亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? lcd.c

?? ti-Chipcon CC251x 2.4G Soc應用開發源碼實例。包括rf,powermodes,clockmodes,flashRW,interrupts,timer,pwm,uart...所有
?? C
字號:
/******************************************************************************
*                                                                             *
*        **********                                                           *
*       ************                                                          *
*      ***        ***                                                         *
*     ***    ++    ***                                                        *
*     ***   +  +   ***                      CHIPCON                           *
*     ***   +                                                                 *
*     ***   +  +   ***                                                        *
*     ***    ++    ***                                                        *
*      ***        ***                                                         *
*       ************                                                          *
*        **********                                                           *
*                                                                             *
*******************************************************************************

Filename:     lcd.c
Target:       cc2510
Author:       KJA
Revised:      20/6-2006
Revision:     1.0

Description:
Function implementations for common LCD functions for use with the SmartRF04EB.

******************************************************************************/

#include "lcd.h"
#include "RF04EB.h"
#include "hal.h"

// SM-Bus address of the LCD controller
#define LCD_ADDR        0x76

// RS selects the register to be accessed for read and write
// RS = 0 => selects instruction register for write and busy flag
// RS = 1 => selects the data register for both read and write
#define RS_0            0x00
#define RS_1            0x40

#define CHAR1_ADDRESS   0x08

// protos
BYTE lcdConvertChar(BYTE c);
void smbSend( BYTE *buffer, const UINT8 n );
BOOL smbSendByte( BYTE b );
void smbReceive( BYTE address, int length, BYTE *buffer );
BYTE smbReceiveByte( BOOL lastByte );
void smbStart( void );
void smbStop( void );
void smbWrite( BOOL value );
void smbClock( BOOL value );
void waitLCD( void );

#define DATA_HIGH()    do{IO_DIR_PORT_PIN(1, 2, IO_IN); } while(0)
#define DATA_LOW()     do{IO_DIR_PORT_PIN(1, 2, IO_OUT); LCD_SDA = 0; }while(0)



/******************************************************************************
* See lcd.h for a description of this function.
******************************************************************************/
void initNewSymbol(char* symbol, BYTE address){
   BYTE sendBuffer[10];

   //send control data
   sendBuffer[0] = LCD_ADDR;
   sendBuffer[1] = RS_0;

   if (address < 0x40)
      sendBuffer[2] = 0x80;
   else
      sendBuffer[2] = 0xC0;

   sendBuffer[3] = 0x40 | (address & 0x3F);
   smbSend(sendBuffer, 4);

   //send data
   sendBuffer[0] = LCD_ADDR;
   sendBuffer[1] = RS_1;

   sendBuffer[2] = symbol[0];
   sendBuffer[3] = symbol[1];
   sendBuffer[4] = symbol[2];
   sendBuffer[5] = symbol[3];
   sendBuffer[6] = symbol[4];
   sendBuffer[7] = symbol[5];
   sendBuffer[8] = symbol[6];
   sendBuffer[9] = symbol[7];

   smbSend(sendBuffer, 10);
}


