Home » Archived » DSDP - Real-Time Software Components (RTSC) » IPeripheral and driver development(How to use metaonly peripheral info in target driver)
IPeripheral and driver development [message #1725688] |
Sun, 06 March 2016 15:43  |
Eclipse User |
|
|
|
I am currently creating generic peripheral drivers (UART, SPI, I2C, etc.) similar to TI-RTOS drivers but implemented using a proxy/delegate scheme like is done for the SYS/BIOS HAL. I would like to keep the device specific register address and structure information out of the driver itself and instead reference this information through a device specific peripheral module. I've seen https://wiki.eclipse.org/DSDP/RTSC_-_xdc.platform.ICpuDataSheet which looks promising. After looking through existing implementations of IPeripheral from TI I'm left confused since all modules inheriting IPeripheral are metaonly.
How can I spec registers and enumeration in IPeripheral modules and use them in the target code? My initial thought is this is not possible. Looking at the ti.sysbios.family.arm.lm4.Timer implementation and I see ti_catalog_arm_peripherals_timers_TimerRegsM4 all over the code. This structure is defined in a header file that is not generated by RTSC but is "contained" in the ti.catalog.arm.peripherals.timers package. Looking at MSP430 implementation is even more confusing since all the registers are defined in the modules but don't appear to be used anywhere. Have I missed the point of IPeripheral?
|
|
|
Re: IPeripheral and driver development [message #1725818 is a reply to message #1725688] |
Mon, 07 March 2016 16:37   |
Eclipse User |
|
|
|
Chris,
IPeripheral interface was created to be a configuration-time representation for device peripherals, and it was initially used only in Grace (http://processors.wiki.ti.com/index.php/Grace_Quick_Start_Guide). That's where you would find references to the registers and their fields defined in IPeripheral modules that you were looking for in the SYS/BIOS code. Using IPeripheral interface, devices declare available peripherals and then any module at the config time could generate appropriate runtime code based on the types of these peripherals. The generated code would directly write into the registers declared by an IPeripheral rather than invoking any API exposed by that IPeripheral. In fact, none of the modules that implement that interface have the runtime presence.
For example, SYS/BIOS code in ti/sysbios/family/msp430/Timer.xs only uses ITimer interface to find out which timers are on device, and then the values for direct writes to registers are generated.
I don't think that's the usage you intend for your drivers, so your drivers wouldn't gain much by inheriting from IPeripheral.
Now, I haven't spent much time thinking of what would be a good way to implement peripherals using a proxy/delegate scheme. I would definitely start from the existing ITimer interface in ti.sysbios.interfaces and its implementation in ti.sysbios.hal, and then work from there. If you do that, you'll probably have more specific questions, so please feel free to continue this thread.
|
|
| |
Re: IPeripheral and driver development [message #1726257 is a reply to message #1726008] |
Thu, 10 March 2016 13:50   |
Eclipse User |
|
|
|
But, why do you want to expose registers in XDCspec files? In IPeripheral, the purpose is for other modules to generate C code with direct register reads and writes so the registers and their bits must be known at the config time. It seems that you are creating a generic API for accessing UART, similar to what TI-RTOS does, and the registers are not exposed in the generic header files for peripherals. Are you planning to let users directly configure initial values of some registers at the config time? That would be a good reason to expose registers, but that doesn't fit with the overall architecture where you have generic drivers, and that's what users access.
If you are using registers only internally in device-specific runtime code, then you have a couple of options. You could create internal config parameters that would get its values from an IPeripheral and then you would have these values accessible at runtime, without a need to hardcode these values in your XDCspec file. You could also do what TI-RTOS does, and get the register addresses from the appropriate driverlib products, from the header files and then XDCspec files are not even involved and they don't need to be. If there is no driverlib, and no IPeripherals for your device, then you can have these values hardcoded in your C sources, and there is no duplication.
|
|
|
Re: IPeripheral and driver development [message #1726453 is a reply to message #1726257] |
Mon, 14 March 2016 00:07   |
Eclipse User |
|
|
|
Sasha,
The registers would only be used by the driver code itself and not accessible to the user config. The idea is to have a consistent location to put device specific information. In general, a given driver may not be appropriate in all applications. For example, enabling an MMU may require a completely different driver. Knowing that drivers are not "one size fit all" it would be nice to provide a common peripheral module that could be reused by multiple drivers. The current IPeripheral interface can only accomplish this for template generated drivers. Even Grace doesn't generate the drivers themselves only the initialization routines.
Take for example ti.catalog.msp430.peripherals.adc.ADC10. If we ignore the config/instance parameters and assume this module was not metaonly, then this would allow anyone developing an ADC10 driver for the MSP430 to use this module and have all the register structures and enumerations available to them. At that point they could choose to generate a driver with a template as Grace does, hand-code the driver, etc. As you can see I care about more than the register values and addresses (I'm using standard RTSC solutions for that). I don't have a way with IPeripheral to, for example, write ADC10CTL0.SREF = SREF_3 without redefining these structures/enums in my own module or handcrafted header file.
If we drop the metaonly then wouldn't the existing IPeripheral modules generate header files that nobody would care about? Would there be any other implications or downsides to this? Perhaps we need an IPeripheral2 if IPeripheral can't support hand-coded drivers?
Most likely I'll create my header-only peripheral modules in the appropriate catalog package and not inherit from IPeripheral for now. It would be nice if we could support template generated and hand-coded drivers with a single interface module.
Thank you,
Chris
|
|
|
Re: IPeripheral and driver development [message #1726598 is a reply to message #1726453] |
Mon, 14 March 2016 19:40   |
Eclipse User |
|
|
|
Chris,
I understand now why you wanted to extend IPeripheral, and make it a runtime. The main concern with changing IPeripheral to a runtime interface would be compatibility with modules built with earlier versions of XDCtools. I would expect that going from metaonly to runtime is much less disruptive than the other way around, but I would have to check that first. It shouldn't be too much work and here is the enhancement request that I filed, and you can add your email to track progress - https://bugs.eclipse.org/bugs/show_bug.cgi?id=489605. Unfortunately, I can't promise any immediate XDCtools release with that change, so you are probably better off to start with your own hierarchy.
The biggest obstacle for me to spend much time on that problem is that the TI-RTOS team turned to various driverlib products to acquire register addresses and enums. That makes it unlikely that we will have RTSC packages that cover all the device families that SYS/BIOS and TI-RTOS support, and there are always new families and devices added to these products. Therefore, much less attention is paid to IPeripheral modules, except that they must not break anything.
|
|
| | | |
Re: IPeripheral and driver development [message #1727541 is a reply to message #1725688] |
Wed, 23 March 2016 11:41  |
Eclipse User |
|
|
|
Chris,
You don't even need to upcast anything.
Say for example, you have a command console module that uses a UART to send/receive. You want your command console to operate with any device, and not worry about which specific driver actually gets linked in, making the command console module useable for any device.
In your command console's .xdc file you would import the IUart, and then in your Module_State (or Instance_State if you really needed multiple consoles), you declare a variable as:
struct Module_State {
...whatever vars you need to declare...
IUart.Handle handle_IUart;
};
you would, of course also have a config variable such as
config IUart.Handle handle_IUart = null;
When using it in your command console code, simply use something like:
#include <package/name/containing/interfaces/IUart>
....
numberOfCharsReceived = IUart_read( module->handle_IUart, &buffer, ....);
In your configuration script, you don't need to do anything special either. It would look something like:
Uart = xdc.useModule('someSpecific.chip.drivers.Uart');
CommandConsole_UartParams = new Uart.Params();
CommandConsole_UartParams.baudRate = 19200;
.....
CommandConsole_Uart = Uart.create(CommandConsole_UartParams);
CommandConsole = xdc.useModule('my.package.with.CommandConsole');
CommandConsole.handle_IUart = CommandConsole_Uart;
|
|
|
Goto Forum:
Current Time: Thu May 15 15:15:55 EDT 2025
Powered by FUDForum. Page generated in 0.10163 seconds
|