コード例 #1
0
ファイル: screen.c プロジェクト: christopherjsmith/C2OS
int get_cursor_pos() {    
    byte_out(SCREEN_CTRL, CLR_HIGH);
    int offset = byte_in(SCREEN_DATA) << 8;
    byte_out(SCREEN_CTRL, CLR_LOW);
    offset += byte_in(SCREEN_DATA);
    
    return offset;
}
コード例 #2
0
ファイル: screen.c プロジェクト: christopherjsmith/C2OS
void set_cursor_pos(short x, short y) {
    int offset = get_screen_offset(x, y);
    
    byte_out(SCREEN_CTRL, CLR_HIGH);
    byte_out(SCREEN_DATA, (unsigned char) ( offset >> 8 ) );
    byte_out(SCREEN_CTRL, CLR_LOW);
    byte_out(SCREEN_DATA, (unsigned char) offset);
}
コード例 #3
0
ファイル: eeprom_udb4.c プロジェクト: kd0aij/matrixpilot_old
void eeprom_ByteWrite(uint16_t address, uint8_t data)
{
	ACK_Poll();                     // Begin ACK polling
	bstart();                       // Generate Start condition
	byte_out(eeprom_control);       // Output control byte
	byte_out((uint8_t)(address>>8));// Output address MSB
	byte_out((uint8_t)address);     // Output address LSB
	byte_out(data);                 // Output data byte
	bstop();                        // Generate Stop condition
}
コード例 #4
0
ファイル: eeprom_udb4.c プロジェクト: kd0aij/matrixpilot_old
void eeprom_ByteRead(uint16_t address, uint8_t *data)
{
	ACK_Poll();                     // Begin ACK polling
	bstart();                       // Generate Start condition
	byte_out(eeprom_control);       // Output control byte
	byte_out((uint8_t)(address>>8));// Output address MSB
	byte_out((uint8_t)address);     // Output address LSB
	bstart();                       // Generate Start condition
	byte_out(eeprom_control | 0x01);// Output control byte
	*data = byte_in(NAKBIT);        // Input data byte
	bstop();                        // Generate Stop condition
}
コード例 #5
0
ファイル: eeprom_udb4.c プロジェクト: kd0aij/matrixpilot_old
void eeprom_PageWrite(uint16_t address, uint8_t *data, uint8_t numbytes)
{
	uint8_t i;                      // Loop counter

	ACK_Poll();                     // Begin ACK polling
	bstart();                       // Generate Start condition
	byte_out(eeprom_control);       // Output control byte
	byte_out((uint8_t)(address>>8));// Output address MSB
	byte_out((uint8_t)address);     // Output address LSB
	for (i = 0; i < numbytes; i++)  // Loop through data bytes
	{
		byte_out(data[i]);          // Output next data byte
	}
	bstop();                        // Generate Stop condition
}
コード例 #6
0
ファイル: eeprom_udb4.c プロジェクト: kd0aij/matrixpilot_old
/********************************************************************
 * Function:        void ACK_Poll(void)
 *
 * Description:     This function implements Acknowledge polling.
 *******************************************************************/
void ACK_Poll(void)
{
	uint8_t result;                 // Polling result

	result = 1;                     // Initialize result
	do
	{
		bstart();                   // Generate Start condition
		result = byte_out(eeprom_control); // Output control byte
	} while (result == 1);
	bstop();                        // Generate Stop condition
}
コード例 #7
0
ファイル: eeprom_udb4.c プロジェクト: kd0aij/matrixpilot_old
void eeprom_SequentialRead(uint16_t address, uint8_t *data, uint16_t numbytes)
{
	uint16_t i;                     // Loop counter

	ACK_Poll();                     // Begin ACK polling
	bstart();                       // Generate Start condition
	byte_out(eeprom_control);       // Output control byte
	byte_out((uint8_t)(address>>8));// Output address MSB
	byte_out((uint8_t)address);     // Output address LSB
	bstart();                       // Generate Start condition
	byte_out(eeprom_control | 0x01);// Output control byte
	for (i = 0; i < numbytes; i++)  // Loop through data bytes
	{
		if (i < (numbytes - 1))     // Check if more data will be read
		{
			data[i] = byte_in(ACKBIT); // If not last, input byte & send ACK
		}
		else
		{
			data[i] = byte_in(NAKBIT); // If last byte, input byte & send NAK
		}
	}
	bstop();                        // Generate Stop condition
}