/************************************************************************************************** z-stack代码,SPI总线写数据 **************************************************************************************************/ void HalLcd_HW_Write(uint8 data) { #ifdef CC2530DK_V1 //do nothiing #else //保存原来MISO引脚的设置,方向和功能选择 uint8 dir = P1DIR; uint8 sel = P1SEL; /* 0为input 1为output 这里要设为输出,控制lcd的A0(命令或数据选择) */ P1DIR |=BV(7); /* 0为GPIO,1为外设, 这里用到的是MISO引脚的GPIO功能, 因此相应引脚设为0? */ P1SEL &=~(BV(7)); #endif LCD_SPI_BEGIN(); LCD_DO_WRITE(); LCD_SPI_TX(data); LCD_SPI_WAIT_RXRDY(); LCD_SPI_END(); #ifdef CC2530DK_V1 //do nothiing #else P1DIR =dir; P1SEL =sel; #endif }
/************************************************************************************************** z-stack代码,SPI总线写命令 **************************************************************************************************/ void HalLcd_HW_Control(uint8 cmd) { #ifdef CC2530DK_V1 //do nothiing #else //保存原来MISO引脚的设置 uint8 dir = P1DIR; uint8 sel = P1SEL; P1DIR |=BV(7); /* 0为GPIO,1为外设, 这里用到的是MISO引脚的GPIO功能, 因此相应引脚设为0? */ P1SEL &=~(BV(7)); #endif LCD_SPI_BEGIN(); LCD_DO_CONTROL(); LCD_SPI_TX(cmd); LCD_SPI_WAIT_RXRDY(); LCD_SPI_END(); #ifdef CC2530DK_V1 //do nothiing #else P1DIR =dir; P1SEL =sel; #endif }
/********************************************************************* * 函数名称:HalLcd_HW_Control * 功 能:LCD硬件写入控制 * 入口参数:cmd 写入的命令或者数据 * 出口参数:无 * 返 回 值:无 ********************************************************************/ void HalLcd_HW_Control(unsigned char cmd) { LCD_SPI_BEGIN(); LCD_SPI_TX(cmd); LCD_SPI_WAIT_RXRDY(); LCD_SPI_END(); }
/************************************************************************************************** * @fn HalLcd_HW_Write * * @brief Write 1 byte to the LCD * * @param uint8 data - data to be written to the LCD * * @return None **************************************************************************************************/ void HalLcd_HW_Write(uint8 data) { LCD_SPI_BEGIN(); LCD_DO_WRITE(); LCD_SPI_TX(data); LCD_SPI_WAIT_RXRDY(); LCD_SPI_END(); }
/************************************************************************************************** * @fn HalLcd_HW_Control * * @brief Write 1 command to the LCD * * @param uint8 cmd - command to be written to the LCD * * @return None **************************************************************************************************/ void HalLcd_HW_Control(uint8 cmd) { LCD_SPI_BEGIN(); LCD_DO_CONTROL(); LCD_SPI_TX(cmd); LCD_SPI_WAIT_RXRDY(); LCD_SPI_END(); }
/*********************************************************************************** * @fn lcdWrite * * @brief Write character to display * * @param uint8 data - character to display * * @return none */ static void lcdWrite(uint8 data) { LCD_SPI_BEGIN(); LCD_DO_WRITE(); LCD_SPI_TX(data); LCD_SPI_WAIT_RXRDY(); LCD_SPI_END(); }
/*********************************************************************************** * @fn lcdControl * * @brief Send command to display * * @param uint8 command * * @return none */ static void lcdControl(uint8 command) { LCD_SPI_BEGIN(); LCD_DO_CONTROL(); LCD_SPI_TX(command); LCD_SPI_WAIT_RXRDY(); LCD_SPI_END(); }
/*********************************************************************************** * @fn lcdWrite * * @brief Write character to display * * @param uint8 ch - character to display * * @return none */ static void lcdWrite(uint8 ch) { P1_2 = 0; //LCD_SPI_BEGIN(); LCD_DO_WRITE(); LCD_SPI_TX(ch); LCD_SPI_WAIT_RXRDY(); LCD_SPI_END(); }
/*********************************************************************************** * @fn lcdWriteMany * * @brief Write text to display * * @param char *pData - text buffer * uint16 count - number of bytes * * @return none */ static void lcdWriteMany(const char *pData, uint16 count) { LCD_SPI_BEGIN(); LCD_DO_WRITE(); while (count--) { LCD_SPI_TX(*(pData++)); LCD_SPI_WAIT_RXRDY(); } LCD_SPI_END(); }
/*********************************************************************************** * @fn lcdControl * * @brief Send command to display * * @param uint8 command * * @return none */ static void lcdControl(uint8 command) { P1_2 = 0; //LCD_SPI_BEGIN(); P0_0 = 0; //LCD_DO_CONTROL(); LCD_SPI_TX(command); LCD_SPI_WAIT_RXRDY(); __asm_begin ASM(nop) ASM(nop) ASM(nop) ASM(nop) __asm_end; P1_2 = 1; //LCD_SPI_END(); }