/** * STM32 F4 Mini library for custom board * * Author: Jan Dvořák z Vozerovic * E-mail: dvorkaman@gmail.com * Web: dvorkaman.asp2.cz * Created: 2015 */ /* Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __dvorkaman_STM32F4Mini_h__ #define __dvorkaman_STM32F4Mini_h__ /* INCLUDES */ #include "stm32f4xx.h" #include "libMotor.h" #include "libServo.h" #include "libPWM.h" #include "libGPIO.h" #include "libRemote.h" #include "libAnalog.h" /* PINOUT */ /* Motors: TIM3 PWM {B4 B5 B0 B1}, control A4..A7 Servos: TIM4 PWM {B6..B9} Lights: B10 B11 B14 B15 XBee USART: C10 C11 User pins: A0..A3: ADC, IO, TIM2 A8, B12, B13, C9: IO, except analog C0, C1, C2, C4, C5: ADC, IO */ /* DEFINES */ #define F4MINI_MAX_ANALOGS 9 /* ENUMERATIONS */ /// /// Enumeration defition of Pin types on GPIOA 0..3 /// typedef enum { io_adc = 0, tim2 = 1 } libF4MiniA0_A3Pins; /* STRUCTS */ /// /// STM32 F4 Mini dolder definition /// typedef struct { // static parts libMotor motor1, motor2, motor3, motor4; // motors libPin light1, light2, light3, light4; // lights libXbeeRx xbee; // xbee reciever libPWMpin s1Pin, s2Pin, s3Pin, s4Pin; // pins for servos libServo servo1, servo2, servo3, servo4; // servos // static pins libPin a8, b12, b13, c9; libPinType a8type, b12type, b13type, c9type; // only IO, not analog (adc) // dynamic pins groups at gpioa 0..3 - all must of of the same group type libF4MiniA0_A3Pins a0_a3; libPin a0, a1, a2, a3; libPinType a0type, a1type, a2type, a3type; // io, adc or tim override // dynamic pins libPin c0, c1, c2, c4, c5; libPinType c0type, c1type, c2type, c4type, c5type; // io, adc // internal libPin yellow, red; libAnalogFilter af; libAnalog analogs[F4MINI_MAX_ANALOGS]; // sorted by used port and pin: GPIO A -> C, Pin 0 -> 15 } libF4Mini; #endif /* FUNCTIONS */ void F4Mini_initialize( libF4Mini* F4Mini, uint32_t xbeeAddr64msb, // XBEE ADDR as ROUTER type; 0 if not used uint32_t xbeeAddr64lsb, // XBEE ADDR as ROUTER type; 0 if not used libF4MiniA0_A3Pins a0_a3Type, // Type of first 4 pins at GPIOA libPinType a0, // Type of pin, available I/O, Analog, not considered (0) if TIM libPinType a1, // Type of pin, available I/O, Analog, not considered (0) if TIM libPinType a2, // Type of pin, available I/O, Analog, not considered (0) if TIM libPinType a3, // Type of pin, available I/O, Analog, not considered (0) if TIM libPinType a8, // Type of pin, available I/O, except Analog libPinType b12, // Type of pin, available I/O except Analog libPinType b13, // Type of pin, available I/O except Analog libPinType c0, // Type of pin, available I/O, Analog libPinType c1, // Type of pin, available I/O, Analog libPinType c2, // Type of pin, available I/O, Analog libPinType c4, // Type of pin, available I/O, Analog libPinType c5, // Type of pin, available I/O, Analog libPinType c9 // Type of pin, available I/O except Analog ); void F4Mini_clearPerihperals(libF4Mini* F4Mini); void F4Mini__initializePerihperals(libF4Mini* F4Mini); // private void F4Mini__initializeUserPins(libF4Mini* F4Mini); // private void F4Mini__initializeUserAnalogPins(libF4Mini* F4Mini, volatile uint16_t* adcAnalogSourceAddress); // private