|
|
@ -11,8 +11,8 @@ void init_gpios(void) |
|
|
|
gpio_enable(GPIOB); |
|
|
|
gpio_enable(GPIOB); |
|
|
|
gpio_enable(GPIOC); |
|
|
|
gpio_enable(GPIOC); |
|
|
|
|
|
|
|
|
|
|
|
gpio_set_mode(GPIOC, BIT8 | BIT9 | BIT7, MODER_OUTPUT); |
|
|
|
// LEDs
|
|
|
|
gpio_set_mode(GPIOA, BIT0, MODER_INPUT); |
|
|
|
gpio_set_mode(GPIOC, BIT8 | BIT9, MODER_OUTPUT); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -38,21 +38,21 @@ void init_clock(void) |
|
|
|
|
|
|
|
|
|
|
|
void init_usart(void) |
|
|
|
void init_usart(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
gpio_set_af(GPIOC, BIT10 | BIT11, AF7); |
|
|
|
gpio_set_af(GPIOA, BIT2 | BIT3, AF7); |
|
|
|
|
|
|
|
|
|
|
|
// USART at C10 (tx), C11 (rx)
|
|
|
|
// USART at A2 (tx), A3 (rx)
|
|
|
|
RCC_APB1ENR |= RCC_APB1ENR_USART3EN; |
|
|
|
RCC_APB1ENR |= RCC_APB1ENR_USART2EN; |
|
|
|
|
|
|
|
|
|
|
|
// RATE 9600Bd 104.1875 (see datasheet for reference)
|
|
|
|
// RATE 9600Bd 104.1875 (see datasheet for reference)
|
|
|
|
//USART3_BRR = 0x00683; // 9600 @ 16MHz
|
|
|
|
//USART2_BRR = 0x00683; // 9600 @ 16MHz
|
|
|
|
USART3_BRR = 0x0008A; // 115200 @ 16MHz
|
|
|
|
USART2_BRR = 0x0008A; // 115200 @ 16MHz
|
|
|
|
|
|
|
|
|
|
|
|
// USART enable
|
|
|
|
// USART enable
|
|
|
|
USART3_CR1 = USART_CR1_UE | USART_CR1_RE | USART_CR1_TE; |
|
|
|
USART2_CR1 = USART_CR1_UE | USART_CR1_RE | USART_CR1_TE; |
|
|
|
|
|
|
|
|
|
|
|
// enable interrupt on data receive
|
|
|
|
// enable interrupt on data receive
|
|
|
|
nvic_enable_irq(NVIC_USART3_IRQ); |
|
|
|
nvic_enable_irq(NVIC_USART2_IRQ); |
|
|
|
USART3_CR1 |= USART_CR1_RXNEIE; |
|
|
|
USART2_CR1 |= USART_CR1_RXNEIE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -67,6 +67,8 @@ void init_systick(void) |
|
|
|
|
|
|
|
|
|
|
|
void init_adc(void) |
|
|
|
void init_adc(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
gpio_set_mode(GPIOB, BIT12, MODER_ANALOG); |
|
|
|
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
// TODO
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|