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

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

?? lcd.c

?? CC2430多功能調試程序
?? C
字號:
/*****************************************************************************
Filename:     lcd.c
Target:       cc2430
Revised:      16/12-2005
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一区二区三区免费野_久草精品视频
日韩写真欧美这视频| 日韩视频一区二区在线观看| 欧美性做爰猛烈叫床潮| 日韩免费成人网| 亚洲国产综合色| 成人97人人超碰人人99| 日韩视频永久免费| 亚洲成人一二三| 色综合咪咪久久| 国产精品美日韩| 国产精品亚洲视频| 精品国产欧美一区二区| 日韩av不卡一区二区| 日本韩国欧美在线| 最近日韩中文字幕| 成人精品在线视频观看| 欧美大片免费久久精品三p| 亚洲大尺度视频在线观看| 91色porny| 亚洲欧洲日产国产综合网| 国内精品国产三级国产a久久| 欧美美女一区二区在线观看| 一区二区三区影院| 91久久精品国产91性色tv| 国产精品高清亚洲| av午夜精品一区二区三区| 国产精品网站在线| 国产成人8x视频一区二区| 26uuu精品一区二区在线观看| 日本三级亚洲精品| 日韩免费看网站| 狠狠久久亚洲欧美| 国产欧美日产一区| 成人精品在线视频观看| 亚洲欧洲成人自拍| 一本久道久久综合中文字幕| 一区二区三区在线免费| 欧美视频在线一区二区三区 | 精品视频在线免费看| ...xxx性欧美| 在线影院国内精品| 亚洲国产精品视频| 欧美一区二区观看视频| 韩国成人在线视频| 国产精品嫩草久久久久| 91女人视频在线观看| 夜夜精品视频一区二区| 欧美日韩一区高清| 麻豆高清免费国产一区| 欧美成人福利视频| 国产精品77777竹菊影视小说| 自拍偷自拍亚洲精品播放| 欧美无人高清视频在线观看| 天堂va蜜桃一区二区三区| 精品久久久久久久久久久久包黑料 | 国产一区二区三区香蕉| 国产亚洲综合在线| 91福利社在线观看| 美腿丝袜亚洲色图| 国产精品女同一区二区三区| 欧美日韩精品一区二区三区蜜桃 | 17c精品麻豆一区二区免费| 欧美色成人综合| 极品美女销魂一区二区三区| 国产精品毛片无遮挡高清| 欧美日韩一区二区三区四区五区 | 欧美日韩高清影院| 国产一本一道久久香蕉| 亚洲色欲色欲www| 欧美精品一区二区三区四区 | 亚洲欧美日韩电影| 欧美一级视频精品观看| av电影天堂一区二区在线观看| 亚洲成人高清在线| 国产精品欧美极品| 精品嫩草影院久久| 欧美性大战久久久久久久| 国产成人在线色| 首页国产丝袜综合| 成人欧美一区二区三区1314| 精品国产污网站| 欧美色图激情小说| 成人sese在线| 国产一区二区三区观看| 视频一区二区欧美| 亚洲乱码中文字幕综合| 久久久精品人体av艺术| 宅男噜噜噜66一区二区66| 99国产精品久久久久久久久久| 国产专区综合网| 青青草国产精品97视觉盛宴| 亚洲卡通欧美制服中文| 国产精品污网站| 日本一区二区三区国色天香| 日韩美女视频一区二区在线观看| 在线这里只有精品| 色婷婷亚洲一区二区三区| 波多野结衣中文一区| 国产乱理伦片在线观看夜一区| 五月激情综合网| 亚洲制服丝袜一区| 亚洲日本在线天堂| 亚洲色图欧美在线| 国产精品初高中害羞小美女文| 久久综合网色—综合色88| 欧美一区二区三区喷汁尤物| 欧美日韩黄色影视| 欧美日本高清视频在线观看| 欧美伊人久久久久久午夜久久久久| 91在线视频观看| 91麻豆自制传媒国产之光| 成人动漫精品一区二区| 成人激情校园春色| 99视频精品全部免费在线| 成人三级伦理片| www.色综合.com| 91麻豆swag| 欧洲一区二区三区免费视频| 在线观看日韩毛片| 欧美午夜精品久久久| 欧美日韩大陆在线| 日韩亚洲欧美中文三级| 精品国产区一区| 久久久久久久久岛国免费| 欧美极品aⅴ影院| 中文字幕一区二区三区四区不卡 | 国产乱码精品一区二区三| 豆国产96在线|亚洲| 99久久精品情趣| 在线观看一区不卡| 这里只有精品99re| 久久精品人人做人人爽人人 | 精品日本一线二线三线不卡| 久久品道一品道久久精品| 一区视频在线播放| 午夜精品久久久久久久99樱桃| 日本系列欧美系列| 国产精品资源网| 91小视频在线免费看| 欧美浪妇xxxx高跟鞋交| 亚洲国产一二三| 奇米影视一区二区三区| 国产成人在线影院| 在线观看区一区二| 精品电影一区二区三区 | 精品久久久久久久一区二区蜜臀| 久久先锋资源网| 亚洲欧美成aⅴ人在线观看| 天堂成人免费av电影一区| 国产一区二区三区精品视频| 99re热这里只有精品视频| 欧美日韩日日骚| 国产午夜精品福利| 亚洲高清免费一级二级三级| 国产一区二区三区美女| 欧美三级午夜理伦三级中视频| 国产午夜精品一区二区| 亚洲成人先锋电影| av电影在线观看不卡| 精品免费视频.| 亚洲成人av中文| 成人激情动漫在线观看| 91精品国产综合久久福利| 国产精品电影一区二区三区| 久久激情五月婷婷| 欧洲一区在线观看| 国产精品素人视频| 免播放器亚洲一区| 欧美丝袜丝nylons| 亚洲品质自拍视频| 国产91综合一区在线观看| 91精品福利在线一区二区三区| 亚洲色图在线视频| 成人av在线资源网站| 精品国产三级电影在线观看| 性久久久久久久| 在线看国产一区| 亚洲人成网站在线| 国产精品综合视频| 欧美成人一区二区| 首页国产丝袜综合| 欧美系列一区二区| 亚洲精品国产精华液| av爱爱亚洲一区| 国产精品网站一区| 岛国精品在线播放| 国产日韩精品一区二区三区在线| 极品少妇一区二区三区精品视频| 欧美高清dvd| 日韩二区三区在线观看| 欧美日韩五月天| 香蕉乱码成人久久天堂爱免费| 91久久免费观看| 一区二区在线观看视频在线观看| av不卡一区二区三区| 中文字幕一区二区三| 色综合天天视频在线观看 | 国产精品卡一卡二卡三| 国产精品99久久久久久久女警| 久久九九99视频|