KM3NeT CLB
2.0
KM3NeT CLB v2 Embedded Software
|
First define a short name for your device.
For example, using a fictional transporter, we can use the name transp
Then follow these steps:
struct
representing the device registers. This should be done in a file named dev_<dev_name>.h
in the platform/lm32soc
directory, or the transporter this would be dev_transp.h
. This structure should be named <DEV_NAME>_Device. Declare all important defines and the device structure. For this special types have been defined named reg_i, reg_o and reg_io, depending on whether its read-only, write-only or read/write respectively. Also all important register bits and such must be defined here as macros. All macro's should be prefixed by the capital short name and register name. Bits are defined simply like this: #define TRANSP_CMD_RESET BIT(2)
defines the reset bit (no. 2) in the CMD register of our fictional transporter device. Ranges must have a shift and a mask: #define TRANSP_CFG_TXPOWER_MASK 0xFF00
and #define TRANSP_CFG_TXPOWER_SIHFT 16
. Below follows a complete example: This concludes the adding of a wishbone device. The next step would be to create an actual driver. Currently this tutorial does not exist yet. Please refer to the source code of other drivers located at platform/drv/
for examples.