Hi Matias, > I thought about doing this for a long time
Yes So many times...Thank you for doing it! David -----Original Message----- From: Matias N. [mailto:mat...@imap.cc] Sent: Friday, July 03, 2020 1:45 PM To: dev@nuttx.apache.org Subject: SVD -> header generator Hi, I thought about doing this for a long time and I just did it, wasn't really hard. If you're not aware, CMSIS-SVD file format is an XML based definitions of peripherals and registers available in a given MCU. This is typically used for debugging but it is quite useful for generating header definitions. I wrote a quick python script that is able to generate register definitions and base addresses of peripherals. It is based on https://github.com/posborne/cmsis-svd which includes both the SVD python parser and a really complete database of SVD files. The tool is available here: https://gitlab.com/nuttx_projects/svdgen (be sure to check the README on how to use) Example output (the console output properly tabulates data, format may look broken in the email): Generate memory map: $ ./gen.py -v Nordic -d nrf51 -p map -x NRF51 #define NRF51_POWER_BASE 0x40000000 /* Power Control.*/ #define NRF51_CLOCK_BASE 0x40000000 /* Clock control.*/ #define NRF51_MPU_BASE 0x40000000 /* Memory Protection Unit.*/ #define NRF51_AMLI_BASE 0x40000000 /* AHB Multi-Layer Interface.*/ ... etc Register definitions: $ ./gen.py -v Nordic -d nrf51 -p RADIO -x NRF51 /* Register offsets *********************************************************/ #define NRF51_RADIO_TASKS_TXEN_OFFSET 0x000000 /* Enable radio in TX mode.*/ #define NRF51_RADIO_TASKS_RXEN_OFFSET 0x000004 /* Enable radio in RX mode.*/ #define NRF51_RADIO_TASKS_START_OFFSET 0x000008 /* Start radio.*/ #define NRF51_RADIO_TASKS_STOP_OFFSET 0x00000c /* Stop radio.*/ #define NRF51_RADIO_TASKS_DISABLE_OFFSET 0x000010 /* Disable radio.*/ ... etc /* Register definitions *****************************************************/ #define NRF51_RADIO_TASKS_TXEN (NRF51_RADIO_BASE + NRF51_RADIO_TASKS_TXEN_OFFSET) #define NRF51_RADIO_TASKS_RXEN (NRF51_RADIO_BASE + NRF51_RADIO_TASKS_RXEN_OFFSET) #define NRF51_RADIO_TASKS_START (NRF51_RADIO_BASE + NRF51_RADIO_TASKS_START_OFFSET) #define NRF51_RADIO_TASKS_STOP (NRF51_RADIO_BASE + NRF51_RADIO_TASKS_STOP_OFFSET) #define NRF51_RADIO_TASKS_DISABLE (NRF51_RADIO_BASE + NRF51_RADIO_TASKS_DISABLE_OFFSET) #define NRF51_RADIO_TASKS_RSSISTART (NRF51_RADIO_BASE + NRF51_RADIO_TASKS_RSSISTART_OFFSET) #define NRF51_RADIO_TASKS_RSSISTOP (NRF51_RADIO_BASE + NRF51_RADIO_TASKS_RSSISTOP_OFFSET) ... etc Best, Matias