How to write header files for devices

I am new to Embedded Programming, taking courses on it. And work with ATSTK600.

I need help on how to write header files for devices. Well, to be specific, what standard should be followed when writing header files, such as naming a register, etc. (How to create .h and include what I know).

I recently received a job to create a header file, which I did, was on the right path, and some errors were fixed before resubmitting. Defining USART (made a mistake, as this is very new to me)

#define USART_RX $0032[that professor said that it would not work correctly because of $ sign #define]. Is the following definition correct?

#define USART0_RX  32
#define USART0_UDRE  34
#define USART0_TX  36

Another thing is that I defined the ports as follows: is this the correct naming convention?

#define I_PINS_PORTA  0x20
#define DD_PORTA  0x21
#define DATA_PORTA  0x22

, - #define BASE_ADDR_PORTA 0x20, DD_PORTA I_PINS_PORTA?

.

P.S. AM, C .

+3
2

, , , UART, PORTA, - . .

#define DD_PORTA 0x21

#define PORTA_DD 0x21

, , . :

#define PORTA_BASE 0x20

#define PORT_I       0x00
#define PORT_DD      0x01
#define PORT_DATA    0x02

#define PORTA_I     (PORTA_BASE + PORT_I)
#define PORTA_DD    (PORTA_BASE + PORT_DD)
#define PORTA_DATA  (PORTA_BASE + PORT_DATA)

, .

, , .

- , . , ( ) 0. , , 2, 4 8 ( , ). , ( , ).

+2
0

Source: https://habr.com/ru/post/1770213/


All Articles