You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: Shahzeb I. <sh...@gm...> - 2007-08-11 04:59:43
|
Hi, I was thinking over how registers should be defined in the library. Regular registers can be define simply as: #define LPC_CAN_AFMR_REG (*(volatile DWORD *)0xE003C000) But a lot of LPC peripherals have multiple modules, like UART, I2C, Timer etc. For registers like these, I normally define structures. A library function can then declare a pointer to the strcuture and assign the proper address to it based on which module is being accessed, examples are given below for FIO and UART registers. One advantage of this approach is the re-usability of library functions in such situations. These examples are taken from a HAL I've previously implemented, hence the use of "DWORD" instead of "uint32_t". Suggestions? Comments? ------------------------------------------------------------------------------------------- typedef volatile struct { DWORD regIODIR; // FIO pin direction control register (base address + 0x00) DWORD dwUnused1; // Unused address... DWORD dwUnused2; // Unused address... DWORD dwUnused3; // Unused address... DWORD regIOMASK; // FIO pin mask register (base address + 0x10) DWORD regIOPIN; // FIO pin value register (base address + 0x14) DWORD regIOSET; // FPIO pin set register (base address + 0x18) DWORD regIOCLR; // FIO pin set register (base address + 0x1C) } tsLPC_FIO_REG; ------------------------------------------------------------------------------------------- typedef volatile struct { union tuLPC_REG_UART_MUX_0 { DWORD regRBR; // UART receive buffer register (base address + 0x00), read only access (DLAB = 0) DWORD regTHR; // UART transmit holding register (base address + 0x00), write only access (DLAB = 0) DWORD regDLL; // UART divisor latch LSB register (base address + 0x00), read/write access (DLAB = 1) } uMux0; union tuLPC_REG_UART_MUX_1 { DWORD regDLM; // UART divisor latch MSB register (base address + 0x04), read/write access (DLAB = 1) DWORD regIER; // UART interrupt enable register (base address + 0x04), read/write access (DLAB = 0) } uMux1; union tuLPC_REG_UART_MUX_2 { DWORD regIIR; // UART interrupt identification register (base address + 0x08), read only access DWORD regFCR; // UART FIFO control register (base address + 0x08), write only access } uMux2; DWORD regLCR; // UART line control register (base address + 0x0C) DWORD regMCR; // UART modem control register (base address + 0x10) DWORD regLSR; // UART line status register (base address + 0x14) DWORD regMSR; // UART modem status register (base address + 0x18) DWORD regSCR; // UART scratch pad register (base address + 0x1C) DWORD regACR; // UART auto-baud control register (base address + 0x20) DWORD dwUnused1; // Unused address... DWORD regFDR; // UART fractional divider register (base address + 0x28) DWORD dwUnused2; // Unused address... DWORD regTER; // UART TX enable register } tsLPC_UART_REG; ------------------------------------------------------------------------------------------- -- "Keep me away from the wisdom which does not cry, the philosophy which does not laugh and the greatness which does not bow before children." ---Khalil Gibran |
From: Shahzeb I. <sh...@gm...> - 2007-08-09 09:41:00
|
This a test message, please reply if you receive this message, you'll have to subscribe using your original email address if you wish to post on the list. I initially subscribed all members using their sourceforge forwarding addresses. -- "Keep me away from the wisdom which does not cry, the philosophy which does not laugh and the greatness which does not bow before children." ---Khalil Gibran |