/******************************************************************************
* See lcd.h for a description of this function.
******************************************************************************/
void initLcd(void){
   BYTE sendBuffer[8];

   // Setting the ports as inputs.
   IO_DIR_PORT_PIN(1, 2, IO_IN);
   IO_DIR_PORT_PIN(2, 0, IO_IN);

   // Setting P2_3 and P2_4 for general IO operation.
   IO_FUNC_PORT_PIN(1, 2, IO_FUNC_GIO);
   IO_FUNC_PORT_PIN(2, 0, IO_FUNC_GIO);

   // Setting ports for pull-up.
   IO_IMODE_PORT_PIN(1, 2, IO_IMODE_PUD);
   IO_IMODE_PORT_PIN(2, 0, IO_IMODE_PUD);
   IO_PUD_PORT(1, IO_PULLUP);
   IO_PUD_PORT(2, IO_PULLUP);

   // Setting up the lcd initialisation data.
   sendBuffer[0] = LCD_ADDR;
   sendBuffer[1] = RS_0;      // Instruction Register
   sendBuffer[2] = 0x0C;      // Display control         D =  1:      Display On
   //                                                    C =  0:      Cursor Off
   //                                                    B =  0:      Cursor character blink off
   sendBuffer[3] = 0x21;      // Function set            H =  1:      Use extended instruction set
   sendBuffer[4] = 0xA0;      // Set DDRAM address       ADD = 0x20
   sendBuffer[5] = 0x07;      // Display configuration   P =  1:      Column data right to left
   //                                                    Q =  1:      Row data, bottom to top
   sendBuffer[6] = 0x34;      // Function set            DL=  0:      4 bits
   //                                                    M =  1:      2-line by 16 display
   //                                                    SL=  0:      MUX1:18
   //                                                    H =  0:      Use basic instruction set
   sendBuffer[7] = 0x01;      // Clearing display
   smbSend(sendBuffer, 8);

   lcdUpdate((char*)"", (char*)"");  //clear display
}



/******************************************************************************
* See lcd.h for a description of this function.
******************************************************************************/
void lcdUpdate(char *pLine1, char *pLine2) {
   lcdUpdateLine(LINE1, pLine1);
   lcdUpdateLine(LINE2, pLine2);
   return;
}


/******************************************************************************
* See lcd.h for a description of this function.
******************************************************************************/
void waitVisible(BOOL visibility)
{
   UINT16 i;

   if(visibility){
      i = 100;
   }
   else{
      i = 6;
   }

   while(i--){
      halWait(10);
   }
}


/******************************************************************************
* See lcd.h for a description of this function.
******************************************************************************/
void lcdUpdateLine(UINT8 line, char *pLine) {
   BYTE sendBuffer[50];
   UINT8 i, j;
   char c;

   i = 0;
   sendBuffer[i++] = LCD_ADDR;
   sendBuffer[i++] = RS_0;
   sendBuffer[i++] = ((line == LINE1) ?  LINE1_ADDR : LINE2_ADDR);
   smbSend(sendBuffer, i);

   i = j = 0;
   sendBuffer[i++] = LCD_ADDR;
   sendBuffer[i++] = RS_1;
   while( ( (c = pLine[j]) != '\0' ) && j < LINE_SIZE ){
      sendBuffer[i++] = lcdConvertChar(c);
      j++;
   }
   for ( ;j < LINE_SIZE; j++){
      sendBuffer[i++] = lcdConvertChar(' ');
   }
   smbSend(sendBuffer, i);
}


/******************************************************************************
* See lcd.h for a description of this function.
******************************************************************************/
void lcdUpdateChar(UINT8 line, UINT8 position, char c){
   lcdUpdateSymbol(line, position, lcdConvertChar(c));
}


/******************************************************************************
* See lcd.h for a description of this function.
******************************************************************************/
void lcdUpdateSymbol(UINT8 line, UINT8 position, char c){
   BYTE sendBuffer[3];
   UINT8 i;

   if(position > LINE_SIZE){
      position = LINE_SIZE - 1;
   }

   i = 0;
   sendBuffer[i++] = LCD_ADDR;
   sendBuffer[i++] = RS_0;
   sendBuffer[i++] = ((line == LINE1) ?  LINE1_ADDR : LINE2_ADDR) + position;
   smbSend(sendBuffer, i);

   i = 0;
   sendBuffer[i++] = LCD_ADDR;
   sendBuffer[i++] = RS_1;
   sendBuffer[i++] = c;
   smbSend(sendBuffer, i);
}



/******************************************************************************
* See lcd.h for a description of this function.
******************************************************************************/
void scrollText(char *string, UINT8 length){
   UINT8 i = 0;

   while(getJoystickDirection() != CENTRED);

   do{
      lcdUpdateLine(LINE2, &string[i]);
      i++;

      if(getJoystickDirection() != CENTRED)
      {
         lcdUpdateLine(LINE2, &(string[length-17]));
         return;
      }

      halWait(100);
   } while((string[i+15] != '\0') && (i + 15) < length);
}

