@@ -179,11 +179,11 @@ we set a number of bits to zero? In four steps:
179179| Get a number with N contiguous bits set: ` 2^N-1 ` , N=2 | ` 3 ` | ` 000000000011 ` |
180180| Shift that number X positions left | ` (3<<6) ` | ` 000011000000 ` |
181181| Invert the number: turn zeros to ones, and ones to zeroes | ` ~(3<<6) ` | ` 111100111111 ` |
182- | Logical AND with existing value | ` VAL &= ~(3<<6) ` | ` xxxx00xxxxxx ` |
182+ | Bitwise AND with existing value | ` VAL &= ~(3<<6) ` | ` xxxx00xxxxxx ` |
183183
184- Note that the last operation, logical AND, turns N bits at position X to zero
184+ Note that the last operation, bitwise AND, turns N bits at position X to zero
185185(because they are ANDed with 0), but retains the value of all other bits
186- (because they are ANDed with 1). Retaining existing value is important, cause
186+ (because they are ANDed with 1). Retaining existing value is important, cause
187187we don't want to change settings in other bit ranges. So in general, if we want
188188to clear N bits at position X:
189189
@@ -295,7 +295,7 @@ self-explanatory and human readable.
295295
296296When an ARM MCU boots, it reads a so-called "vector table" from the
297297beginning of flash memory. A vector table is a concept common to all ARM MCUs.
298- That is a array of 32-bit addresses of interrupt handlers. First 16 entries
298+ That is an array of 32-bit addresses of interrupt handlers. First 16 entries
299299are reserved by ARM and are common to all ARM MCUs. The rest of interrupt
300300handlers are specific to the given MCU - these are interrupt handlers for
301301peripherals. Simpler MCUs with few peripherals have few interrupt handlers,
@@ -342,7 +342,7 @@ For function `_reset()`, we have used GCC-specific attributes `naked` and
342342be created by the compiler, and that function does not return .
343343
344344The `void (*const tab[16 + 91 ])(void )` expression means: define an array of 16
345- + 91 pointers to functions, that return nothing (void ) and take to arguments.
345+ + 91 pointers to functions which return nothing (void ) and take to arguments.
346346Each such function is an IRQ handler (Interrupt ReQuest handler). An array of
347347those handlers is called a vector table.
348348
@@ -653,7 +653,7 @@ Now, what is left - is the `flash` target:
653653
654654```make
655655firmware.bin: firmware.elf
656- $(DOCKER) $(CROSS) -objcopy -O binary $< $@
656+ arm-none-eabi -objcopy -O binary $< $@
657657
658658flash: firmware.bin
659659 st-flash --reset write $< 0x8000000
@@ -894,7 +894,7 @@ Now we should add `SysTick_Handler()` interrupt handler to the vector table:
894894
895895` ` ` c
896896__attribute__(( section(".vectors")) ) void (* const tab[16 + 91])(void) = {
897- 0 , _reset, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SysTick_Handler};
897+ _estack , _reset, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, SysTick_Handler};
898898` ` `
899899
900900Now we have a precise millisecond clock! Let' s create a helper function
@@ -970,11 +970,11 @@ To configure UART, we need to:
970970- Enable the peripheral, receive and transmit via the CR1 register
971971
972972We already know how to set a GPIO pin into a specific mode. If a pin is in the
973- AF mode, we also need to specify the "function number", i.e. which exactly
973+ AF mode, we also need to specify the "function number", i.e. which exact
974974peripheral takes control. This can be done via the "alternate function register",
975975`AFR`, of the GPIO peripheral. Reading the AFR register description in the
976976datasheet, we can see that the AF number occupies 4 bits, thus the whole setup
977- for 16 pins occupies 2 registers. If a p
977+ for 16 pins occupies 2 registers.
978978
979979```c
980980static inline void gpio_set_af(uint16_t pin, uint8_t af_num) {
@@ -1076,7 +1076,7 @@ On my Mac workstation, I use `cu`. It also can be used on Linux. On Windows,
10761076using ` putty` utility can be a good idea. Run a terminal and see the messages:
10771077
10781078` ` ` sh
1079- $ cu -l /dev/cu. YOUR_SERIAL_PORT -s 115200
1079+ $ cu -l /dev/YOUR_SERIAL_PORT -s 115200
10801080hi
10811081hi
10821082` ` `
@@ -1099,7 +1099,7 @@ then a newlib code will be added to our firmware by the GCC linker.
10991099
11001100Some of the standard C functions that newlib implements, specifically, file
11011101input/output (IO) operations, implemented by the newlib is a special fashion: those
1102- functions eventually call a set of low-level IO functions called "sycalls ".
1102+ functions eventually call a set of low-level IO functions called "syscalls ".
11031103
11041104For example:
11051105- `fopen()` eventually calls `_open()`
@@ -1306,7 +1306,7 @@ CMSIS stands for Common Microcontroller Software Interface Standard, thus it is
13061306a common ground for the MCU manufacturers to specify peripheral API. Since
13071307CMSIS is an ARM standard, and since CMSIS headers are supplied by the MCU
13081308vendor, they are the source of authority. Therefore, using vendor
1309- headers is is a preferred way, rather than writing definitions manually.
1309+ headers is a preferred way, rather than writing definitions manually.
13101310
13111311In this section, we will replace our API functions in the ` mcu.h` by the
13121312CMSIS vendor header, and leave the rest of the firmware intact.
0 commit comments