mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 03:20:00 +03:00
added softi2c source file (oops)
changed gpio speeds to 2mhz from 50, nothing is toggling at 50mhz here. reduce ringing/noise. git-svn-id: https://afrodevices.googlecode.com/svn/trunk/baseflight@181 7c89a4a9-59b9-e629-4cfe-3a2d53b20e61
This commit is contained in:
parent
23d11299b8
commit
e70d7b5d16
11 changed files with 781 additions and 549 deletions
1
Makefile
1
Makefile
|
@ -49,6 +49,7 @@ COMMON_SRC = startup_stm32f10x_md_gcc.S \
|
||||||
spektrum.c \
|
spektrum.c \
|
||||||
telemetry.c \
|
telemetry.c \
|
||||||
drv_i2c.c \
|
drv_i2c.c \
|
||||||
|
drv_i2c_soft.c \
|
||||||
drv_system.c \
|
drv_system.c \
|
||||||
drv_uart.c \
|
drv_uart.c \
|
||||||
$(CMSIS_SRC) \
|
$(CMSIS_SRC) \
|
||||||
|
|
|
@ -614,6 +614,11 @@
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>.\src\drv_hcsr04.c</FilePath>
|
<FilePath>.\src\drv_hcsr04.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>drv_i2c_soft.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>.\src\drv_i2c_soft.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
@ -1389,6 +1394,11 @@
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>.\src\drv_hcsr04.c</FilePath>
|
<FilePath>.\src\drv_hcsr04.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>drv_i2c_soft.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>.\src\drv_i2c_soft.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
@ -2344,6 +2354,11 @@
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>.\src\drv_hcsr04.c</FilePath>
|
<FilePath>.\src\drv_hcsr04.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>drv_i2c_soft.c</FileName>
|
||||||
|
<FileType>1</FileType>
|
||||||
|
<FilePath>.\src\drv_i2c_soft.c</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
|
1068
obj/baseflight.hex
1068
obj/baseflight.hex
File diff suppressed because it is too large
Load diff
|
@ -96,7 +96,7 @@ bool bmp085Init(void)
|
||||||
|
|
||||||
// PC13, PC14 (Barometer XCLR reset output, EOC input)
|
// PC13, PC14 (Barometer XCLR reset output, EOC input)
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
GPIO_Init(GPIOC, &GPIO_InitStructure);
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
|
||||||
|
|
|
@ -84,7 +84,7 @@ void hcsr04_init(sonar_config_t config)
|
||||||
// tp - trigger pin
|
// tp - trigger pin
|
||||||
GPIO_InitStructure.GPIO_Pin = trigger_pin;
|
GPIO_InitStructure.GPIO_Pin = trigger_pin;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
|
||||||
// ep - echo pin
|
// ep - echo pin
|
||||||
|
|
|
@ -265,7 +265,7 @@ void i2cInit(I2C_TypeDef *I2C)
|
||||||
|
|
||||||
// Init pins
|
// Init pins
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
|
||||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ static void i2cUnstick(void)
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_OD;
|
||||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ static void i2cUnstick(void)
|
||||||
|
|
||||||
// Init pins
|
// Init pins
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
|
||||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
}
|
}
|
||||||
|
|
216
src/drv_i2c_soft.c
Normal file
216
src/drv_i2c_soft.c
Normal file
|
@ -0,0 +1,216 @@
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
|
// Software I2C driver, using same pins as hardware I2C, with hw i2c module disabled.
|
||||||
|
// SCL PB10
|
||||||
|
// SDA PB11
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef SOFT_I2C
|
||||||
|
|
||||||
|
#define SCL_H GPIOB->BSRR = GPIO_Pin_10 /* GPIO_SetBits(GPIOB , GPIO_Pin_10) */
|
||||||
|
#define SCL_L GPIOB->BRR = GPIO_Pin_10 /* GPIO_ResetBits(GPIOB , GPIO_Pin_10) */
|
||||||
|
|
||||||
|
#define SDA_H GPIOB->BSRR = GPIO_Pin_11 /* GPIO_SetBits(GPIOB , GPIO_Pin_11) */
|
||||||
|
#define SDA_L GPIOB->BRR = GPIO_Pin_11 /* GPIO_ResetBits(GPIOB , GPIO_Pin_11) */
|
||||||
|
|
||||||
|
#define SCL_read GPIOB->IDR & GPIO_Pin_10 /* GPIO_ReadInputDataBit(GPIOB , GPIO_Pin_10) */
|
||||||
|
#define SDA_read GPIOB->IDR & GPIO_Pin_11 /* GPIO_ReadInputDataBit(GPIOB , GPIO_Pin_11) */
|
||||||
|
|
||||||
|
static void I2C_delay(void)
|
||||||
|
{
|
||||||
|
volatile int i = 7;
|
||||||
|
while (i) {
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool I2C_Start(void)
|
||||||
|
{
|
||||||
|
SDA_H;
|
||||||
|
SCL_H;
|
||||||
|
I2C_delay();
|
||||||
|
if (!SDA_read)
|
||||||
|
return false;
|
||||||
|
SDA_L;
|
||||||
|
I2C_delay();
|
||||||
|
if (SDA_read)
|
||||||
|
return false;
|
||||||
|
SDA_L;
|
||||||
|
I2C_delay();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void I2C_Stop(void)
|
||||||
|
{
|
||||||
|
SCL_L;
|
||||||
|
I2C_delay();
|
||||||
|
SDA_L;
|
||||||
|
I2C_delay();
|
||||||
|
SCL_H;
|
||||||
|
I2C_delay();
|
||||||
|
SDA_H;
|
||||||
|
I2C_delay();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void I2C_Ack(void)
|
||||||
|
{
|
||||||
|
SCL_L;
|
||||||
|
I2C_delay();
|
||||||
|
SDA_L;
|
||||||
|
I2C_delay();
|
||||||
|
SCL_H;
|
||||||
|
I2C_delay();
|
||||||
|
SCL_L;
|
||||||
|
I2C_delay();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void I2C_NoAck(void)
|
||||||
|
{
|
||||||
|
SCL_L;
|
||||||
|
I2C_delay();
|
||||||
|
SDA_H;
|
||||||
|
I2C_delay();
|
||||||
|
SCL_H;
|
||||||
|
I2C_delay();
|
||||||
|
SCL_L;
|
||||||
|
I2C_delay();
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool I2C_WaitAck(void)
|
||||||
|
{
|
||||||
|
SCL_L;
|
||||||
|
I2C_delay();
|
||||||
|
SDA_H;
|
||||||
|
I2C_delay();
|
||||||
|
SCL_H;
|
||||||
|
I2C_delay();
|
||||||
|
if (SDA_read) {
|
||||||
|
SCL_L;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SCL_L;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void I2C_SendByte(uint8_t byte)
|
||||||
|
{
|
||||||
|
uint8_t i = 8;
|
||||||
|
while (i--) {
|
||||||
|
SCL_L;
|
||||||
|
I2C_delay();
|
||||||
|
if (byte & 0x80)
|
||||||
|
SDA_H;
|
||||||
|
else
|
||||||
|
SDA_L;
|
||||||
|
byte <<= 1;
|
||||||
|
I2C_delay();
|
||||||
|
SCL_H;
|
||||||
|
I2C_delay();
|
||||||
|
}
|
||||||
|
SCL_L;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8_t I2C_ReceiveByte(void)
|
||||||
|
{
|
||||||
|
uint8_t i = 8;
|
||||||
|
uint8_t byte = 0;
|
||||||
|
|
||||||
|
SDA_H;
|
||||||
|
while (i--) {
|
||||||
|
byte <<= 1;
|
||||||
|
SCL_L;
|
||||||
|
I2C_delay();
|
||||||
|
SCL_H;
|
||||||
|
I2C_delay();
|
||||||
|
if (SDA_read) {
|
||||||
|
byte |= 0x01;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SCL_L;
|
||||||
|
return byte;
|
||||||
|
}
|
||||||
|
|
||||||
|
void i2cInit(I2C_TypeDef * I2C)
|
||||||
|
{
|
||||||
|
GPIO_InitTypeDef gpio;
|
||||||
|
|
||||||
|
gpio.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11;
|
||||||
|
gpio.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
|
gpio.GPIO_Mode = GPIO_Mode_Out_OD;
|
||||||
|
GPIO_Init(GPIOB, &gpio);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool i2cWriteBuffer(uint8_t addr, uint8_t reg, uint8_t len, uint8_t * data)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
if (!I2C_Start())
|
||||||
|
return false;
|
||||||
|
I2C_SendByte(addr << 1 | I2C_Direction_Transmitter);
|
||||||
|
if (!I2C_WaitAck()) {
|
||||||
|
I2C_Stop();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
I2C_SendByte(reg);
|
||||||
|
I2C_WaitAck();
|
||||||
|
for (i = 0; i < len; i++) {
|
||||||
|
I2C_SendByte(data[i]);
|
||||||
|
if (!I2C_WaitAck()) {
|
||||||
|
I2C_Stop();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
I2C_Stop();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool i2cWrite(uint8_t addr, uint8_t reg, uint8_t data)
|
||||||
|
{
|
||||||
|
if (!I2C_Start())
|
||||||
|
return false;
|
||||||
|
I2C_SendByte(addr << 1 | I2C_Direction_Transmitter);
|
||||||
|
if (!I2C_WaitAck()) {
|
||||||
|
I2C_Stop();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
I2C_SendByte(reg);
|
||||||
|
I2C_WaitAck();
|
||||||
|
I2C_SendByte(data);
|
||||||
|
I2C_WaitAck();
|
||||||
|
I2C_Stop();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool i2cRead(uint8_t addr, uint8_t reg, uint8_t len, uint8_t *buf)
|
||||||
|
{
|
||||||
|
if (!I2C_Start())
|
||||||
|
return false;
|
||||||
|
I2C_SendByte(addr << 1 | I2C_Direction_Transmitter);
|
||||||
|
if (!I2C_WaitAck()) {
|
||||||
|
I2C_Stop();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
I2C_SendByte(reg);
|
||||||
|
I2C_WaitAck();
|
||||||
|
I2C_Start();
|
||||||
|
I2C_SendByte(addr << 1 | I2C_Direction_Receiver);
|
||||||
|
I2C_WaitAck();
|
||||||
|
while (len) {
|
||||||
|
*buf = I2C_ReceiveByte();
|
||||||
|
if (len == 1)
|
||||||
|
I2C_NoAck();
|
||||||
|
else
|
||||||
|
I2C_Ack();
|
||||||
|
buf++;
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
I2C_Stop();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t i2cGetErrorCounter(void)
|
||||||
|
{
|
||||||
|
// TODO maybe fix this, but since this is test code, doesn't matter.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -165,7 +165,7 @@ static void pwmInitializeInput(bool usePPM)
|
||||||
// Configure TIM2_CH1 for PPM input
|
// Configure TIM2_CH1 for PPM input
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
|
||||||
// Input timer on TIM2 only for PPM
|
// Input timer on TIM2 only for PPM
|
||||||
|
@ -200,7 +200,7 @@ static void pwmInitializeInput(bool usePPM)
|
||||||
// Configure TIM2, TIM3 all 4 channels
|
// Configure TIM2, TIM3 all 4 channels
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_6 | GPIO_Pin_7;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_6 | GPIO_Pin_7;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
|
||||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
@ -276,7 +276,7 @@ bool pwmInit(drv_pwm_config_t *init)
|
||||||
// Configure TIM2_CH1 for input
|
// Configure TIM2_CH1 for input
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -307,7 +307,7 @@ bool pwmInit(drv_pwm_config_t *init)
|
||||||
// Output pins
|
// Output pins
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_11;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_11;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;
|
||||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
@ -361,7 +361,7 @@ bool pwmInit(drv_pwm_config_t *init)
|
||||||
// PWM 7,8,9,10
|
// PWM 7,8,9,10
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
|
||||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
|
|
@ -167,7 +167,7 @@ static void pwmInitializeInput(bool usePPM)
|
||||||
// Configure TIM2_CH1 for PPM input
|
// Configure TIM2_CH1 for PPM input
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
|
||||||
// Input timer on TIM2 only for PPM
|
// Input timer on TIM2 only for PPM
|
||||||
|
@ -202,7 +202,7 @@ static void pwmInitializeInput(bool usePPM)
|
||||||
// Configure TIM2 all 4 channels
|
// Configure TIM2 all 4 channels
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
|
|
||||||
// TODO Configure EXTI4 1 channel
|
// TODO Configure EXTI4 1 channel
|
||||||
|
@ -285,7 +285,7 @@ bool pwmInit(drv_pwm_config_t *init)
|
||||||
// Output pins (4x)
|
// Output pins (4x)
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||||
|
|
||||||
// Output timer
|
// Output timer
|
||||||
|
|
|
@ -75,7 +75,7 @@ void systemInit(void)
|
||||||
// Configure gpio
|
// Configure gpio
|
||||||
for (i = 0; i < gpio_count; i++) {
|
for (i = 0; i < gpio_count; i++) {
|
||||||
GPIO_InitStructure.GPIO_Pin = gpio_cfg[i].pin;
|
GPIO_InitStructure.GPIO_Pin = gpio_cfg[i].pin;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_InitStructure.GPIO_Mode = gpio_cfg[i].mode;
|
GPIO_InitStructure.GPIO_Mode = gpio_cfg[i].mode;
|
||||||
GPIO_Init(gpio_cfg[i].gpio, &GPIO_InitStructure);
|
GPIO_Init(gpio_cfg[i].gpio, &GPIO_InitStructure);
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ void uartInit(uint32_t speed)
|
||||||
// USART1_RX PA10
|
// USART1_RX PA10
|
||||||
|
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
|
||||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
|
||||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
|
||||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
|
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue