Coding standards
This commit is contained in:
@ -45,12 +45,11 @@
|
||||
#define OUTPUT 1
|
||||
#define INPUT_PULLUP 2
|
||||
|
||||
|
||||
uint8_t LPC1768_PIN_PORT(const uint8_t pin);
|
||||
uint8_t LPC1768_PIN_PIN(const uint8_t pin);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// I/O functions
|
||||
@ -63,22 +62,21 @@ void pinMode_LCD(uint8_t pin, uint8_t mode) {
|
||||
PINSEL_FUNC_0,
|
||||
PINSEL_PINMODE_TRISTATE,
|
||||
PINSEL_PINMODE_NORMAL };
|
||||
switch(mode) {
|
||||
case INPUT:
|
||||
LPC_GPIO(LPC1768_PIN_PORT(pin))->FIODIR &= ~LPC_PIN(LPC1768_PIN_PIN(pin));
|
||||
PINSEL_ConfigPin(&config);
|
||||
break;
|
||||
case OUTPUT:
|
||||
LPC_GPIO(LPC1768_PIN_PORT(pin))->FIODIR |= LPC_PIN(LPC1768_PIN_PIN(pin));
|
||||
PINSEL_ConfigPin(&config);
|
||||
break;
|
||||
case INPUT_PULLUP:
|
||||
LPC_GPIO(LPC1768_PIN_PORT(pin))->FIODIR &= ~LPC_PIN(LPC1768_PIN_PIN(pin));
|
||||
config.Pinmode = PINSEL_PINMODE_PULLUP;
|
||||
PINSEL_ConfigPin(&config);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
switch (mode) {
|
||||
case INPUT:
|
||||
LPC_GPIO(LPC1768_PIN_PORT(pin))->FIODIR &= ~LPC_PIN(LPC1768_PIN_PIN(pin));
|
||||
PINSEL_ConfigPin(&config);
|
||||
break;
|
||||
case OUTPUT:
|
||||
LPC_GPIO(LPC1768_PIN_PORT(pin))->FIODIR |= LPC_PIN(LPC1768_PIN_PIN(pin));
|
||||
PINSEL_ConfigPin(&config);
|
||||
break;
|
||||
case INPUT_PULLUP:
|
||||
LPC_GPIO(LPC1768_PIN_PORT(pin))->FIODIR &= ~LPC_PIN(LPC1768_PIN_PIN(pin));
|
||||
config.Pinmode = PINSEL_PINMODE_PULLUP;
|
||||
PINSEL_ConfigPin(&config);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,7 +103,6 @@ uint8_t u8g_GetPinLevel(uint8_t pin) {
|
||||
return (uint32_t)LPC_GPIO(LPC1768_PIN_PORT(pin))->FIOPIN & LPC_PIN(LPC1768_PIN_PIN(pin)) ? 1 : 0;
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -95,9 +95,8 @@ uint8_t u8g_com_ssd_I2C_start_sequence(u8g_t *u8g) {
|
||||
if (u8g->pin_list[U8G_PI_SET_A0] == 0) return 1;
|
||||
|
||||
/* setup bus, might be a repeated start */
|
||||
if (u8g_i2c_start(I2C_SLA) == 0)
|
||||
return 0;
|
||||
if (u8g->pin_list[U8G_PI_A0_STATE] == 0 ) {
|
||||
if (u8g_i2c_start(I2C_SLA) == 0) return 0;
|
||||
if (u8g->pin_list[U8G_PI_A0_STATE] == 0) {
|
||||
if (u8g_i2c_send_byte(I2C_CMD_MODE) == 0) return 0;
|
||||
}
|
||||
else if (u8g_i2c_send_byte(I2C_DATA_MODE) == 0)
|
||||
@ -108,7 +107,7 @@ uint8_t u8g_com_ssd_I2C_start_sequence(u8g_t *u8g) {
|
||||
}
|
||||
|
||||
uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
switch(msg) {
|
||||
switch (msg) {
|
||||
case U8G_COM_MSG_INIT:
|
||||
//u8g_com_arduino_digital_write(u8g, U8G_PI_SCL, HIGH);
|
||||
//u8g_com_arduino_digital_write(u8g, U8G_PI_SDA, HIGH);
|
||||
|
@ -91,7 +91,7 @@ static void u8g_com_LPC1768_st7920_write_byte_hw_spi(uint8_t rs, uint8_t val) {
|
||||
}
|
||||
|
||||
uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
switch(msg) {
|
||||
switch (msg) {
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_SetPILevel(u8g, U8G_PI_CS, 0);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_CS);
|
||||
|
@ -89,10 +89,8 @@ static void u8g_com_LPC1768_st7920_write_byte_sw_spi(uint8_t rs, uint8_t val) {
|
||||
swSpiTransfer(val << 4, SPI_speed, SCK_pin_ST7920_HAL, -1, MOSI_pin_ST7920_HAL_HAL);
|
||||
}
|
||||
|
||||
uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr)
|
||||
{
|
||||
switch(msg)
|
||||
{
|
||||
uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
switch (msg) {
|
||||
case U8G_COM_MSG_INIT:
|
||||
SCK_pin_ST7920_HAL = u8g->pin_list[U8G_PI_SCK];
|
||||
MOSI_pin_ST7920_HAL_HAL = u8g->pin_list[U8G_PI_MOSI];
|
||||
|
@ -72,7 +72,7 @@ static void u8g_sw_spi_HAL_LPC1768_shift_out(uint8_t dataPin, uint8_t clockPin,
|
||||
}
|
||||
|
||||
uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr) {
|
||||
switch(msg) {
|
||||
switch (msg) {
|
||||
case U8G_COM_MSG_INIT:
|
||||
u8g_SetPIOutput(u8g, U8G_PI_SCK);
|
||||
u8g_SetPIOutput(u8g, U8G_PI_MOSI);
|
||||
|
Reference in New Issue
Block a user