原创 使用Freescale 56F8346 数字信号控制器(DSC)的SPI控制LED显示(4)

2012-10-20 12:00 1633 21 21 分类: 处理器与DSP
LED.c代码如下:

 

#include "LED.h"

 

 

#define MOTORSPEED 5

 

/*此函数将采集的量,比如电机转速Value,转化成LED对应的某个字符,每一位的字符存储在一个字符数组

  返回该字符数组的指针

  Value - actual value..etc,1265rpm

  pParamLED - stroe the charactor's offset address

  paramID - for identify the param which it present. etc.MOTORSPEED present the value is motor

            speed.

*/

 

unsigned int* transValueLed(unsigned int value,unsigned int *pParamLED,unsigned int paramID1,unsigned int paramID2)

{

  unsigned int temp;

 

  *pParamLED = paramID1;     //F

  *(pParamLED+1) = paramID2; //n

  *(pParamLED+2) = value/1000;

  temp = value%1000;

  *(pParamLED+3) = temp/100;

  temp = temp%100;

  *(pParamLED+4) = temp/10;

  temp = temp%10;

  *(pParamLED+5) = temp/1;

  temp = temp%1;

 

  return pParamLED;

}

 

/*此函数将对应要发送的字符的地址指针对应的字符存入一个数组

  pSend - pointer to arrary that save the value of charactor that to be send

  pParamBit - 指向相应参数的指针数组.

  pParamLED - 指向LED字符便宜量的指针.

  此函数替代以下这段代码

  for(i=0;i

    {

        *(CharSend+i) = *(OEGA_ACT+i)+*(CharOrNumOffset+i);

    //SM1_SendChar(*(*(CharSend+i)));

    }

*/

void valuePointedChar(byte **pSend,byte **pParamBit,unsigned int *pParamLED)

{

    unsigned int i,temp;

  temp = 6;//sizeof(pParamBit)/2;//不能用sizeof,因为sizeof(pParamBit)始终为0.

  for(i=0;i

  {

    *(pSend+i) = *(pParamBit+i)+*(pParamLED+i);

  }

//   return pSend;

}

文章评论0条评论)

登录后参与讨论
我要评论
0
21
关闭 站长推荐上一条 /2 下一条