Jump to content
43oh

Who would be interested/contribute in an open source C2000 repository.


Recommended Posts

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.

 

Link to post
Share on other sites

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

Link to post
Share on other sites

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.

Link to post
Share on other sites

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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...