/******************************************************************************
* Internal function for lcd.c
******************************************************************************/
void smbSend(BYTE *buffer, const UINT8 n){
   UINT8 i = 0;

   smbStart();
   for(i = 0; i < n; i++){
      while(!smbSendByte(buffer[i])); //send until ACK received
   }
   smbStop();
}

/******************************************************************************
* Internal function for lcd.c
******************************************************************************/
BOOL smbSendByte(BYTE b){
   UINT8 i;
   BOOL ack;
   for (i = 0; i < 8; i++){
      smbWrite(b & 0x80);
      b = (b <<  1);
   }
   smbClock(0);
   DATA_HIGH();
   smbClock(1);
   ack = !LCD_SDA;
   return ack; //high = ACK received, else ACK not received
}

/******************************************************************************
* Internal function for lcd.c
* Function for writing bit to the data line. Setting the port as input
* make the SMBus go high because of the pull-up resistors.
*
******************************************************************************/
void smbWrite(BOOL value){
   smbClock(0);
   waitLCD();
   if(value){
      DATA_HIGH();
   }
   else{
      DATA_LOW();
   }
   smbClock(1);
   waitLCD();
}

/******************************************************************************
* Internal function for lcd.c
******************************************************************************/
void smbReceive(BYTE address, int length, BYTE *buffer){
   int i;

   smbStart();

   while (!smbSendByte(address)); //send address until ACK'ed

   for(i = 0; i < length; i++){
      buffer[i] = smbReceiveByte( i==(length-1) ); //TRUE if last byte
   }

   smbClock(1);
   smbWrite(0);

   smbStop();
}

/******************************************************************************
* Internal function for lcd.c
******************************************************************************/
BYTE smbReceiveByte(BOOL lastByte){
   int i;

   BYTE inData = 0;

   DATA_HIGH();

   for(i = 0; i < 8 * 2; i++){
      if(LCD_SCL == 0){ //clk low
         if(LCD_SDA){ //read '1'
            inData = (inData<<1) | 0x01;
         } else {
            inData = (inData<<1) & ~0x01;
         }
         waitLCD();
         smbClock(1);
      }
      else{
         waitLCD();
         smbClock(0);
      }
   }
   smbClock(0);

   //do not ACK if last byte
   lastByte ? smbWrite(1) :  smbWrite(0);

   smbClock(1);
   smbClock(0);

   return inData;
}


/******************************************************************************
* Internal function for lcd.c
*
* This function is used to clock the SMBus connected to the LCD. If a negative
* edge is to follow, the pin is set as an output and driven low. If a positive
* edge is to follow, the pin is set as an input and the pull-up resistor is
* to drive the node high. This way the slave device can hold the node low if
* a longer setup time is desired.
*
******************************************************************************/
void smbClock(BOOL value){
   if(!value)
   {
      IO_DIR_PORT_PIN(2, 0, IO_OUT);
      LCD_SCL = 0;
   }
   else {
      IO_DIR_PORT_PIN(2, 0, IO_IN);
   }
   waitLCD();
}

/******************************************************************************
* Internal function for lcd.c
*
* This function initiates SMBus communication. It makes sure that both the
* data and the clock of the SMBus are high. Then the data pin is set low
* while the clock is kept high. This initializes SMBus transfer.
******************************************************************************/
void smbStart(){
   while (! (LCD_SDA && LCD_SCL) ); //wait for Data and clk high
   DATA_LOW();
   waitLCD();
   smbClock(0);
}

/******************************************************************************
* Internal function for lcd.c
*
* This function terminates SMBus communication. It makes sure that the data
* and clock of the SMBus are low and high, respectively. Then the data pin is
* set high while the clock is kept high. This terminates SMBus transfer.
******************************************************************************/
void smbStop(){
   while (! (!LCD_SDA && LCD_SCL));
   smbClock(0);
   DATA_HIGH();
   waitLCD();
   smbClock(1);
}


