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

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

?? lcd.c

?? zigbee 2430 演示 就是個演示程序么 說這么多干嘛 暈
?? 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一区二区三区免费野_久草精品视频
欧美日韩一区在线观看| 国产精品色哟哟网站| 久久蜜桃av一区精品变态类天堂 | 亚洲国产毛片aaaaa无费看 | 精品国精品国产| 亚洲福利一区二区| 91天堂素人约啪| 久久女同性恋中文字幕| 丝袜美腿成人在线| 在线免费观看一区| 亚洲视频在线观看三级| 成人免费高清在线观看| 欧美精品一区在线观看| 欧美aaaaaa午夜精品| 欧美日韩精品电影| 日韩精品成人一区二区三区| voyeur盗摄精品| 国产亚洲精品7777| 国产美女av一区二区三区| 欧美一区二区视频在线观看2022| 亚洲免费在线视频一区 二区| av在线不卡网| 亚洲三级在线播放| 99国产精品久久| 中文字幕在线观看一区二区| 国产成人午夜精品影院观看视频| 日韩一区二区三免费高清| 日韩精品久久理论片| 欧美精品一二三四| 丝袜亚洲另类丝袜在线| 欧美日韩mp4| 日本不卡视频在线观看| 日韩一区二区免费在线电影| 日本女人一区二区三区| 欧美va天堂va视频va在线| 久久精品国产99国产| 亚洲精品在线一区二区| 国产伦精品一区二区三区免费迷| 精品成a人在线观看| 国产精品亚洲一区二区三区在线 | 丰满放荡岳乱妇91ww| 久久蜜桃一区二区| 不卡的看片网站| 亚洲精品免费一二三区| 色婷婷av一区二区三区大白胸| 亚洲精品乱码久久久久久久久 | 日韩精品久久久久久| 欧美成人bangbros| 高清不卡一区二区| 亚洲视频在线观看一区| 欧美三级电影在线观看| 奇米精品一区二区三区在线观看一| 欧美大片一区二区三区| 成人在线综合网站| 亚洲一区二区三区四区在线免费观看| 在线视频中文字幕一区二区| 青青草97国产精品免费观看| 日本一区二区免费在线观看视频| heyzo一本久久综合| 午夜在线成人av| 久久精品亚洲乱码伦伦中文| 色香色香欲天天天影视综合网| 性做久久久久久免费观看欧美| 精品成人在线观看| 色拍拍在线精品视频8848| 日韩电影在线免费| 欧美韩国日本一区| 欧美日韩国产一区二区三区地区| 国产一区二区免费在线| 亚洲自拍偷拍av| 久久久久久久久久久久久女国产乱| 一本色道亚洲精品aⅴ| 久久99这里只有精品| 亚洲欧美视频一区| 精品对白一区国产伦| 91成人看片片| 国产91对白在线观看九色| 日一区二区三区| 亚洲天堂精品在线观看| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 1000精品久久久久久久久| 欧美一级日韩不卡播放免费| 色婷婷久久久亚洲一区二区三区| 精品一区二区三区蜜桃| 一区二区三区久久久| 国产日本亚洲高清| 精品女同一区二区| 在线91免费看| 色视频成人在线观看免| 成人sese在线| 国产精品一区久久久久| 久久精品国产99久久6| 亚洲成人免费av| 一区二区三区免费网站| 国产精品麻豆一区二区| 中文字幕第一区第二区| 2024国产精品视频| 日韩一区二区三区在线| 欧美久久久久中文字幕| 在线视频国内自拍亚洲视频| 不卡高清视频专区| 国产成人精品免费视频网站| 激情av综合网| 另类专区欧美蜜桃臀第一页| 亚洲gay无套男同| 亚洲大片在线观看| 亚洲成人免费视频| 亚洲成人你懂的| 天天色天天爱天天射综合| 五月激情六月综合| 午夜av电影一区| 爽好久久久欧美精品| 日韩av午夜在线观看| 麻豆精品精品国产自在97香蕉 | 亚洲国产精品t66y| 国产欧美视频在线观看| 欧美激情综合网| 国产精品二三区| 亚洲精品中文字幕在线观看| 亚洲伊人伊色伊影伊综合网| 亚洲成人免费观看| 蜜桃精品在线观看| 国产一区二区不卡| 福利一区二区在线| 91在线porny国产在线看| 色婷婷狠狠综合| 欧美日高清视频| ww亚洲ww在线观看国产| 久久精品视频一区二区| 中文字幕日本不卡| 亚洲国产视频一区| 美洲天堂一区二卡三卡四卡视频| 国产一区二区三区免费在线观看| 国产盗摄一区二区| 日本黄色一区二区| 日韩一级完整毛片| 国产农村妇女精品| 亚洲成av人片在线观看无码| 美女国产一区二区| 91在线观看成人| 日韩精品一区二区三区中文不卡| 国产午夜一区二区三区| 一区二区三区欧美日| 九九在线精品视频| 99视频精品在线| 日韩视频一区二区| 中文字幕中文在线不卡住| 日韩一区精品视频| 成人av网在线| 欧美一级欧美三级在线观看| 国产精品久久久久久久久晋中 | 国产成人精品免费看| 一本一道久久a久久精品| 欧美一级在线免费| 中文字幕日韩一区| 日韩激情一区二区| 99在线视频精品| 欧美电影免费观看高清完整版在线| 欧美激情自拍偷拍| 美女一区二区久久| 色成人在线视频| 欧美韩日一区二区三区四区| 亚洲va欧美va人人爽午夜| 成人免费av网站| 日韩欧美色综合网站| 亚洲一区中文日韩| 春色校园综合激情亚洲| 日韩亚洲欧美成人一区| 亚洲免费观看高清完整| 成人午夜碰碰视频| 精品欧美一区二区在线观看| 亚洲国产精品一区二区久久| 99热这里都是精品| 久久毛片高清国产| 久久99久久精品| 日韩欧美久久一区| 丝袜诱惑亚洲看片| 欧美日韩在线观看一区二区 | 日日欢夜夜爽一区| 欧美综合在线视频| 中文字幕在线一区| 国内精品视频一区二区三区八戒| 欧美三区在线视频| 中文字幕一区二区在线播放| 国产在线精品不卡| 久久亚洲二区三区| 韩国三级在线一区| 欧美电影免费观看高清完整版在线 | 色综合激情久久| 日韩一区日韩二区| gogo大胆日本视频一区| 国产精品久久久久影院色老大| 国产九色精品成人porny| 精品少妇一区二区| 九九九久久久精品| 日韩一区国产二区欧美三区| 日韩在线播放一区二区| 欧美日韩精品一区二区三区四区| 一区二区三区国产精品| 色老汉一区二区三区|