@@ -31,7 +31,7 @@ Nucleo-F429ZI.
31
31
32
32
| Skeleton project | MCU datasheet | Board datasheet | Status |
33
33
| --------- | ---------------- | ------------- | ------------ |
34
- | [ STM32 Nucleo-F429ZI] ( step-7-webserver/nucleo-f429zi/ ) | [ mcu datasheet] ( https://www.st.com/resource/en/reference_manual/dm00031020-stm32f405-415-stm32f407-417-stm32f427-437-and-stm32f429-439-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf ) | [ board datasheet] ( https//www.st.com/resource/en/user_manual/dm00244518-stm32-nucleo144-boards-mb1137-stmicroelectronics.pdf ) | complete |
34
+ | [ STM32 Nucleo-F429ZI] ( step-7-webserver/nucleo-f429zi/ ) | [ mcu datasheet] ( https://www.st.com/resource/en/reference_manual/dm00031020-stm32f405-415-stm32f407-417-stm32f427-437-and-stm32f429-439-advanced-arm-based-32-bit-mcus-stmicroelectronics.pdf ) | [ board datasheet] ( https: //www.st.com/resource/en/user_manual/dm00244518-stm32-nucleo144-boards-mb1137-stmicroelectronics.pdf ) | complete |
35
35
| [ TI EK-TM4C1294XL] ( step-7-webserver/ek-tm4c1294xl/ ) | [ mcu datasheet] ( https://www.ti.com/lit/ds/symlink/tm4c1294ncpdt.pdf ) | [ board datasheet] ( https://www.ti.com/lit/ug/spmu365c/spmu365c.pdf ) | complete |
36
36
| [ RP2040 Pico-W5500] ( step-7-webserver/pico-w5500/ ) | [ mcu datasheet] ( https://datasheets.raspberrypi.com/rp2040/rp2040-datasheet.pdf ) | [ board datasheet] ( https://docs.wiznet.io/Product/iEthernet/W5500/w5500-evb-pico ) | complete |
37
37
@@ -764,7 +764,7 @@ int main(void) {
764
764
uint16_t led = PIN(' B' , 7); // Blue LED
765
765
RCC->AHB1ENR |= BIT(PINBANK(led)); // Enable GPIO clock for LED
766
766
gpio_set_mode(led, GPIO_MODE_OUTPUT); // Set blue LED to output mode
767
- for (;;) asm volatile("nop"); // Infinite loop
767
+ for (;;) (void) 0; // Infinite loop
768
768
return 0;
769
769
}
770
770
```
@@ -779,7 +779,7 @@ register (i.e. set pin low). Let's define an API function for that:
779
779
` ` ` c
780
780
static inline void gpio_write(uint16_t pin, bool val) {
781
781
struct gpio * gpio = GPIO(PINBANK(pin));
782
- gpio-> BSRR | = (1U << PINNO(pin)) << (val ? 0 : 16);
782
+ gpio-> BSRR = (1U << PINNO(pin)) << (val ? 0 : 16);
783
783
}
784
784
` ` `
785
785
@@ -789,7 +789,7 @@ a NOP instruction a given number of times:
789
789
790
790
```c
791
791
static inline void spin(volatile uint32_t count) {
792
- while (count--) asm("nop") ;
792
+ while (count--) (void) 0 ;
793
793
}
794
794
```
795
795
@@ -932,7 +932,7 @@ Now we are ready to update our main loop and use a precise timer for LED blink.
932
932
For example, let' s use 250 milliseconds blinking interval:
933
933
934
934
` ` ` c
935
- uint32_t timer, period = 250 ; // Declare timer and 250ms period
935
+ uint32_t timer, period = 500 ; // Declare timer and 500ms period
936
936
for (;; ) {
937
937
if (timer_expired(& timer, period, s_ticks)) {
938
938
static bool on; // This block is executed
@@ -1019,16 +1019,16 @@ Now we're ready to create a UART initialization API function:
1019
1019
#define FREQ 16000000 // CPU frequency, 16 Mhz
1020
1020
static inline void uart_init(struct uart *uart, unsigned long baud) {
1021
1021
// https://www.st.com/resource/en/datasheet/stm32f429zi.pdf
1022
- uint8_t af = 0 ; // Alternate function
1022
+ uint8_t af = 7 ; // Alternate function
1023
1023
uint16_t rx = 0, tx = 0; // pins
1024
1024
1025
1025
if (uart == UART1) RCC->APB2ENR |= BIT(4);
1026
1026
if (uart == UART2) RCC->APB1ENR |= BIT(17);
1027
1027
if (uart == UART3) RCC->APB1ENR |= BIT(18);
1028
1028
1029
- if (uart == UART1) af = 4, tx = PIN(' A' , 9), rx = PIN(' A' , 10);
1030
- if (uart == UART2) af = 4, tx = PIN(' A' , 2), rx = PIN(' A' , 3);
1031
- if (uart == UART3) af = 7, tx = PIN(' D' , 8), rx = PIN(' D' , 9);
1029
+ if (uart == UART1) tx = PIN(' A' , 9), rx = PIN(' A' , 10);
1030
+ if (uart == UART2) tx = PIN(' A' , 2), rx = PIN(' A' , 3);
1031
+ if (uart == UART3) tx = PIN(' D' , 8), rx = PIN(' D' , 9);
1032
1032
1033
1033
gpio_set_mode(tx, GPIO_MODE_AF);
1034
1034
gpio_set_af(tx, af);
@@ -1156,7 +1156,7 @@ int main(void) {
1156
1156
systick_init(16000000 / 1000); // Tick every 1 ms
1157
1157
gpio_set_mode(led, GPIO_MODE_OUTPUT); // Set blue LED to output mode
1158
1158
uart_init(UART3, 115200); // Initialise UART
1159
- uint32_t timer = 0, period = 250 ; // Declare timer and 250ms period
1159
+ uint32_t timer = 0, period = 500 ; // Declare timer and 500ms period
1160
1160
for (;; ) {
1161
1161
if (timer_expired(& timer, period, s_ticks)) {
1162
1162
static bool on; // This block is executed
@@ -1364,7 +1364,7 @@ standard C inludes, vendor CMSIS include, defines to PIN, BIT, FREQ, and
1364
1364
# define PINBANK(pin) (pin >> 8)
1365
1365
1366
1366
static inline void spin(volatile uint32_t count) {
1367
- while (count--) asm( " nop " ) ;
1367
+ while (count--) (void) 0 ;
1368
1368
}
1369
1369
1370
1370
static inline bool timer_expired(uint32_t * t, uint32_t prd, uint32_t now) {
0 commit comments