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

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

?? lcd.c

?? reference about wireless design which is helpful to everyone
?? 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一区二区三区免费野_久草精品视频
久久99日本精品| 91精品蜜臀在线一区尤物| 欧美日韩精品免费| 久久精品人人做人人爽人人| 亚洲成人av一区二区| 99久久99久久精品免费看蜜桃 | 亚洲午夜一二三区视频| 国产麻豆精品theporn| 91精品国产高清一区二区三区| 1024国产精品| 国产精品亚洲综合一区在线观看| 欧美天堂一区二区三区| 亚洲情趣在线观看| 成人av在线播放网址| 欧美tk—视频vk| 免费人成在线不卡| 4hu四虎永久在线影院成人| 一片黄亚洲嫩模| 色偷偷成人一区二区三区91| 国产女同互慰高潮91漫画| 久久精品噜噜噜成人88aⅴ| 欧美日韩精品一区二区三区蜜桃| 一区二区在线观看不卡| av在线一区二区| 亚洲视频电影在线| 91啪九色porn原创视频在线观看| 中文字幕电影一区| 成人精品国产福利| 中文字幕在线一区免费| 99视频热这里只有精品免费| 欧美激情中文不卡| av午夜一区麻豆| 亚洲激情av在线| 一本久道中文字幕精品亚洲嫩| 国产精品国产三级国产普通话三级 | 国产白丝精品91爽爽久久| 精品国产免费视频| 国产大片一区二区| 国产精品久99| 在线观看亚洲a| 亚洲3atv精品一区二区三区| 欧美精品xxxxbbbb| 麻豆国产精品官网| 久久久精品tv| 色综合天天狠狠| 亚洲成a人v欧美综合天堂| 欧美妇女性影城| 久久99久久99小草精品免视看| 欧美大片免费久久精品三p| 国产精品一区二区免费不卡 | 国产精品一区二区久激情瑜伽| 欧美激情在线一区二区三区| 91色porny在线视频| 亚洲成a人片在线观看中文| 欧美一卡在线观看| 国产高清视频一区| 一区二区三区四区在线免费观看| 91精品国产手机| 国产精品一级二级三级| 日韩理论片中文av| 欧美精品自拍偷拍| 国产乱人伦精品一区二区在线观看| 欧美极品少妇xxxxⅹ高跟鞋 | 欧美日韩亚洲国产综合| 青娱乐精品在线视频| 国产人成亚洲第一网站在线播放| 91免费看`日韩一区二区| 麻豆成人综合网| 亚洲人吸女人奶水| 精品成人在线观看| 欧洲精品视频在线观看| 精品中文字幕一区二区| 一区二区三区四区乱视频| 精品欧美黑人一区二区三区| 9人人澡人人爽人人精品| 美女在线观看视频一区二区| 国产精品久久久久aaaa樱花| 日韩一区二区免费视频| 91色视频在线| 国产精品一级黄| 秋霞影院一区二区| 又紧又大又爽精品一区二区| 久久久久久久久伊人| 欧美日本免费一区二区三区| 97se亚洲国产综合自在线观| 久久99精品国产.久久久久久| 一个色在线综合| 国产精品国产a级| 久久无码av三级| 欧美丰满高潮xxxx喷水动漫 | 国产成人av福利| 另类欧美日韩国产在线| 夜夜亚洲天天久久| 中文字幕在线一区| 国产欧美日韩中文久久| 精品国产免费人成在线观看| 666欧美在线视频| 欧美日韩激情一区二区| 欧美影片第一页| 欧美日韩日日夜夜| 日韩精品免费视频人成| 日韩精品一区二区三区swag| 91精品视频网| 欧美日韩大陆一区二区| 欧美性猛交xxxx乱大交退制版| 99在线精品免费| 99国产精品99久久久久久| 国产综合久久久久久鬼色| 另类综合日韩欧美亚洲| 蓝色福利精品导航| 青椒成人免费视频| 老司机精品视频导航| 免费观看在线色综合| 欧美国产乱子伦| 国产精品久久久久四虎| 亚洲人成伊人成综合网小说| 中文字幕一区二区三区四区| 国产欧美日韩三级| 国产精品日韩成人| 亚洲视频每日更新| 亚洲黄色录像片| 亚洲国产成人porn| 日韩精品国产精品| 久久成人免费网| 国产宾馆实践打屁股91| 99久久精品免费观看| 在线观看成人小视频| 欧美丰满少妇xxxbbb| 日韩女优视频免费观看| 国产欧美精品国产国产专区| 亚洲欧洲成人精品av97| 亚洲成人精品影院| 美国十次了思思久久精品导航| 国产精品羞羞答答xxdd| 91在线观看污| 6080国产精品一区二区| 国产三级三级三级精品8ⅰ区| 国产精品对白交换视频| 亚洲二区视频在线| 国产一区免费电影| 色一区在线观看| 日韩欧美亚洲一区二区| 国产午夜精品理论片a级大结局| 国产精品伦一区二区三级视频| 一区二区三区国产精品| 免费在线视频一区| 99r精品视频| 日韩美女一区二区三区四区| 国产精品久久久久久久久免费相片 | 中文字幕亚洲不卡| 日日摸夜夜添夜夜添国产精品 | 蜜臀av在线播放一区二区三区| 国产激情一区二区三区桃花岛亚洲| 一本色道久久综合亚洲aⅴ蜜桃| 欧美一区中文字幕| 亚洲日本欧美天堂| 久草中文综合在线| 91玉足脚交白嫩脚丫在线播放| 精品国产一区二区亚洲人成毛片| 国产欧美日韩视频在线观看| 视频一区在线播放| 日本韩国精品在线| 久久一日本道色综合| 偷拍亚洲欧洲综合| 色欧美乱欧美15图片| 久久久噜噜噜久久中文字幕色伊伊 | 国内外成人在线| 在线免费精品视频| 国产精品拍天天在线| 蜜桃久久av一区| 欧美日韩激情一区二区三区| 亚洲少妇最新在线视频| 国产乱子轮精品视频| 91精品国产麻豆国产自产在线| 亚洲色图20p| 不卡一区中文字幕| 久久青草欧美一区二区三区| 日本女优在线视频一区二区| 91老师国产黑色丝袜在线| 日本一区二区三区dvd视频在线 | 三级在线观看一区二区| 色婷婷久久一区二区三区麻豆| 国产日韩欧美不卡| 国产精品综合二区| 精品国产a毛片| 九九国产精品视频| 欧美xfplay| 久久成人久久爱| 欧美电视剧免费观看| 麻豆精品久久精品色综合| 51精品国自产在线| 午夜精品久久久久久久99樱桃| 在线亚洲欧美专区二区| 一区二区激情视频| 欧美在线观看一区| 亚洲尤物在线视频观看| 欧美无人高清视频在线观看| 亚洲sss视频在线视频| 欧美电影在哪看比较好| 石原莉奈一区二区三区在线观看|