123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #include "UC1601S-I2C.h"
- void uc1601s_write_command(unsigned char cmd) {
- expander_set_bit_no_send(UC1601S_CS_PORT, UC1601S_CS, 0);
- expander_set_bit_no_send(UC1601S_CD_PORT, UC1601S_CD, 0);
- exp_output[0] = cmd;
- expander_write(0);
- expander_set_bit(UC1601S_WR_PORT, UC1601S_WR, 0);
- expander_set_bit(UC1601S_WR_PORT, UC1601S_WR, 1);
- expander_set_bit(UC1601S_CS_PORT, UC1601S_CS, 1);
- }
- void uc1601s_write_data(unsigned char data) {
- expander_set_bit_no_send(UC1601S_CS_PORT, UC1601S_CS, 0);
- expander_set_bit(UC1601S_CD_PORT, UC1601S_CD, 1);
- exp_output[0] = data;
- expander_write(0);
- expander_set_bit(UC1601S_WR_PORT, UC1601S_WR, 0);
- expander_set_bit(UC1601S_WR_PORT, UC1601S_WR, 1);
- expander_set_bit(UC1601S_CS_PORT, UC1601S_CS, 1);
- }
- unsigned char uc1601s_read_data(void) {
- unsigned char out;
- UC1601S_DATA_INPUT();
- expander_set_bit_no_send(UC1601S_CS_PORT, UC1601S_CS, 0);
- expander_set_bit_no_send(UC1601S_CD_PORT, UC1601S_CD, 1);
- expander_set_bit(UC1601S_RD_PORT, UC1601S_RD, 0);
- out = expander_read_byte(0, 0);
- expander_set_bit_no_send(UC1601S_RD_PORT, UC1601S_RD, 1);
- expander_set_bit(UC1601S_CS_PORT, UC1601S_CS, 1);
- UC1601S_DATA_OUTPUT();
- return out;
- }
- #define UC1601S_INTERNAL_VLCD 0x6
- void LCD_Initialize(void) {
- expander_set_bit(UC1601S_RST_PORT, UC1601S_RST, 1);
- _delay_ms(5);
- expander_set_bit_no_send(UC1601S_RD_PORT, UC1601S_RD, 1);
- expander_set_bit(UC1601S_WR_PORT, UC1601S_WR, 1);
- UC1601S_DATA_OUTPUT();
- // uc1601s_system_reset();
- uc1601s_set_lcd_bias_ratio(UC1601S_BIAS_RATIO_8);
- uc1601s_set_vbias(0xee);
- uc1601s_set_display_enable(1);
- uc1601s_set_power_control(UC1601S_INTERNAL_VLCD);
- uc1601s_set_all_pixel_on(1);
- _delay_ms(2);
- }
|