Jump to content


  • Content Count

  • Joined

  • Last visited

  1. You can use the __byte((int*)bufer, N) compiler "intrinsic" to access the Nth byte of a given buffer. That could make retrieval easier. However I don't think it would save any space when creating the array of chars because the litteral in __byte((int*)buffer, N) = 'a'; is probably still going to be stored in a 16 bit char. You could still build the array by doing hex and then grabbing the Nth char with the __byte((int*)buffer, N) intrinsic. As far as building the hex litterals for the array some excel or python magic could help.
  2. 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.
  3. I also plan on providing C wrappers for those that dont use C++.
  4. 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.
  5. Cool. I will contact you when I get my first chunk of content.
  6. 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.
  • Create New...