Illustrating machine storage classes
This recipe illustrates a version of addTwoNums
that uses the machine storage classes, int32_t
and uint8_t
. We explain why it is advantageous for embedded applications to define and use these as opposed to the primitive types that are provided by the C language.
How to do it…
To define and use machine storage classes, please follow the outlined steps:
- Create a new folder named
addTwoNums_v2
by cloning the previous project. - Copy the
addTwoNums.c
file from the previous recipe to the folder and modify it as follows:int main (void) { int32_t input; uint8_t num1, num2, res; HAL_Init (); /* Init Hardware Abstraction Layer */ SystemClock_Config (); /* Config Clocks */ SER_Init(); for (;;) { /* Loop forever */ printf("Enter ...
Get ARM® Cortex® M4 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.