Echelon Mini FX User Manual

Page 96

Advertising
background image

Mini FX User's Guide

83

} else {
current.value = 32767l;
}
}
return current.value;
}

//
// Driver to support simple serial output. The SerialOutput() function
// sends a zero-terminated string (without the termination byte) to the
// serial output, using the SCI input/output model. The function auto-
// matically appends a "\r\n" line termination.
// The SCI model is not available on all target chips, as it requires
// and uses the on-chip UART. Consider using the serial output model on
// IO 10 as a replacement in this case.
//
IO_8 sci baud(SCI_9600) ioSerial;

void SerialOutput(const char *data)
{
io_out_request(ioSerial, data, (unsigned)strlen(data));
while(!io_out_ready(ioSerial)) ;
// Send line termination:
io_out_request(ioSerial, "\r\n", 2);
}

//
// Driver to support the LCD display provided with the FT 5000 EVB. In a
// debug build, the driver automatically forwards the output to the serial
// port, using the SerialOutput() function.
// On a device using a Mini Gizmo I/O board, which does not include
// a LCD display, display data is always sent to the serial output.
//
// The main API is LcdDisplayString()
//
#ifndef USE_MINIGIZMO
IO_0 i2c __slow ioIIC;

# define LCD_COMMAND_PREFIX 0xFEu

# define LCD_COMMAND_ON 0x41u
# define LCD_COMMAND_SETCURSOR 0x45u
# define LCD_COMMAND_CLEARSCREEN 0x51u
# define LCD_COMMAND_BRIGHTNESS 0x53u

// The datasheet advertizes the address as 0x50, but in reality, the 7-bit
// right-justified address is 0x28 (0x50 >> 1)
# define I2C_ADDRESS_LCD (0x50u >> 1)

//
// The SendLcdCommand() function is used within this driver kit. The function
// sends a one- or two-byte command to the display.
//

void SendLcdCommand(unsigned command, unsigned parameter, unsigned size)
{
unsigned data[3];

data[0] = LCD_COMMAND_PREFIX;
data[1] = command;
data[2] = parameter;

(void)io_out(ioIIC, data, I2C_ADDRESS_LCD, 1+size);
}
#endif // !mini gizmo

//
// The InitializeLCD function enables and clears the display. Call this
// function from InitializeIO() (which in turn is called from when(reset).
//
void InitializeLCD(void)

Advertising