[stm32f429i-discovery] Switched over to UART1.
UART1 is connected through two jumpers to the programmer chip on the board. Making the use of it very streight forward.
This commit is contained in:
@@ -193,11 +193,10 @@ void console_setup(int baud) {
|
||||
/* MUST enable the GPIO clock in ADDITION to the USART clock */
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
|
||||
/* This example uses PD5 and PD6 for Tx and Rx respectively
|
||||
/* This example uses PA9 and PA10 for Tx and Rx respectively
|
||||
* but other pins are available for this role on USART1 (our chosen
|
||||
* USART) as well, such as PA2 and PA3. You can also split them
|
||||
* so PA2 for Tx, PD6 for Rx but you would have to enable both
|
||||
* the GPIOA and GPIOD clocks in that case
|
||||
* USART) as well. We decided on the ones above as they are connected
|
||||
* to the programming circuitry through jumpers.
|
||||
*/
|
||||
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO10);
|
||||
|
||||
@@ -209,9 +208,11 @@ void console_setup(int baud) {
|
||||
|
||||
|
||||
/* This then enables the clock to the USART1 peripheral which is
|
||||
* attached inside the chip to the APB2 bus. Different peripherals
|
||||
* attached inside the chip to the APB1 bus. Different peripherals
|
||||
* attach to different buses, and even some UARTS are attached to
|
||||
* APB1 and some to APB2, again the data sheet is useful here.
|
||||
* We use the rcc_periph_clock_enable function that knows which
|
||||
* peripheral is on which bus and sets it up for us.
|
||||
*/
|
||||
rcc_periph_clock_enable(RCC_USART1);
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#define CONSOLE_UART USART2
|
||||
#define CONSOLE_UART USART1
|
||||
|
||||
|
||||
/* This is a ring buffer to holding characters as they are typed
|
||||
@@ -62,7 +62,7 @@ volatile int recv_ndx_nxt; // Next place to store
|
||||
volatile int recv_ndx_cur; // Next place to read
|
||||
|
||||
/* For interrupt handling we add a new function which is called
|
||||
* when recieve interrupts happen. The name (usart2_isr) is created
|
||||
* when recieve interrupts happen. The name (usart1_isr) is created
|
||||
* by the irq.json file in libopencm3 calling this interrupt for
|
||||
* USART2 'usart2', adding the suffix '_isr', and then weakly binding
|
||||
* it to the 'do nothing' interrupt function in vec.c.
|
||||
@@ -72,7 +72,7 @@ volatile int recv_ndx_cur; // Next place to read
|
||||
* right or it won't work. And you'll wonder where your interrupts
|
||||
* are going.
|
||||
*/
|
||||
void usart2_isr(void) {
|
||||
void usart1_isr(void) {
|
||||
uint32_t reg;
|
||||
int i;
|
||||
|
||||
@@ -193,29 +193,30 @@ int console_gets(char *s, int len) {
|
||||
void console_setup(void) {
|
||||
|
||||
/* MUST enable the GPIO clock in ADDITION to the USART clock */
|
||||
rcc_periph_clock_enable(RCC_GPIOD);
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
|
||||
/* This example uses PD5 and PD6 for Tx and Rx respectively
|
||||
* but other pins are available for this role on USART2 (our chosen
|
||||
* USART) as well, such as PA2 and PA3. You can also split them
|
||||
* so PA2 for Tx, PD6 for Rx but you would have to enable both
|
||||
* the GPIOA and GPIOD clocks in that case
|
||||
/* This example uses PD9 and PD10 for Tx and Rx respectively
|
||||
* but other pins are available for this role on USART1 (our chosen
|
||||
* USART) as well, we are using them because they are connected over
|
||||
* jumpers to the programmer.
|
||||
*/
|
||||
gpio_mode_setup(GPIOD, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO5 | GPIO6);
|
||||
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO10);
|
||||
|
||||
/* Actual Alternate function number (in this case 7) is part
|
||||
* depenedent, check the data sheet for the right number to
|
||||
* use.
|
||||
*/
|
||||
gpio_set_af(GPIOD, GPIO_AF7, GPIO5 | GPIO6);
|
||||
gpio_set_af(GPIOA, GPIO_AF7, GPIO9 | GPIO10);
|
||||
|
||||
|
||||
/* This then enables the clock to the USART2 peripheral which is
|
||||
* attached inside the chip to the APB2 bus. Different peripherals
|
||||
/* This then enables the clock to the USART1 peripheral which is
|
||||
* attached inside the chip to the APB1 bus. Different peripherals
|
||||
* attach to different buses, and even some UARTS are attached to
|
||||
* APB1 and some to APB2, again the data sheet is useful here.
|
||||
* We are using the rcc_periph_clock_enable function that knows which
|
||||
* peripheral is on which clock bus and sets things up accordingly.
|
||||
*/
|
||||
rcc_periph_clock_enable(RCC_USART2);
|
||||
rcc_periph_clock_enable(RCC_USART1);
|
||||
|
||||
/* Set up USART/UART parameters using the libopencm3 helper functions */
|
||||
usart_set_baudrate(CONSOLE_UART, 115200);
|
||||
@@ -227,7 +228,7 @@ void console_setup(void) {
|
||||
usart_enable(CONSOLE_UART);
|
||||
|
||||
/* Enable interrupts from the USART */
|
||||
nvic_enable_irq(NVIC_USART2_IRQ);
|
||||
nvic_enable_irq(NVIC_USART1_IRQ);
|
||||
|
||||
/* Specifically enable recieve interrupts */
|
||||
usart_enable_rx_interrupt(CONSOLE_UART);
|
||||
|
||||
@@ -47,9 +47,9 @@ volatile int recv_ndx_nxt; // Next place to store
|
||||
volatile int recv_ndx_cur; // Next place to read
|
||||
|
||||
/* For interrupt handling we add a new function which is called
|
||||
* when recieve interrupts happen. The name (usart2_isr) is created
|
||||
* when recieve interrupts happen. The name (usart1_isr) is created
|
||||
* by the irq.json file in libopencm3 calling this interrupt for
|
||||
* USART2 'usart2', adding the suffix '_isr', and then weakly binding
|
||||
* USART1 'usart1', adding the suffix '_isr', and then weakly binding
|
||||
* it to the 'do nothing' interrupt function in vec.c.
|
||||
*
|
||||
* By defining it in this file the linker will override that weak
|
||||
@@ -57,7 +57,7 @@ volatile int recv_ndx_cur; // Next place to read
|
||||
* right or it won't work. And you'll wonder where your interrupts
|
||||
* are going.
|
||||
*/
|
||||
void usart2_isr(void) {
|
||||
void usart1_isr(void) {
|
||||
uint32_t reg;
|
||||
int i;
|
||||
|
||||
@@ -191,29 +191,30 @@ int console_gets(char *s, int len) {
|
||||
void console_setup(int baud) {
|
||||
|
||||
/* MUST enable the GPIO clock in ADDITION to the USART clock */
|
||||
rcc_periph_clock_enable(RCC_GPIOD);
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
|
||||
/* This example uses PD5 and PD6 for Tx and Rx respectively
|
||||
* but other pins are available for this role on USART2 (our chosen
|
||||
* USART) as well, such as PA2 and PA3. You can also split them
|
||||
* so PA2 for Tx, PD6 for Rx but you would have to enable both
|
||||
* the GPIOA and GPIOD clocks in that case
|
||||
/* This example uses PA9 and PA10 for Tx and Rx respectively
|
||||
* but other pins are available for this role on USART1 (our chosen
|
||||
* USART) as well, we are using these because they are connected to the
|
||||
* programmer through some jumpers.
|
||||
*/
|
||||
gpio_mode_setup(GPIOD, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO5 | GPIO6);
|
||||
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO10);
|
||||
|
||||
/* Actual Alternate function number (in this case 7) is part
|
||||
* depenedent, CHECK THE DATA SHEET for the right number to
|
||||
* use.
|
||||
*/
|
||||
gpio_set_af(GPIOD, GPIO_AF7, GPIO5 | GPIO6);
|
||||
gpio_set_af(GPIOA, GPIO_AF7, GPIO9 | GPIO10);
|
||||
|
||||
|
||||
/* This then enables the clock to the USART2 peripheral which is
|
||||
* attached inside the chip to the APB2 bus. Different peripherals
|
||||
/* This then enables the clock to the USART1 peripheral which is
|
||||
* attached inside the chip to the APB1 bus. Different peripherals
|
||||
* attach to different buses, and even some UARTS are attached to
|
||||
* APB1 and some to APB2, again the data sheet is useful here.
|
||||
* We are using rcc_periph_clock_enable that knows which peripheral is
|
||||
* on which clock bus and sets up everything accordingly.
|
||||
*/
|
||||
rcc_periph_clock_enable(RCC_USART2);
|
||||
rcc_periph_clock_enable(RCC_USART1);
|
||||
|
||||
/* Set up USART/UART parameters using the libopencm3 helper functions */
|
||||
usart_set_baudrate(CONSOLE_UART, baud);
|
||||
@@ -225,7 +226,7 @@ void console_setup(int baud) {
|
||||
usart_enable(CONSOLE_UART);
|
||||
|
||||
/* Enable interrupts from the USART */
|
||||
nvic_enable_irq(NVIC_USART2_IRQ);
|
||||
nvic_enable_irq(NVIC_USART1_IRQ);
|
||||
|
||||
/* Specifically enable recieve interrupts */
|
||||
usart_enable_rx_interrupt(CONSOLE_UART);
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
* we can use on a serial port.
|
||||
*/
|
||||
|
||||
#define CONSOLE_UART USART2
|
||||
#define CONSOLE_UART USART1
|
||||
|
||||
void console_putc(char c);
|
||||
char console_getc(int wait);
|
||||
@@ -134,28 +134,29 @@ int main(void) {
|
||||
clock_setup(); // initialize our clock
|
||||
|
||||
/* MUST enable the GPIO clock in ADDITION to the USART clock */
|
||||
rcc_periph_clock_enable(RCC_GPIOD);
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
|
||||
/* This example uses PD5 and PD6 for Tx and Rx respectively
|
||||
* but other pins are available for this role on USART2 (our chosen
|
||||
* USART) as well, such as PA2 and PA3. You can also split them
|
||||
* so PA2 for Tx, PD6 for Rx but you would have to enable both
|
||||
* the GPIOA and GPIOD clocks in that case
|
||||
/* This example uses PA9 and PA10 for Tx and Rx respectively
|
||||
* but other pins are available for this role on USART1 (our chosen
|
||||
* USART) as it is connected to the programmer interface through
|
||||
* jumpers.
|
||||
*/
|
||||
gpio_mode_setup(GPIOD, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO5 | GPIO6);
|
||||
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO10);
|
||||
|
||||
/* Actual Alternate function number (in this case 7) is part
|
||||
* depenedent, check the data sheet for the right number to
|
||||
* use.
|
||||
*/
|
||||
gpio_set_af(GPIOD, GPIO_AF7, GPIO5 | GPIO6);
|
||||
gpio_set_af(GPIOA, GPIO_AF7, GPIO9 | GPIO10);
|
||||
|
||||
/* This then enables the clock to the USART2 peripheral which is
|
||||
* attached inside the chip to the APB2 bus. Different peripherals
|
||||
/* This then enables the clock to the USART1 peripheral which is
|
||||
* attached inside the chip to the APB1 bus. Different peripherals
|
||||
* attach to different buses, and even some UARTS are attached to
|
||||
* APB1 and some to APB2, again the data sheet is useful here.
|
||||
* We use the rcc_periph_clock_enable function that knows on which bus
|
||||
* the peripheral is and sets things up accordingly.
|
||||
*/
|
||||
rcc_periph_clock_enable(RCC_USART2);
|
||||
rcc_periph_clock_enable(RCC_USART1);
|
||||
|
||||
/* Set up USART/UART parameters using the libopencm3 helper functions */
|
||||
usart_set_baudrate(CONSOLE_UART, 115200);
|
||||
|
||||
@@ -22,7 +22,7 @@ BINARY = usart_irq_console
|
||||
# Example showing how to generate a map file.
|
||||
LDFLAGS += -Wl,--Map=$(BINARY).map
|
||||
|
||||
LDSCRIPT = ../stm32f4-disco.ld
|
||||
LDSCRIPT = ../stm32f429i-discovery.ld
|
||||
|
||||
include ../../Makefile.include
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
*/
|
||||
|
||||
|
||||
#define CONSOLE_UART USART2
|
||||
#define CONSOLE_UART USART1
|
||||
|
||||
void console_putc(char c);
|
||||
char console_getc(int wait);
|
||||
@@ -97,9 +97,9 @@ volatile int recv_ndx_nxt; // Next place to store
|
||||
volatile int recv_ndx_cur; // Next place to read
|
||||
|
||||
/* For interrupt handling we add a new function which is called
|
||||
* when recieve interrupts happen. The name (usart2_isr) is created
|
||||
* when recieve interrupts happen. The name (usart1_isr) is created
|
||||
* by the irq.json file in libopencm3 calling this interrupt for
|
||||
* USART2 'usart2', adding the suffix '_isr', and then weakly binding
|
||||
* USART1 'usart1', adding the suffix '_isr', and then weakly binding
|
||||
* it to the 'do nothing' interrupt function in vec.c.
|
||||
*
|
||||
* By defining it in this file the linker will override that weak
|
||||
@@ -107,7 +107,7 @@ volatile int recv_ndx_cur; // Next place to read
|
||||
* right or it won't work. And you'll wonder where your interrupts
|
||||
* are going.
|
||||
*/
|
||||
void usart2_isr(void) {
|
||||
void usart1_isr(void) {
|
||||
uint32_t reg;
|
||||
int i;
|
||||
|
||||
@@ -272,29 +272,28 @@ int main(void) {
|
||||
clock_setup(); // initialize our clock
|
||||
|
||||
/* MUST enable the GPIO clock in ADDITION to the USART clock */
|
||||
rcc_periph_clock_enable(RCC_GPIOD);
|
||||
rcc_periph_clock_enable(RCC_GPIOA);
|
||||
|
||||
/* This example uses PD5 and PD6 for Tx and Rx respectively
|
||||
* but other pins are available for this role on USART2 (our chosen
|
||||
* USART) as well, such as PA2 and PA3. You can also split them
|
||||
* so PA2 for Tx, PD6 for Rx but you would have to enable both
|
||||
* the GPIOA and GPIOD clocks in that case
|
||||
/* This example uses PA9 and PA10 for Tx and Rx respectively
|
||||
* but other pins are available for this role on USART1 (our chosen
|
||||
* USART) as well. We are using the ones mentioned above because they
|
||||
* are connected to the programmer on the board through some jumpers.
|
||||
*/
|
||||
gpio_mode_setup(GPIOD, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO5 | GPIO6);
|
||||
gpio_mode_setup(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO9 | GPIO10);
|
||||
|
||||
/* Actual Alternate function number (in this case 7) is part
|
||||
* depenedent, CHECK THE DATA SHEET for the right number to
|
||||
* use.
|
||||
*/
|
||||
gpio_set_af(GPIOD, GPIO_AF7, GPIO5 | GPIO6);
|
||||
gpio_set_af(GPIOA, GPIO_AF7, GPIO9 | GPIO10);
|
||||
|
||||
|
||||
/* This then enables the clock to the USART2 peripheral which is
|
||||
* attached inside the chip to the APB2 bus. Different peripherals
|
||||
/* This then enables the clock to the USART1 peripheral which is
|
||||
* attached inside the chip to the APB1 bus. Different peripherals
|
||||
* attach to different buses, and even some UARTS are attached to
|
||||
* APB1 and some to APB2, again the data sheet is useful here.
|
||||
*/
|
||||
rcc_periph_clock_enable(RCC_USART2);
|
||||
rcc_periph_clock_enable(RCC_USART1);
|
||||
|
||||
/* Set up USART/UART parameters using the libopencm3 helper functions */
|
||||
usart_set_baudrate(CONSOLE_UART, 115200);
|
||||
@@ -306,7 +305,7 @@ int main(void) {
|
||||
usart_enable(CONSOLE_UART);
|
||||
|
||||
/* Enable interrupts from the USART */
|
||||
nvic_enable_irq(NVIC_USART2_IRQ);
|
||||
nvic_enable_irq(NVIC_USART1_IRQ);
|
||||
|
||||
/* Specifically enable recieve interrupts */
|
||||
usart_enable_rx_interrupt(CONSOLE_UART);
|
||||
|
||||
Reference in New Issue
Block a user