From 799e3b2b404dbdd3f017b3b68714628f6cb4f2e4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 21 Feb 2018 18:43:42 -0600 Subject: [PATCH] LPC1768 HAL formatting/comments --- Marlin/src/HAL/HAL_LPC1768/HAL.h | 11 ++-- .../HAL/HAL_LPC1768/HAL_LCD_I2C_routines.h | 14 ++---- Marlin/src/HAL/HAL_LPC1768/HAL_LCD_delay.h | 6 +-- .../HAL/HAL_LPC1768/HAL_LCD_pin_routines.h | 11 ---- .../HAL/HAL_LPC1768/HAL_LPC1768_LCD_defines.h | 50 +++++++++---------- Marlin/src/HAL/HAL_LPC1768/LPC_SPI.h | 1 + Marlin/src/HAL/HAL_LPC1768/main.cpp | 4 +- .../u8g_com_HAL_LPC1768_hw_spi.cpp | 6 +-- 8 files changed, 39 insertions(+), 64 deletions(-) diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL.h b/Marlin/src/HAL/HAL_LPC1768/HAL.h index 1ec5901517..87e80ae87b 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL.h +++ b/Marlin/src/HAL/HAL_LPC1768/HAL.h @@ -21,13 +21,12 @@ */ /** - * Description: HAL for Arduino Due and compatible (SAM3X8E) - * - * For ARDUINO_ARCH_SAM + * HAL_LPC1768/HAL.h + * Hardware Abstraction Layer for NXP LPC1768 */ -#ifndef _HAL_LPC1768_H -#define _HAL_LPC1768_H +#ifndef _HAL_LPC1768_H_ +#define _HAL_LPC1768_H_ // -------------------------------------------------------------------------- // Includes @@ -141,4 +140,4 @@ void HAL_adc_enable_channel(int pin); void HAL_adc_start_conversion(const uint8_t adc_pin); uint16_t HAL_adc_get_result(void); -#endif // _HAL_LPC1768_H +#endif // _HAL_LPC1768_H_ diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL_LCD_I2C_routines.h b/Marlin/src/HAL/HAL_LPC1768/HAL_LCD_I2C_routines.h index c02ae6e964..5f7337316a 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL_LCD_I2C_routines.h +++ b/Marlin/src/HAL/HAL_LPC1768/HAL_LCD_I2C_routines.h @@ -20,12 +20,8 @@ * */ -#ifdef TARGET_LPC1768 - - void u8g_i2c_init(uint8_t options); - uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos); - uint8_t u8g_i2c_start(uint8_t sla); - uint8_t u8g_i2c_send_byte(uint8_t data); - void u8g_i2c_stop(void); - -#endif +void u8g_i2c_init(uint8_t options); +uint8_t u8g_i2c_wait(uint8_t mask, uint8_t pos); +uint8_t u8g_i2c_start(uint8_t sla); +uint8_t u8g_i2c_send_byte(uint8_t data); +void u8g_i2c_stop(void); diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL_LCD_delay.h b/Marlin/src/HAL/HAL_LPC1768/HAL_LCD_delay.h index 3a7b3a4839..28c950ae49 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL_LCD_delay.h +++ b/Marlin/src/HAL/HAL_LPC1768/HAL_LCD_delay.h @@ -29,18 +29,14 @@ * one microsecond delay being about 4uS. */ - - #ifdef __cplusplus extern "C" { #endif void U8g_delay(int msec); - void u8g_MicroDelay(void); - void u8g_10MicroDelay(void); #ifdef __cplusplus } -#endif \ No newline at end of file +#endif diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL_LCD_pin_routines.h b/Marlin/src/HAL/HAL_LPC1768/HAL_LCD_pin_routines.h index eb4cb2e5e8..5a900ac45c 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL_LCD_pin_routines.h +++ b/Marlin/src/HAL/HAL_LPC1768/HAL_LCD_pin_routines.h @@ -30,18 +30,7 @@ * resulted in using about about 25% of the CPU's time. */ - - - - void u8g_SetPinOutput(uint8_t internal_pin_number); - void u8g_SetPinInput(uint8_t internal_pin_number); - void u8g_SetPinLevel(uint8_t pin, uint8_t pin_status); - uint8_t u8g_GetPinLevel(uint8_t pin); - - - - diff --git a/Marlin/src/HAL/HAL_LPC1768/HAL_LPC1768_LCD_defines.h b/Marlin/src/HAL/HAL_LPC1768/HAL_LPC1768_LCD_defines.h index 7347164d6a..496f8810dc 100644 --- a/Marlin/src/HAL/HAL_LPC1768/HAL_LPC1768_LCD_defines.h +++ b/Marlin/src/HAL/HAL_LPC1768/HAL_LPC1768_LCD_defines.h @@ -24,35 +24,31 @@ * LPC1768 LCD-specific defines */ -#ifdef TARGET_LPC1768 +// pointers to low level routines - must always supply these +//#define U8G_HAL_LINKS +#define HAL_LCD_pin_routines "HAL_LPC1768/HAL_LCD_pin_routines.h" +#define HAL_LCD_I2C_routines "HAL_LPC1768/HAL_LCD_I2C_routines.h" +#define HAL_LCD_delay "HAL_LPC1768/HAL_LCD_delay.h" - // pointers to low level routines - must always supply these - //#define U8G_HAL_LINKS - #define HAL_LCD_pin_routines "HAL_LPC1768/HAL_LCD_pin_routines.h" - #define HAL_LCD_I2C_routines "HAL_LPC1768/HAL_LCD_I2C_routines.h" - #define HAL_LCD_delay "HAL_LPC1768/HAL_LCD_delay.h" +// The following are optional depending on the platform. - // The following are optional depending on the platform. - - // definitions of HAL specific com and device drivers. - uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); +// definitions of HAL specific com and device drivers. +uint8_t u8g_com_HAL_LPC1768_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); +uint8_t u8g_com_HAL_LPC1768_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); +uint8_t u8g_com_HAL_LPC1768_ST7920_hw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); +uint8_t u8g_com_HAL_LPC1768_ST7920_sw_spi_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); +uint8_t u8g_com_HAL_LPC1768_ssd_hw_i2c_fn(u8g_t *u8g, uint8_t msg, uint8_t arg_val, void *arg_ptr); - // connect U8g com generic com names to the desired driver - #define U8G_COM_HW_SPI u8g_com_HAL_LPC1768_hw_spi_fn // use LPC1768 specific hardware SPI routine - #define U8G_COM_SW_SPI u8g_com_HAL_LPC1768_sw_spi_fn // use LPC1768 specific software SPI routine - #define U8G_COM_ST7920_HW_SPI u8g_com_HAL_LPC1768_ST7920_hw_spi_fn - #define U8G_COM_ST7920_SW_SPI u8g_com_HAL_LPC1768_ST7920_sw_spi_fn - #define U8G_COM_SSD_I2C u8g_com_HAL_LPC1768_ssd_hw_i2c_fn +// connect U8g com generic com names to the desired driver +#define U8G_COM_HW_SPI u8g_com_HAL_LPC1768_hw_spi_fn // use LPC1768 specific hardware SPI routine +#define U8G_COM_SW_SPI u8g_com_HAL_LPC1768_sw_spi_fn // use LPC1768 specific software SPI routine +#define U8G_COM_ST7920_HW_SPI u8g_com_HAL_LPC1768_ST7920_hw_spi_fn +#define U8G_COM_ST7920_SW_SPI u8g_com_HAL_LPC1768_ST7920_sw_spi_fn +#define U8G_COM_SSD_I2C u8g_com_HAL_LPC1768_ssd_hw_i2c_fn - // let these default for now - #define U8G_COM_PARALLEL u8g_com_null_fn - #define U8G_COM_T6963 u8g_com_null_fn - #define U8G_COM_FAST_PARALLEL u8g_com_null_fn - #define U8G_COM_UC_I2C u8g_com_null_fn - -#endif +// let these default for now +#define U8G_COM_PARALLEL u8g_com_null_fn +#define U8G_COM_T6963 u8g_com_null_fn +#define U8G_COM_FAST_PARALLEL u8g_com_null_fn +#define U8G_COM_UC_I2C u8g_com_null_fn diff --git a/Marlin/src/HAL/HAL_LPC1768/LPC_SPI.h b/Marlin/src/HAL/HAL_LPC1768/LPC_SPI.h index 3682516728..281d1ca2d4 100644 --- a/Marlin/src/HAL/HAL_LPC1768/LPC_SPI.h +++ b/Marlin/src/HAL/HAL_LPC1768/LPC_SPI.h @@ -19,6 +19,7 @@ * along with this program. If not, see . * */ + #pragma once #ifdef TARGET_LPC1768 #include diff --git a/Marlin/src/HAL/HAL_LPC1768/main.cpp b/Marlin/src/HAL/HAL_LPC1768/main.cpp index 4f3d2f36a1..681f2b9fc7 100644 --- a/Marlin/src/HAL/HAL_LPC1768/main.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/main.cpp @@ -116,9 +116,7 @@ int main(void) { LPC1768_PWM_init(); setup(); - while (true) { - loop(); - } + for (;;) loop(); } #endif // TARGET_LPC1768 diff --git a/Marlin/src/HAL/HAL_LPC1768/u8g_com_HAL_LPC1768_hw_spi.cpp b/Marlin/src/HAL/HAL_LPC1768/u8g_com_HAL_LPC1768_hw_spi.cpp index 53a4f3454a..d5b915ea69 100644 --- a/Marlin/src/HAL/HAL_LPC1768/u8g_com_HAL_LPC1768_hw_spi.cpp +++ b/Marlin/src/HAL/HAL_LPC1768/u8g_com_HAL_LPC1768_hw_spi.cpp @@ -59,10 +59,10 @@ #ifdef TARGET_LPC1768 -// #include + //#include -// #include "src/core/macros.h" -// #include "Configuration.h" + //#include "src/core/macros.h" + //#include "Configuration.h" #include