Example #1
0
// init_debugging
status_t
init_debugging()
{
	status_t error = B_OK;
	if (init_counter++ == 0) {
		// open the file
		#if DEBUG_PRINT
			out = open(DEBUG_PRINT_FILE, O_RDWR | O_CREAT | O_TRUNC);
			if (out < 0) {
				error = errno;
				init_counter--;
			}
		#endif	// DEBUG_PRINT
		// allocate the semaphore
		if (error == B_OK) {
			dbg_printf_sem = create_sem(1, "dbg_printf");
			if (dbg_printf_sem < 0)
				error = dbg_printf_sem;
		}
		if (error == B_OK) {
			#if DEBUG
				__out("##################################################\n");
			#endif
		} else
			exit_debugging();
	}
	return error;
}
Example #2
0
//---------------------------------------------------------------------------------------
void _lcd_4bit_write( int value, int rs_value )
// Writes bits 7-4 to DB7-DB4, only bits 7-4 are used  all other bits are ignored
{
    if (_lcd_mode == 6) {   // 6 wire mode
      __out(_lcd_DB7, value & 0x80 );
      __out(_lcd_DB6, value & 0x40 );
      __out(_lcd_DB5, value & 0x20 );
      __out(_lcd_DB4, value & 0x10 );
      __out(_lcd_RS,  rs_value & 0x01);
      __out(_lcd_EN, 1);
      __out(_lcd_EN, 0);
    }
 
    if (_lcd_mode == 2) {      // 2 wire mode
      int i;
      // flush the shift register with 8 bits of zero data, in preparation for a the data 
      for (i=0; i<8; i++) {  
         _lcd2w_shift_1bit(0);
      }
      
      // send the first enable bit as the msb
      _lcd2w_shift_1bit(1);
      // then send the 4 bits msb first 
      _lcd2w_shift_1bit(value & 0x80);    
      _lcd2w_shift_1bit(value & 0x40);
      _lcd2w_shift_1bit(value & 0x20);
      _lcd2w_shift_1bit(value & 0x10);
      // followed by the RS 
      _lcd2w_shift_1bit(rs_value & 0x01);
      // then the final 2 unused bits
      _lcd2w_shift_1bit(0);
      _lcd2w_shift_1bit(1);
      // finally send a 1 to activate the enable signal
      _lcd2w_shift_1bit(0);

    }
}
Example #3
0
void _lcd2w_shift_1bit(int bit_value)
{
    __out(_lcd_DATA, bit_value );  __out(_lcd_CLOCK, 1 ); __out(_lcd_CLOCK, 0 );
}