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

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

?? lcd.c

?? CC2430多功能綜合測試程序,zigbee協議下的通信開發源碼
?? 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一区二区三区免费野_久草精品视频
精品国精品国产| 无吗不卡中文字幕| 亚洲国产sm捆绑调教视频| 免费高清在线视频一区·| 不卡av免费在线观看| 3751色影院一区二区三区| 国产精品嫩草影院com| 日本欧美在线观看| 91成人在线免费观看| 精品福利视频一区二区三区| 亚洲乱码国产乱码精品精小说| 毛片一区二区三区| 色94色欧美sute亚洲线路一久 | 蜜芽一区二区三区| 国产91在线观看| 欧美精品日韩一本| 亚洲婷婷国产精品电影人久久| 经典三级在线一区| 欧美老年两性高潮| 亚洲精品精品亚洲| av一本久道久久综合久久鬼色| 精品久久人人做人人爽| 亚洲一区二区三区四区不卡| 99久久免费视频.com| 国产欧美日韩激情| 国产精品乡下勾搭老头1| 欧美一二区视频| 午夜私人影院久久久久| 色噜噜狠狠色综合欧洲selulu | 538在线一区二区精品国产| 亚洲婷婷综合色高清在线| 成人永久免费视频| 久久久久国产精品麻豆ai换脸 | 日韩欧美成人激情| 日本va欧美va瓶| 欧美一级搡bbbb搡bbbb| 日韩电影在线免费| 91精品免费观看| 免费成人av在线播放| 日韩三级在线免费观看| 日本不卡免费在线视频| 91精品在线观看入口| 日本特黄久久久高潮| 日韩一区二区免费高清| 秋霞电影一区二区| 日韩手机在线导航| 久久精品99国产精品| 亚洲精品在线三区| 国产成a人无v码亚洲福利| 久久影音资源网| 国产99久久久国产精品潘金网站| 久久九九国产精品| 91在线视频官网| 亚洲欧美一区二区三区极速播放 | 日韩成人av影视| 欧美一区2区视频在线观看| 青青青爽久久午夜综合久久午夜| 日韩三级免费观看| 国产一区二区三区黄视频| 久久精品视频在线看| 成人污视频在线观看| 一区二区三区美女视频| 欧美一区二区高清| 风间由美性色一区二区三区| 自拍偷拍亚洲欧美日韩| 欧美精选一区二区| 国产精品一区二区三区乱码| 亚洲老妇xxxxxx| 日韩精品在线看片z| 成人18视频日本| 亚洲一区二区五区| 欧美电影免费观看高清完整版在线 | 国产女同互慰高潮91漫画| 成人av免费在线观看| 天堂一区二区在线| 国产欧美精品一区二区色综合| 在线视频欧美精品| 激情丁香综合五月| ...av二区三区久久精品| 欧美日韩黄视频| 国产一区二区视频在线| 亚洲资源中文字幕| 欧美激情一区二区| 欧美丰满高潮xxxx喷水动漫| 成人免费黄色大片| 全部av―极品视觉盛宴亚洲| 国产精品久久久久久久久图文区| 在线电影一区二区三区| 波多野结衣中文字幕一区| 男男视频亚洲欧美| 亚洲精品乱码久久久久久黑人| 欧美电视剧在线看免费| 91国产成人在线| 国产成人精品aa毛片| 日韩av不卡一区二区| 亚洲品质自拍视频网站| 日本一区免费视频| 日韩手机在线导航| 在线电影欧美成精品| 色婷婷精品久久二区二区蜜臂av| 国产精选一区二区三区| 免费亚洲电影在线| 亚洲成人自拍偷拍| 亚洲精品日韩专区silk| 国产欧美精品国产国产专区| 日韩女优av电影| 欧美日韩你懂的| 91麻豆自制传媒国产之光| 丰满放荡岳乱妇91ww| 国产一区二三区| 另类小说色综合网站| 亚洲成人av免费| 亚洲一区影音先锋| 亚洲一区二区三区四区五区黄| 国产精品进线69影院| 欧美激情在线观看视频免费| 久久综合99re88久久爱| 久久久蜜臀国产一区二区| 日韩一区二区视频| 日韩女优毛片在线| 精品国产乱码久久久久久免费| 日韩美女天天操| 欧美变态tickle挠乳网站| 欧美一区二区三区在线视频| 91精品婷婷国产综合久久性色| 在线电影院国产精品| 日韩片之四级片| 精品国免费一区二区三区| 久久亚洲影视婷婷| 国产精品免费视频一区| 国产精品福利在线播放| 伊人一区二区三区| 日韩成人午夜电影| 国产一区二区三区在线看麻豆 | 五月综合激情网| 午夜精品福利一区二区三区av | 国产精品久久免费看| 亚洲男人的天堂在线观看| 亚洲一区二区视频在线| 婷婷一区二区三区| 国内欧美视频一区二区| 国产成人av一区二区三区在线观看| 国产精品资源网| 福利91精品一区二区三区| 国产91在线观看| 久久99国产精品久久99| 国产精品一区二区在线观看不卡| 国产风韵犹存在线视精品| 国产精品综合网| 粉嫩av一区二区三区| 亚洲成a人v欧美综合天堂下载| 玖玖九九国产精品| 国产成人免费av在线| 99久久久无码国产精品| 欧美在线观看你懂的| 精品入口麻豆88视频| 国产三级欧美三级日产三级99| 国产精品丝袜久久久久久app| 国产精品久久国产精麻豆99网站| 亚洲午夜激情av| 麻豆精品一区二区三区| 国产乱理伦片在线观看夜一区 | www.色精品| 欧美三区免费完整视频在线观看| 5月丁香婷婷综合| 最新国产の精品合集bt伙计| 亚洲二区在线观看| 国产一区中文字幕| 在线观看网站黄不卡| 精品成人免费观看| 亚洲免费观看高清完整版在线观看熊| 中文字幕欧美日韩一区| 亚洲国产中文字幕| 国产永久精品大片wwwapp| 国产69精品久久久久毛片| 欧美性大战久久久| 久久亚洲综合色一区二区三区| 亚洲美女视频在线观看| 麻豆精品新av中文字幕| 极品少妇一区二区三区精品视频 | 亚洲精品国产精品乱码不99 | 亚洲日穴在线视频| 欧美aaa在线| 91亚洲精品一区二区乱码| 91成人免费在线视频| 国产精品国产三级国产有无不卡 | √…a在线天堂一区| 蜜臀av性久久久久av蜜臀妖精| 丁香婷婷综合激情五月色| 欧美怡红院视频| 中文字幕成人av| 日韩国产精品久久久| 99这里只有精品| 欧美国产一区二区在线观看| 午夜影院在线观看欧美| 色哟哟在线观看一区二区三区| 国产欧美一区二区三区在线老狼| 偷窥国产亚洲免费视频| 97se狠狠狠综合亚洲狠狠| 国产午夜精品理论片a级大结局 |