int8 in_read_charlieplex_inputs() { int8 switches; output_drive(PI_CHARLIEPLEX_SWITCH_1_PIN); switches = input_state(PI_CHARLIEPLEX_SWITCH_3_PIN); switches <<= 1; switches |= input_state(PI_CHARLIEPLEX_SWITCH_2_PIN); output_high(PI_CHARLIEPLEX_SWITCH_1_PIN); output_float(PI_CHARLIEPLEX_SWITCH_1_PIN); output_low(PI_CHARLIEPLEX_SWITCH_1_PIN); output_drive(PI_CHARLIEPLEX_SWITCH_2_PIN); switches <<= 1; switches |= input_state(PI_CHARLIEPLEX_SWITCH_3_PIN); switches <<= 1; switches |= input_state(PI_CHARLIEPLEX_SWITCH_1_PIN); output_high(PI_CHARLIEPLEX_SWITCH_2_PIN); output_float(PI_CHARLIEPLEX_SWITCH_2_PIN); output_low(PI_CHARLIEPLEX_SWITCH_2_PIN); //Note: In this block charliplex1 must be read before charliplex2 // just to charliplex2 has enough time to recover because charliplex2 was // low in previous block. This avoid to put a delay here. output_drive(PI_CHARLIEPLEX_SWITCH_3_PIN); switches <<= 1; switches |= input_state(PI_CHARLIEPLEX_SWITCH_1_PIN); switches <<= 1; switches |= input_state(PI_CHARLIEPLEX_SWITCH_2_PIN); output_high(PI_CHARLIEPLEX_SWITCH_3_PIN); output_float(PI_CHARLIEPLEX_SWITCH_3_PIN); output_low(PI_CHARLIEPLEX_SWITCH_3_PIN); return ~switches; }
void lcd_init(void) { BYTE i; #if defined(__PCB__) set_tris_lcd(LCD_OUTPUT_MAP); #else #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) output_drive(LCD_DATA4); output_drive(LCD_DATA5); output_drive(LCD_DATA6); output_drive(LCD_DATA7); #else lcdtris.data = 0x0; #endif lcd_enable_tris(); lcd_rs_tris(); lcd_rw_tris(); #endif lcd_output_rs(0); lcd_output_rw(0); lcd_output_enable(0); delay_ms(15); for(i=1;i<=3;++i) { lcd_send_nibble(3); delay_ms(5); } lcd_send_nibble(2); for(i=0;i<=3;++i) lcd_send_byte(0,LCD_INIT_STRING[i]); }
void eaDogM_iniSPI_BB(void) { output_drive(EADOGM_SCLK_BB); output_drive(EADOGM_MOSI_BB); output_low(EADOGM_SCLK_BB); output_low(EADOGM_MOSI_BB); }
void eaDogM_ini8Bit(void) { #ifndef EADOGM_NOCSB output_drive(EADOGM_PIN_CSB); output_high(EADOGM_PIN_CSB); #endif output_drive(EADOGM_PIN_E); output_drive(EADOGM_PIN_RW); output_drive(EADOGM_PIN_RS); output_low(EADOGM_PIN_E); output_low(EADOGM_PIN_RS); output_low(EADOGM_PIN_RW); }
BYTE lcd_read_byte(void) { BYTE low,high; #if defined(__PCB__) set_tris_lcd(LCD_INPUT_MAP); #else #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) output_float(LCD_DATA4); output_float(LCD_DATA5); output_float(LCD_DATA6); output_float(LCD_DATA7); #else lcdtris.data = 0xF; #endif #endif lcd_output_rw(1); delay_cycles(1); lcd_output_enable(1); delay_cycles(1); high = lcd_read_nibble(); lcd_output_enable(0); delay_cycles(1); lcd_output_enable(1); delay_us(1); low = lcd_read_nibble(); lcd_output_enable(0); #if defined(__PCB__) set_tris_lcd(LCD_INPUT_MAP); #else #if (defined(LCD_DATA4) && defined(LCD_DATA5) && defined(LCD_DATA6) && defined(LCD_DATA7)) output_drive(LCD_DATA4); output_drive(LCD_DATA5); output_drive(LCD_DATA6); output_drive(LCD_DATA7); #else lcdtris.data = 0x0; #endif #endif return( (high<<4) | low); }
void eaDogM_Initialize(void) { // v2.03 fix #if EADOGM_SPI_HW == 1 setup_spi(SPI_MASTER | SPI_H_TO_L | EADOGM_SPI_DIV); #endif // v2.03 fix #if EADOGM_SPI_HW == 2 setup_spi2(SPI_MASTER | SPI_H_TO_L | EADOGM_SPI_DIV); #endif #ifdef EADOGM_SPI_SW eaDogM_iniSPI_BB(); #endif #ifdef EADOGM_8BIT eaDogM_ini8Bit(); #else output_drive(EADOGM_PIN_CSB); output_drive(EADOGM_PIN_RS); output_high(EADOGM_PIN_CSB); output_high(EADOGM_PIN_RS); #endif delay_ms(200); eaDogM_WriteCommand(EADOGM_INIT_FS1); eaDogM_WriteCommand(EADOGM_INIT_BIAS_SET); eaDogM_WriteCommand(EADOGM_INIT_POWER_CONTROL); eaDogM_WriteCommand(EADOGM_INIT_FOLLOWER_CONTROL); eaDogM_WriteCommand(EADOGM_INIT_CONTRAST_SET); eaDogM_WriteCommand(EADOGM_INIT_FS2); eaDogM_WriteCommand(EADOGM_INIT_CLEAR_DISPLAY); eaDogM_WriteCommand(EADOGM_INIT_ENTRY_MODE); }