/******************************************************************************
* Internal function for lcd.c
*
* This function does the timing of clk
******************************************************************************/
void waitLCD(){
   UINT8 i = 0x01;
   while(i--);
}
/******************************************************************************
* Internal function for lcd.c
*
*  BYTE LcdConvertChar(BYTE c)
*
*  DESCRIPTION:
*      Converts ASCII characters to the character set the LCD display uses
*      (works for all digits and letters and some other common characters)
******************************************************************************/
BYTE lcdConvertChar(BYTE c) {
   //character set R in data sheet
   if ((c >= 'a') && (c <= 'z')) //lower case
      c += ('a' - 0xE1);//0x80;
   else if ((c >= 'A') && (c <= 'Z')) //upper case
      c+= ('A' - 0xC1);
   else if ((c >= ' ') && (c <= '#') || (c >= '%') && (c <= '?'))
      c += (' ' - 0xA0);
   else{
      switch (c){
      case '$':
         c = 0x82;
         break;
      case '

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91麻豆精品国产91久久久| 午夜欧美大尺度福利影院在线看| 久久精品一区四区| 精品一区二区三区在线视频| 国产91对白在线观看九色| 欧美曰成人黄网| 国产午夜精品一区二区三区视频 | 免费成人你懂的| 91搞黄在线观看| 欧美国产乱子伦| 韩国女主播成人在线| 欧美精品xxxxbbbb| 亚洲自拍偷拍网站| 不卡高清视频专区| 精品va天堂亚洲国产| 亚洲成av人综合在线观看| 91亚洲国产成人精品一区二区三| 久久久影院官网| 毛片av一区二区三区| 欧美午夜一区二区三区免费大片| 亚洲人成网站在线| 成a人片亚洲日本久久| 国产亚洲欧美日韩俺去了| 蜜臀久久99精品久久久久久9| 欧美色老头old∨ideo| 亚洲品质自拍视频网站| 成人av电影观看| 中文字幕高清一区| 国产精品乡下勾搭老头1| 久久嫩草精品久久久精品| 国产在线播放一区| 欧美精品一区二区三区在线播放| 奇米综合一区二区三区精品视频| 欧美精品三级日韩久久| 青草国产精品久久久久久| 欧美一级二级三级乱码| 久久国产婷婷国产香蕉| 欧美国产亚洲另类动漫| 成人性生交大片免费看在线播放| 国产日韩欧美精品综合| 成熟亚洲日本毛茸茸凸凹| 国产精品女上位| 一本色道久久综合亚洲aⅴ蜜桃| 国产精品乱人伦| 色吧成人激情小说| 亚洲国产成人91porn| 91精品国产综合久久精品麻豆| 日本成人中文字幕在线视频| 日韩三级视频中文字幕| 国产成人精品免费一区二区| 亚洲天堂a在线| 欧美日本在线视频| 久99久精品视频免费观看| 国产无一区二区| 在线观看不卡一区| 午夜精品一区二区三区电影天堂| 日韩精品中文字幕一区二区三区 | 亚洲大片在线观看| 日韩视频永久免费| 成人妖精视频yjsp地址| 亚洲精品乱码久久久久久久久| 欧美高清激情brazzers| 国产一区二三区| 亚洲欧美另类久久久精品| 欧美精品在线观看一区二区| 国产精品亚洲专一区二区三区 | 久久看人人爽人人| 色播五月激情综合网| 久久99精品久久久久久久久久久久| 偷窥少妇高潮呻吟av久久免费 | 欧美无砖专区一中文字| 美国一区二区三区在线播放| 国产精品国模大尺度视频| 欧美日本不卡视频| 粉嫩久久99精品久久久久久夜| 亚洲一区二区三区国产| 久久久久国色av免费看影院| 欧美最新大片在线看| 国产成人一区在线| 日本vs亚洲vs韩国一区三区二区| 国产精品免费观看视频| 亚洲精品在线免费观看视频| 欧美系列日韩一区| www.欧美精品一二区| 久久精品国产99久久6| 亚洲精品成人天堂一二三| 国产人成亚洲第一网站在线播放| 7777精品伊人久久久大香线蕉| 成人激情小说乱人伦| 久久se这里有精品| 五月婷婷欧美视频| 亚洲婷婷综合色高清在线| 久久九九全国免费| 欧美tickle裸体挠脚心vk| 欧美三级资源在线| 日本韩国精品一区二区在线观看| 国产麻豆成人传媒免费观看| 青椒成人免费视频| 婷婷成人综合网| 亚洲成av人片一区二区梦乃| 亚洲乱码国产乱码精品精的特点 | 美女视频网站黄色亚洲| 亚洲一区在线观看视频| 亚洲欧美区自拍先锋| 国产精品二三区| 亚洲国产精品成人综合| 欧美精彩视频一区二区三区| 久久亚洲精品小早川怜子| 欧美成人午夜电影| 精品国精品国产尤物美女| 日韩欧美电影在线| 日韩欧美国产一区二区三区| 欧美一区二区福利视频| 日韩美一区二区三区| 欧美电影免费提供在线观看| 欧美一区二区三区成人| 欧美一级二级三级蜜桃| 精品日韩在线观看| 精品福利一二区| 久久久久久一二三区| 亚洲国产精品精华液ab| 国产精品传媒入口麻豆| 国产精品电影一区二区三区| 亚洲人成伊人成综合网小说| 亚洲一本大道在线| 亚洲成人www| 波多野结衣精品在线| 成人aa视频在线观看| 色婷婷久久久亚洲一区二区三区| 一本大道久久a久久精品综合| 91精品1区2区| 欧美一区二区三区免费观看视频| 欧美一级在线视频| 久久久久一区二区三区四区| 日韩一区在线看| 午夜欧美电影在线观看| 狠狠狠色丁香婷婷综合激情| 亚洲美女屁股眼交3| 美女一区二区在线观看| 国产大片一区二区| 91久久精品国产91性色tv| 欧美一区二区久久久| 国产日韩精品久久久| 亚洲综合色在线| 韩国理伦片一区二区三区在线播放 | 曰韩精品一区二区| 日本欧美一区二区| 成人一级视频在线观看| 欧美三级午夜理伦三级中视频| 精品国产一区二区精华| 中文字幕中文在线不卡住| 亚洲国产精品视频| 国产乱码精品1区2区3区| 欧美综合视频在线观看| 精品日韩在线一区| 亚洲一区二区三区自拍| 国产综合久久久久影院| 欧美综合在线视频| 日本一二三不卡| 秋霞国产午夜精品免费视频| av综合在线播放| 精品国产乱码久久久久久浪潮| 亚洲欧美自拍偷拍| 久久97超碰国产精品超碰| 色呦呦日韩精品| 国产欧美综合在线观看第十页| 国产在线不卡一卡二卡三卡四卡| 在线观看欧美日本| 欧美国产亚洲另类动漫| 久久99国产精品尤物| 欧美美女激情18p| 中文字幕五月欧美| 国产成人亚洲精品狼色在线| 精品女同一区二区| 午夜视频在线观看一区二区| 91无套直看片红桃| 国产欧美日韩精品a在线观看| 免费高清视频精品| 欧美日本韩国一区二区三区视频| 亚洲欧洲日产国码二区| 丁香婷婷综合色啪| 国产日韩欧美精品一区| 九九**精品视频免费播放| 欧美日韩aaaaaa| 午夜不卡av在线| 欧美日韩中字一区| 一区二区三区av电影| 91小宝寻花一区二区三区| 国产精品丝袜一区| 成人在线综合网站| 国产精品亲子乱子伦xxxx裸| 国产精品69久久久久水密桃| 精品国产欧美一区二区| 精品在线一区二区三区| 精品日韩成人av| 国内久久精品视频| 久久精品男人的天堂| 国产精品白丝jk黑袜喷水| 国产日韩精品一区二区三区| 从欧美一区二区三区|