Skip to content

Commit ca76038

Browse files
committed
Merge branch 'main' of github.com:cpq/bare-metal-programming-guide
2 parents 07844c7 + 123808c commit ca76038

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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
187187
we don't want to change settings in other bit ranges. So in general, if we want
188188
to clear N bits at position X:
189189

@@ -295,7 +295,7 @@ self-explanatory and human readable.
295295
296296
When an ARM MCU boots, it reads a so-called "vector table" from the
297297
beginning 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
299299
are reserved by ARM and are common to all ARM MCUs. The rest of interrupt
300300
handlers are specific to the given MCU - these are interrupt handlers for
301301
peripherals. Simpler MCUs with few peripherals have few interrupt handlers,
@@ -342,7 +342,7 @@ For function `_reset()`, we have used GCC-specific attributes `naked` and
342342
be created by the compiler, and that function does not return.
343343

344344
The `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.
346346
Each such function is an IRQ handler (Interrupt ReQuest handler). An array of
347347
those handlers is called a vector table.
348348

@@ -653,7 +653,7 @@ Now, what is left - is the `flash` target:
653653
654654
```make
655655
firmware.bin: firmware.elf
656-
$(DOCKER) $(CROSS)-objcopy -O binary $< $@
656+
arm-none-eabi-objcopy -O binary $< $@
657657
658658
flash: 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
900900
Now 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
972972
We 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
974974
peripheral takes control. This can be done via the "alternate function register",
975975
`AFR`, of the GPIO peripheral. Reading the AFR register description in the
976976
datasheet, 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
980980
static 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,
10761076
using `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
10801080
hi
10811081
hi
10821082
```
@@ -1099,7 +1099,7 @@ then a newlib code will be added to our firmware by the GCC linker.
10991099
11001100
Some of the standard C functions that newlib implements, specifically, file
11011101
input/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
11041104
For example:
11051105
- `fopen()` eventually calls `_open()`
@@ -1306,7 +1306,7 @@ CMSIS stands for Common Microcontroller Software Interface Standard, thus it is
13061306
a common ground for the MCU manufacturers to specify peripheral API. Since
13071307
CMSIS is an ARM standard, and since CMSIS headers are supplied by the MCU
13081308
vendor, 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
13111311
In this section, we will replace our API functions in the `mcu.h` by the
13121312
CMSIS vendor header, and leave the rest of the firmware intact.

0 commit comments

Comments
 (0)