下載本文檔
版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、#include stm8s.h#include global.h”/* Private typedef*/* Private define*/顯示芯片HT1621引腳定義#define HT1621_CS_PORTGPIOC#define HT1621_CS_PINGPIO_PIN_7#define Ht1621CsHigh(HT1621_CS_PORT-ODR |=(u8)(HT1621_CS_PIN)#define Ht1621CsLow(HT1621_CS_PORT-ODR &=(u8)(HT1621_CS_PIN)#define HT1621_WR_PORTGPIOC#define
2、HT1621_WR_PINGPIO_PIN_6#define Ht1621WrHigh(HT1621_WR_PORT-ODR |=(u8)(HT1621_WR_PIN)#define Ht1621WrLow(HT1621_WR_PORT-ODR &=(u8)(HT1621_WR_PIN)#define HT1621_DATA_PORTGPIOC#define HT1621_DATA_PINGPIO_PIN_5#define Ht1621DataHigh(HT1621_DATA_PORT-ODR |=(u8)(HT1621_DATA_PIN)#define Ht1621DataLow(HT162
3、1_DATA_PORT-ODR &=(u8)(HT1621_DATA_PIN)/LCD屏背光PWM設定#define BLACK_LIGHT_PORTGPIOD#define BLACK_LIGHT_PINGPIO_PIN_3#define LedPwmDuty(A)TIM2-CCR2H = (u8)(A) 8);TIM2-CCR2L(u8)(A);#define LedOn()TIM2-CCER1 |= TIM2_CCER1_CC2E#define LedOff()TIM2-CCER1 &= (TIM2_CCER1_CC2E)#define COMMAND_CODE0 x80 /命令碼#de
4、fine WRITE_DATA_CODE0 xa0 /寫 命令#define READ_DATA_CODE0 xc0 /讀命令#define DISPLAY_BEGIN_ADDR(0X0F 2) /顯示起始地址#define SYS_EN0 x02#define RC256K0 x30#defineBIAS_130 x52#defineTONE_ON0 x12 /打開聲音輸出#defineTONE_OFF0 x10#defineTONE_2K0 xc0#defineTONE_4K0 x80#defineLCD_ON0 x06/* Private variables*/void Ht1621_W
5、riteCommand(uint8_t Cmd);void Ht1621_WriteNBit(uint8_t BitCnt, uint8_t wData);/* Public functions*/void Ht1621_Init(void);void Ht1621_WriteData(const uint8_t *wDataBuf);void Ht1621_BuzzerControl(uint8_t RunFlag);*函數:延時函數ms參數:返回值:無*/void Ht1621_Delay(uint8_t ms)unsigned short jj;for (jj = 1; jj = ms;
6、 jj+)nop();*函數:HT1621初始化參數:返回值:無*/void Ht1621_Init(void)Ht1621_WriteCommand(SYS_EN); /SYS_EN 打開系統(tǒng)振蕩器Ht1621_Delay(5);Ht1621_WriteCommand(RC_256K); /RC_256K 系統(tǒng)時鐘源 片內 RC 振蕩器 Ht1621_Delay(5);Ht1621_WriteCommand(BIAS_13); /BIAS13 4 個公共口 Ht1621_Delay(5);Ht1621_WriteCommand(TONE_4K); /TONE_2KC0 TONE_4K80Ht
7、1621_Delay(5);Ht1621_WriteCommand(LCD_ON); /LCD_ON 打開 LCD 偏壓發(fā)生器 Ht1621_Delay(5);個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個*函數:HT1621寫一字節(jié)數據參數:寫數據的為位數和數據返回值:無 個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個/void Ht1621_WriteNBit(uint8
8、_t wData , uint8_t BitCnt)uint8_t i;for(i=0; i BitCnt; i+)Ht1621WrLow;Ht1621_Delay(2);if(wData i) & 0 x80)Ht1621DataHigh;elseHt1621DataLow;Ht1621_Delay(2);Ht1621WrHigh;Ht1621_Delay(2);*函數:HT1621寫數據操作(連續(xù)寫3位寫操作命令+6位地址+ .數據)參數:寫數據指針返回值:無 個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個
9、個個個個個個個個個個個個個個/void Ht1621_WriteData(const uint8_t *wDataBuf)uint8_t i;Ht1621CsLow;Ht1621_Delay(2);Ht1621_WriteNBit(WRITE_DATA_CODE, 3);Ht1621_WriteNBit(DISPLAY_BEGIN_ADDR, 6);/TODO: 20140820 hzg 注意要相應原理圖上的起始地址for(i=0; i12; i+)Ht1621_WriteNBit(wDataBufi, 8);Ht1621CsHigh;Ht1621_Delay(2);個個個個個個個個個個個個個
10、個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個*函數:HT1621寫命令操作(12位命令數據)參數:命令值返回值:無 個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個個/void Ht1621_WriteCommand(uint8_t Cmd)Ht1621CsLow;Ht1621_Delay(2);Ht1621_WriteNBit(COMMAND_CODE, 4);Ht1621_WriteNBit(Cmd, 8);Ht1621CsHigh;Ht1621_Delay
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
評論
0/150
提交評論