gsrunion 0 Posted February 23, 2013 Share Posted February 23, 2013 Unlike the many of TI's other chips the C2000 series does not come with a peripheral driver library of any sort. What is provided by TI is the "C/C++ Header files and Peripheral examples" which is a relatively weak set examples covering a pretty small set of the use cases of the chips peripherals. Having personally developed driver abstractions for the I2C, SPI, CAN, and XINTF on the TMS320F28335 I have been frustrated with the sheer amount of tedium and attention to detail required to work with the peripherals on the C2000 devices. Since there seems to be no driver library coming from TI in the near future, I am gauging interest starting a repository, maybe it could be hosted on C2KCentral, where us working with the C2000 can work together to build our own driver library for the chip. If there enough interest and enough people would be willing to contribute, whether it be with chip knowledge, code contribution, or code review, I would upload what code I have for these peripherals (with permission from my management of course) and this could serve as a starting point. This is not a project I am wanting to undertake alone or that I have huge amounts of time to contribute to. But with a little help from everyone here and there it could turn into something great. Any input would be appreciated. Quote Link to post Share on other sites
msptest6 0 Posted February 25, 2013 Share Posted February 25, 2013 I'd be happy to host it. This site needs a jumpstart anyway.. which I'm finding very hard to do. Let me know or PM me for help. Quote Link to post Share on other sites
gsrunion 0 Posted February 26, 2013 Author Share Posted February 26, 2013 Cool. I will contact you when I get my first chunk of content. Quote Link to post Share on other sites
Anguel 0 Posted February 26, 2013 Share Posted February 26, 2013 gsrunion, This is a very good idea. I am new to TI and the C2000 but I am already very disappointed. It is a joke that a big company like them is not able to provide working drivers and good docs for a MCU they advertise so extensively. Instead, they leave all the hard work to each single developer. I am now trying to dig into the docs and if I have more experience in the future, I will try to contribute to this project. Best regards, Anguel Quote Link to post Share on other sites
gsrunion 0 Posted March 1, 2013 Author Share Posted March 1, 2013 There are plenty of docs. However the examples are minimal. The good thing is that, I believe, TI uses the same IP for the peripherals on the C2000 chips. So you write a driver for one it pretty much ports. I am aiming for device independent drivers. For a proof of concept I wanted to start with the easiest peripheral I could think of..... serial... Here is what I have so far. I am going to do considerable beautifying and generalizing. #include "DSP28x_Project.h" class ScopedEAllow { public: ScopedEAllow() { EALLOW; } ~ScopedEAllow(){ EDIS; } }; void boilerPlate() { DisableDog(); IntOsc1Sel(); InitPll(DSP28_PLLCR,DSP28_DIVSEL); { ScopedEAllow e; SysCtrlRegs.LOSPCP.all = 0x0002; SysCtrlRegs.XCLK.bit.XCLKOUTDIV=2; } // Disable and clear all CPU interrupts: DINT; IER = 0x0000; IFR = 0x0000; } class SCIDevice { private: volatile struct SCI_REGS* const REGS; public: enum { SCIA, SCIB }; SCIDevice(volatile struct SCI_REGS* const regs, int device, int txPin, int rxPin) : REGS(regs) { ScopedEAllow e; EnableClock(device); SetPins(txPin, rxPin); EnableHardwareFifo(); // sci loopback init REGS->SCICCR.all =0x0007; // 1 stop bit, No loopback // No parity,8 char bits, // async mode, idle-line protocol REGS->SCICTL1.all =0x0003; // enable TX, RX, internal SCICLK, // Disable RX ERR, SLEEP, TXWAKE REGS->SCICTL2.all =0x0003; REGS->SCICTL2.bit.TXINTENA =1; REGS->SCICTL2.bit.RXBKINTENA =1; REGS->SCIHBAUD =0x0000; REGS->SCILBAUD =0x000F; REGS->SCICCR.bit.LOOPBKENA =1; // Enable loop back REGS->SCICTL1.all =0x0023; // Relinquish SCI from Reset } char SendChar(char c) { REGS->SCITXBUF = c; return c & 0xFF; } char WaitForChar() { while(REGS->SCIFFRX.bit.RXFFST !=1) { } return REGS->SCIRXBUF.all & 0xFF; } private: void EnableHardwareFifo() { REGS->SCIFFTX.all=0xE040; REGS->SCIFFRX.all=0x2044; REGS->SCIFFCT.all=0x0; } void EnableClock(int device) { switch(device) { case SCIA: SysCtrlRegs.PCLKCR0.bit.SCIAENCLK = 1; // SCI-A break; case SCIB: SysCtrlRegs.PCLKCR0.bit.SCIBENCLK = 1; // SCI-A default: } } void SetPins(int txPin, int rxPin) { switch(txPin) { case 29: GpioCtrlRegs.GPAPUD.bit.GPIO29 = 0; // Enable pull-up for GPIO29 (SCITXDA) GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 1; // Configure GPIO29 for SCITXDA operation break; case 12: GpioCtrlRegs.GPAPUD.bit.GPIO12 = 0; // Enable pull-up for GPIO12 (SCITXDA) GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 2; // Configure GPIO12 for SCITXDA operation break; default: break; }; switch(rxPin) { case 28: GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0; // Enable pull-up for GPIO28 (SCIRXDA) GpioCtrlRegs.GPAQSEL2.bit.GPIO28 = 3; // Asynch input GPIO28 (SCIRXDA) GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 1; // Configure GPIO28 for SCIRXDA operation break; case 7: GpioCtrlRegs.GPAPUD.bit.GPIO7 = 0; // Enable pull-up for GPIO7 (SCIRXDA) GpioCtrlRegs.GPAQSEL1.bit.GPIO7 = 3; // Asynch input GPIO7 (SCIRXDA) GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 2; // Configure GPIO7 for SCIRXDA operation break; default: break; }; } }; int main(void) { boilerPlate(); SCIDevice sci(&SciaRegs, SCIDevice::SCIA, 29, 28); Uint16 loopCount = 0; Uint16 errorCount = 0; char sendChar = 0; for(; { if(sci.WaitForChar() != sci.SendChar(sendChar++)) { errorCount++; } loopCount++; } } I started with the sci loopback example for the 28069. Quote Link to post Share on other sites
gsrunion 0 Posted March 1, 2013 Author Share Posted March 1, 2013 I also plan on providing C wrappers for those that dont use C++. Quote Link to post Share on other sites
gsrunion 0 Posted March 3, 2013 Author Share Posted March 3, 2013 So now that I have dug a little more into the Piccolo it looks like there is the beginnings of a StellarisWare style driver library. I am surprise this has not been ported by TI to the other C2000 chips as the peripherals probably operate the same way just with registers in different chunks of memory. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.