diff --git a/drivers/analog/pga11x.c b/drivers/analog/pga11x.c index 3a8e551afde..81a96483071 100644 --- a/drivers/analog/pga11x.c +++ b/drivers/analog/pga11x.c @@ -15,7 +15,7 @@ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. - **************************************************************************** + ****************************************************************************/ /**************************************************************************** * References: diff --git a/drivers/audio/wm8994.c b/drivers/audio/wm8994.c index a07cac7c8c5..cf2d62cf5dc 100644 --- a/drivers/audio/wm8994.c +++ b/drivers/audio/wm8994.c @@ -1,4 +1,4 @@ -/*********************************************************************************** +/**************************************************************************** * drivers/audio/wm8994.c * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,11 +16,11 @@ * License for the specific language governing permissions and limitations * under the License. * - ***********************************************************************************/ + ****************************************************************************/ -/*********************************************************************************** +/**************************************************************************** * Included Files - ***********************************************************************************/ + ****************************************************************************/ #include @@ -73,9 +73,9 @@ #define WM8994_DEFAULT_INPUT_DEVICE (WM8994_INPUT_DEVICE_DIGITAL_MIC1_MIC2) #define WM8994_STARTUP_MODE_COLD (1) -/*********************************************************************************** +/**************************************************************************** * Private Function Prototypes - ***********************************************************************************/ + ****************************************************************************/ #if !defined(CONFIG_WM8994_REGDUMP) && !defined(CONFIG_WM8994_CLKDEBUG) static @@ -837,7 +837,8 @@ static int wm8994_stop(FAR struct audio_lowerhalf_s *dev) term_msg.msg_id = AUDIO_MSG_STOP; term_msg.u.data = 0; - (void)file_mq_send(&priv->mq, (FAR const char *)&term_msg, sizeof(term_msg), + (void)file_mq_send(&priv->mq, (FAR const char *)&term_msg, + sizeof(term_msg), CONFIG_WM8994_MSG_PRIO); /* Join the worker thread */ @@ -939,9 +940,10 @@ static int wm8994_enqueuebuffer(FAR struct audio_lowerhalf_s *dev, dq_addlast(&apb->dq_entry, &priv->pendq); wm8994_givesem(&priv->pendsem); - /* Send a message to the worker thread indicating that a new buffer has been - * enqueued. If mq is NULL, then the playing has not yet started. In that - * case we are just "priming the pump" and we don't need to send any message. + /* Send a message to the worker thread indicating that a new buffer has + * been enqueued. If mq is NULL, then the playing has not yet started. + * In that case we are just "priming the pump" and we don't need to send + * any message. */ ret = OK; @@ -1256,7 +1258,8 @@ static void *wm8994_workerthread(pthread_addr_t pvarg) /* Wait for messages from our message queue */ - msglen = file_mq_receive(&priv->mq, (FAR char *)&msg, sizeof(msg), &prio); + msglen = file_mq_receive(&priv->mq, (FAR char *)&msg, + sizeof(msg), &prio); /* Handle the case when we return with no message */ @@ -1587,7 +1590,8 @@ static void wm8994_hw_reset(FAR struct wm8994_dev_s *priv) wm8994_writereg(priv, WM8994_DAC2_RIGHT_MIXER_ROUTING, regval); break; case WM8994_OUTPUT_DEVICE_BOTH: - if (WM8994_DEFAULT_INPUT_DEVICE == WM8994_INPUT_DEVICE_DIGITAL_MIC1_MIC2) + if (WM8994_DEFAULT_INPUT_DEVICE == + WM8994_INPUT_DEVICE_DIGITAL_MIC1_MIC2) { wm8994_writereg(priv, 0x005, 0x0303 | 0x0c0c); wm8994_writereg(priv, 0x601, 0x0003); @@ -1924,9 +1928,9 @@ static void wm8994_hw_reset(FAR struct wm8994_dev_s *priv) wm8994_clock_analysis(&priv->dev, "After configuration"); } -/*********************************************************************************** +/**************************************************************************** * Public Functions - ***********************************************************************************/ + ****************************************************************************/ /* Name: wm8994_initialize * diff --git a/drivers/audio/wm8994.h b/drivers/audio/wm8994.h index 3f8de0e6050..42864982ae9 100644 --- a/drivers/audio/wm8994.h +++ b/drivers/audio/wm8994.h @@ -1,4 +1,4 @@ -/*************************************************************************************************** +/**************************************************************************** * drivers/audio/wm8994.h * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,14 +16,14 @@ * License for the specific language governing permissions and limitations * under the License. * - ***************************************************************************************************/ + ****************************************************************************/ #ifndef __DRIVERS_AUDIO_WM8994_H #define __DRIVERS_AUDIO_WM8994_H -/*************************************************************************************************** +/**************************************************************************** * Included Files - ***************************************************************************************************/ + ****************************************************************************/ #include #include @@ -36,9 +36,9 @@ #ifdef CONFIG_AUDIO -/*************************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - ***************************************************************************************************/ + ****************************************************************************/ /* So far, I have not been able to get FLL lock interrupts. Worse, I have * been able to get the FLL to claim that it is locked at all even when @@ -590,7 +590,7 @@ #define WM8994_IN2L_MUTE_ENABLE (WM8994_IN2L_MUTE) /* Enabled */ #define WM8994_IN2_VU (1 << 8) /* Bit 8: Input PGA Voluem Update. Writing a 1 to this bit cause IN2L and IN2R input PGA volumes to updated simultaneously */ - /* Bits 9-15: Reserved */ + /* Bits 9-15: Reserved */ /* R26 (0x1A) - Right Line Input 1&2 Volume */ @@ -785,7 +785,7 @@ /* R57 (0x39) - AntiPOP (2) */ - /* Bits 8-15: Reserved */ + /* Bits 8-15: Reserved */ #define WM8994_MICB2_DISCH (1 << 8) /* Bit 7: Microphone Bias 2 Discharge */ #define WM8994_MICB2_DISCH_FLOAT (0) /* MICBIAS2 floating when disabled */ #define WM8994_MICB2_DISCH_DISCHARGED WM8994_MICB2_DISCH /* MICBIAS2 disharged when disabled */ @@ -1549,9 +1549,9 @@ # define MAX(a,b) (((a) > (b)) ? (a) : (b)) #endif -/*************************************************************************************************** +/**************************************************************************** * Public Types - ***************************************************************************************************/ + ****************************************************************************/ struct wm8994_dev_s { @@ -1559,9 +1559,9 @@ struct wm8994_dev_s * the WM8994 driver with respect to the board lower half driver). * * Terminology: Our "lower" half audio instances will be called dev for the - * publicly visible version and "priv" for the version that only this driver - * knows. From the point of view of this driver, it is the board lower - * "half" that is referred to as "lower". + * publicly visible version and "priv" for the version that only this + * driver knows. From the point of view of this driver, it is the board + * lower "half" that is referred to as "lower". */ struct audio_lowerhalf_s dev; /* WM8994 audio lower half (this device) */ @@ -1605,26 +1605,26 @@ struct wm8994_dev_s uint16_t power_mgnt_reg_1; }; -/*************************************************************************************************** +/**************************************************************************** * Public Data - ***************************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_WM8994_CLKDEBUG extern const uint8_t g_sysclk_scaleb1[WM8994_BCLK_MAXDIV + 1]; extern const uint8_t g_fllratio[WM8994_NFLLRATIO]; #endif -/*************************************************************************************************** +/**************************************************************************** * Public Function Prototypes - ***************************************************************************************************/ + ****************************************************************************/ -/*************************************************************************************************** +/**************************************************************************** * Name: wm8994_readreg * * Description: * Read the specified 16-bit register from the WM8994 device. * - ***************************************************************************************************/ + ****************************************************************************/ #if defined(CONFIG_WM8994_REGDUMP) || defined(CONFIG_WM8994_CLKDEBUG) struct wm8994_dev_s; diff --git a/drivers/audio/wm8994_debug.c b/drivers/audio/wm8994_debug.c index 3386136d0a3..6dbdc80230b 100644 --- a/drivers/audio/wm8994_debug.c +++ b/drivers/audio/wm8994_debug.c @@ -1,4 +1,4 @@ -/***************************************************************************************** +/**************************************************************************** * drivers/audio/wm8994_debug.c * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,11 +16,11 @@ * License for the specific language governing permissions and limitations * under the License. * - *****************************************************************************************/ + ****************************************************************************/ -/***************************************************************************************** +/**************************************************************************** * Included Files - *****************************************************************************************/ + ****************************************************************************/ #include @@ -34,13 +34,13 @@ #include "wm8994.h" -/***************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - *****************************************************************************************/ + ****************************************************************************/ -/***************************************************************************************** +/**************************************************************************** * Private Types - *****************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_WM8994_REGDUMP struct wb8994_regdump_s @@ -50,13 +50,13 @@ struct wb8994_regdump_s }; #endif -/***************************************************************************************** +/**************************************************************************** * Private Function Prototypes - *****************************************************************************************/ + ****************************************************************************/ -/***************************************************************************************** +/**************************************************************************** * Private Data - *****************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_WM8994_REGDUMP static const struct wb8994_regdump_s g_wm8994_debug[] = @@ -291,15 +291,15 @@ static const struct wb8994_regdump_s g_wm8994_debug[] = # define WM8994_NREGISTERS (sizeof(g_wm8994_debug)/sizeof(struct wb8994_regdump_s)) #endif /* CONFIG_WM8994_REGDUMP */ -/***************************************************************************************** +/**************************************************************************** * Private Functions - *****************************************************************************************/ + ****************************************************************************/ -/***************************************************************************************** +/**************************************************************************** * Public Functions - *****************************************************************************************/ + ****************************************************************************/ -/***************************************************************************************** +/**************************************************************************** * Name: wm8994_dump_registers * * Description: @@ -311,7 +311,7 @@ static const struct wb8994_regdump_s g_wm8994_debug[] = * Returned Value: * None. * - *****************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_WM8994_REGDUMP void wm8994_dump_registers(FAR struct audio_lowerhalf_s *dev, @@ -330,7 +330,7 @@ void wm8994_dump_registers(FAR struct audio_lowerhalf_s *dev, } #endif /* CONFIG_WM8994_REGDUMP */ -/***************************************************************************************** +/**************************************************************************** * Name: wm8994_clock_analysis * * Description: @@ -342,7 +342,7 @@ void wm8994_dump_registers(FAR struct audio_lowerhalf_s *dev, * Returned Value: * None. * - *****************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_WM8994_CLKDEBUG void wm8994_clock_analysis(FAR struct audio_lowerhalf_s *dev, @@ -442,8 +442,10 @@ void wm8994_clock_analysis(FAR struct audio_lowerhalf_s *dev, regval = wm8994_readreg(priv, WM8994_FLL_CTRL2); frndx = (regval & WM8994_FLL_FRATIO_MASK) >> WM8994_FLL_FRATIO_SHIFT; - tmp = (regval & WM8994_FLL_CTRL_RATE_MASK) >> WM8994_FLL_CTRL_RATE_SHIFT; - outdiv = ((regval & WM8994_FLL_OUTDIV_MASK) >> WM8994_FLL_OUTDIV_SHIFT) + 1; + tmp = (regval & WM8994_FLL_CTRL_RATE_MASK) >> + WM8994_FLL_CTRL_RATE_SHIFT; + outdiv = ((regval & WM8994_FLL_OUTDIV_MASK) >> + WM8994_FLL_OUTDIV_SHIFT) + 1; syslog(LOG_INFO, " FLL_CTRL_RATE: Fvco / %u\n", tmp + 1); @@ -501,7 +503,8 @@ void wm8994_clock_analysis(FAR struct audio_lowerhalf_s *dev, sysclk >>= 1; } - syslog(LOG_INFO, " SYSCLK: %lu (after divider)\n", (unsigned long)sysclk); + syslog(LOG_INFO, " SYSCLK: %lu (after divider)\n", + (unsigned long)sysclk); regval = wm8994_readreg(priv, WM8994_CLKRATE2); diff --git a/drivers/bch/bchdev_driver.c b/drivers/bch/bchdev_driver.c index 2118cf8a20a..50e9102bac7 100644 --- a/drivers/bch/bchdev_driver.c +++ b/drivers/bch/bchdev_driver.c @@ -433,7 +433,9 @@ static int bch_ioctl(FAR struct file *filep, int cmd, unsigned long arg) break; #endif - /* Otherwise, pass the IOCTL command on to the contained block driver. */ + /* Otherwise, pass the IOCTL command on to the contained block + * driver. + */ default: { diff --git a/drivers/input/ads7843e.h b/drivers/input/ads7843e.h index ea2f1341ea7..2c12b55b843 100644 --- a/drivers/input/ads7843e.h +++ b/drivers/input/ads7843e.h @@ -1,4 +1,4 @@ -/******************************************************************************************** +/**************************************************************************** * drivers/input/ads7843e.h * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,7 +16,7 @@ * License for the specific language governing permissions and limitations * under the License. * - ********************************************************************************************/ + ****************************************************************************/ /* References: * "Touch Screen Controller, ADS7843," Burr-Brown Products from Texas @@ -32,9 +32,9 @@ #ifndef __DRIVERS_INPUT_ADS7843E_H #define __DRIVERS_INPUT_ADS7843E_H -/******************************************************************************************** +/**************************************************************************** * Included Files - ********************************************************************************************/ + ****************************************************************************/ #include @@ -48,17 +48,19 @@ #include #include -/******************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - ********************************************************************************************/ + ****************************************************************************/ -/* Configuration ****************************************************************************/ +/* Configuration ************************************************************/ -/* Reference counting is partially implemented, but not needed in the current design. */ +/* Reference counting is partially implemented, but not needed in the current + * design. + */ #undef CONFIG_ADS7843E_REFCNT -/* ADS7843E Interfaces **********************************************************************/ +/* ADS7843E Interfaces ******************************************************/ /* ADS7843E command bit settings */ @@ -79,7 +81,7 @@ #define ADS7843_CMD_ENABPENIRQ \ ((1 << ADS7843E_CMD_CHAN_SHIFT)| ADS7843E_CMD_START) -/* Driver support ***************************************************************************/ +/* Driver support ***********************************************************/ /* This format is used to construct the /dev/input[n] device driver path. It * defined here so that it will be used consistently in all places. @@ -92,9 +94,9 @@ #define ADS7843E_WDOG_DELAY MSEC2TICK(50) -/******************************************************************************************** +/**************************************************************************** * Public Types - ********************************************************************************************/ + ****************************************************************************/ /* This describes the state of one contact */ @@ -149,9 +151,9 @@ struct ads7843e_dev_s struct pollfd *fds[CONFIG_ADS7843E_NPOLLWAITERS]; }; -/******************************************************************************************** +/**************************************************************************** * Public Function Prototypes - ********************************************************************************************/ + ****************************************************************************/ #ifdef __cplusplus #define EXTERN extern "C" diff --git a/drivers/input/ajoystick.c b/drivers/input/ajoystick.c index 6237d42b883..80e91803009 100644 --- a/drivers/input/ajoystick.c +++ b/drivers/input/ajoystick.c @@ -576,7 +576,8 @@ static int ajoy_ioctl(FAR struct file *filep, int cmd, unsigned long arg) switch (cmd) { /* Command: AJOYIOC_SUPPORTED - * Description: Report the set of button events supported by the hardware; + * Description: Report the set of button events supported by the + * hardware; * Argument: A pointer to writeable integer value in which to return * the set of supported buttons. * Return: Zero (OK) on success. Minus one will be returned on @@ -782,7 +783,6 @@ errout_with_dusem: int ajoy_register(FAR const char *devname, FAR const struct ajoy_lowerhalf_s *lower) - { FAR struct ajoy_upperhalf_s *priv; int ret; diff --git a/drivers/input/max11802.h b/drivers/input/max11802.h index 4a4301de0b7..a880003a616 100644 --- a/drivers/input/max11802.h +++ b/drivers/input/max11802.h @@ -1,4 +1,4 @@ -/******************************************************************************************** +/**************************************************************************** * drivers/input/max11802.h * * Copyright (C) 2011-2012, 2014 Gregory Nutt. All rights reserved. @@ -32,7 +32,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ********************************************************************************************/ + ****************************************************************************/ /* References: * "Low-Power, Ultra-Small Resistive Touch-Screen Controllers @@ -42,9 +42,9 @@ #ifndef __DRIVERS_INPUT_MAX11802_H #define __DRIVERS_INPUT_MAX11802_H -/******************************************************************************************** +/**************************************************************************** * Included Files - ********************************************************************************************/ + ****************************************************************************/ #include @@ -58,11 +58,11 @@ #include #include -/******************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - ********************************************************************************************/ + ****************************************************************************/ -/* MAX11802 Interfaces **********************************************************************/ +/* MAX11802 Interfaces ******************************************************/ /* LSB of register addresses specifies read (1) or write (0). */ @@ -86,7 +86,7 @@ #define MAX11802_DELAY 0x55 #define MAX11802_PULL 0x33 -/* Driver support ***************************************************************************/ +/* Driver support ***********************************************************/ /* This format is used to construct the /dev/input[n] device driver path. It * defined here so that it will be used consistently in all places. @@ -99,9 +99,9 @@ #define MAX11802_WDOG_DELAY MSEC2TICK(50) -/******************************************************************************************** +/**************************************************************************** * Public Types - ********************************************************************************************/ + ****************************************************************************/ /* This describes the state of one contact */ @@ -153,9 +153,9 @@ struct max11802_dev_s struct pollfd *fds[CONFIG_MAX11802_NPOLLWAITERS]; }; -/******************************************************************************************** +/**************************************************************************** * Public Function Prototypes - ********************************************************************************************/ + ****************************************************************************/ #ifdef __cplusplus #define EXTERN extern "C" diff --git a/drivers/input/mxt.h b/drivers/input/mxt.h index fc81ac776fa..2ac01f1e753 100644 --- a/drivers/input/mxt.h +++ b/drivers/input/mxt.h @@ -240,6 +240,7 @@ /**************************************************************************** * Public Types ****************************************************************************/ + /* This structure describes one maXTouch object */ struct mxt_object_s diff --git a/drivers/input/stmpe811.h b/drivers/input/stmpe811.h index f0a0b1df856..5a519849fe8 100644 --- a/drivers/input/stmpe811.h +++ b/drivers/input/stmpe811.h @@ -1,4 +1,4 @@ -/******************************************************************************************** +/**************************************************************************** * drivers/input/stmpe811.h * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,7 +16,7 @@ * License for the specific language governing permissions and limitations * under the License. * - ********************************************************************************************/ + ****************************************************************************/ /* References: * "STMPE811 S-Touch advanced resistive touchscreen controller with 8-bit @@ -26,9 +26,9 @@ #ifndef __DRIVERS_INPUT_STMPE811_H #define __DRIVERS_INPUT_STMPE811_H -/******************************************************************************************** +/**************************************************************************** * Included Files - ********************************************************************************************/ + ****************************************************************************/ #include @@ -40,26 +40,29 @@ #if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_STMPE811) -/******************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - ********************************************************************************************/ + ****************************************************************************/ -/* Configuration ****************************************************************************/ +/* Configuration ************************************************************/ -/* Reference counting is partially implemented, but not needed in the current design. */ +/* Reference counting is partially implemented, but not needed in the current + * design. + */ #undef CONFIG_STMPE811_REFCNT -/* Driver support ***************************************************************************/ +/* Driver support ***********************************************************/ -/* This format is used to construct the /dev/input[n] device driver path. It defined here - * so that it will be used consistently in all places. +/* This format is used to construct the /dev/input[n] device driver path. + * It defined here so that it will be used consistently in all places. */ #define DEV_FORMAT "/dev/input%d" #define DEV_NAMELEN 16 -/* STMPE811 Resources ***********************************************************************/ +/* STMPE811 Resources *******************************************************/ + #ifndef CONFIG_STMPE811_TSC_DISABLE # define STMPE811_ADC_NPINS 4 /* Only pins 0-3 can be used for ADC */ # define STMPE811_GPIO_NPINS 4 /* Only pins 0-3 can be used as GPIOs */ @@ -79,9 +82,9 @@ #define STMPE811_PENUP_TICKS MSEC2TICK(100) -/******************************************************************************************** +/**************************************************************************** * Public Types - ********************************************************************************************/ + ****************************************************************************/ /* This describes the state of one contact */ @@ -127,7 +130,9 @@ struct stmpe811_dev_s uint8_t flags; /* See STMPE811_FLAGS_* definitions */ struct work_s work; /* Supports the interrupt handling "bottom half" */ - /* Fields that may be disabled to save size if touchscreen support is not used. */ + /* Fields that may be disabled to save size if touchscreen support + * is not used. + */ #ifndef CONFIG_STMPE811_TSC_DISABLE #ifdef CONFIG_STMPE811_REFCNT @@ -161,61 +166,63 @@ struct stmpe811_dev_s #endif }; -/******************************************************************************************** +/**************************************************************************** * Public Function Prototypes - ********************************************************************************************/ + ****************************************************************************/ -/******************************************************************************************** +/**************************************************************************** * Name: stmpe811_getreg8 * * Description: * Read from an 8-bit STMPE811 register * - ********************************************************************************************/ + ****************************************************************************/ uint8_t stmpe811_getreg8(FAR struct stmpe811_dev_s *priv, uint8_t regaddr); -/******************************************************************************************** +/**************************************************************************** * Name: stmpe811_putreg8 * * Description: * Write a value to an 8-bit STMPE811 register * - ********************************************************************************************/ + ****************************************************************************/ -void stmpe811_putreg8(FAR struct stmpe811_dev_s *priv, uint8_t regaddr, uint8_t regval); +void stmpe811_putreg8(FAR struct stmpe811_dev_s *priv, + uint8_t regaddr, uint8_t regval); -/******************************************************************************************** +/**************************************************************************** * Name: stmpe811_getreg16 * * Description: * Read 16-bits of data from an STMPE-11 register * - ********************************************************************************************/ + ****************************************************************************/ uint16_t stmpe811_getreg16(FAR struct stmpe811_dev_s *priv, uint8_t regaddr); -/******************************************************************************************** +/**************************************************************************** * Name: stmpe811_tscint * * Description: - * Handle touchscreen interrupt events (this function actually executes in the context of - * the worker thread). + * Handle touchscreen interrupt events (this function actually executes in + * the context of the worker thread). * - ********************************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_STMPE811_TSC_DISABLE -void stmpe811_tscworker(FAR struct stmpe811_dev_s *priv, uint8_t intsta) weak_function; +void stmpe811_tscworker(FAR struct stmpe811_dev_s *priv, + uint8_t intsta) weak_function; #endif -/******************************************************************************************** +/**************************************************************************** * Name: stmpe811_gpioworker * * Description: - * Handle GPIO interrupt events (this function actually executes in the context of the - * worker thread). + * Handle GPIO interrupt events (this function actually executes in the + * context of the worker thread). * - ********************************************************************************************/ + ****************************************************************************/ #if !defined(CONFIG_STMPE811_GPIO_DISABLE) && !defined(CONFIG_STMPE811_GPIOINT_DISABLE) void stmpe811_gpioworker(FAR struct stmpe811_dev_s *priv) weak_function; diff --git a/drivers/input/stmpe811_temp.c b/drivers/input/stmpe811_temp.c index d5076edb325..8c7bff3f573 100644 --- a/drivers/input/stmpe811_temp.c +++ b/drivers/input/stmpe811_temp.c @@ -124,7 +124,7 @@ uint16_t stmpe811_tempread(STMPE811_HANDLE handle) /* Read the temperature */ temp1 = stmpe811_getreg8(priv, STMPE811_SYS_CTRL2); - temp2 = stmpe811_getreg8(priv, STMPE811_SYS_CTRL2+1); + temp2 = stmpe811_getreg8(priv, STMPE811_SYS_CTRL2 + 1); add_sensor_randomness((temp1 << 8) | temp2); @@ -159,6 +159,7 @@ uint16_t stmpe811_tempread(STMPE811_HANDLE handle) * returned to indicate the nature of the failure. * ****************************************************************************/ + /* Not implemented */ #endif /* CONFIG_INPUT && CONFIG_INPUT_STMPE811 && !CONFIG_STMPE811_TEMP_DISABLE */ diff --git a/drivers/input/tsc2007.h b/drivers/input/tsc2007.h index cee802492a6..99290c2d12e 100644 --- a/drivers/input/tsc2007.h +++ b/drivers/input/tsc2007.h @@ -1,4 +1,4 @@ -/******************************************************************************************** +/**************************************************************************** * drivers/input/tsc2007.h * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,11 +16,12 @@ * License for the specific language governing permissions and limitations * under the License. * - ********************************************************************************************/ + ****************************************************************************/ -/* The TSC2007 is an analog interface circuit for a human interface touch screen device. - * All peripheral functions are controlled through the command byte and onboard state - * machines. +/* The TSC2007 is an analog interface circuit for a human interface touch + * screen device. + * All peripheral functions are controlled through the command byte and + * onboard state machines. */ /* References: @@ -32,13 +33,13 @@ #ifndef __DRIVERS_INPUT_TSC2007_H #define __DRIVERS_INPUT_TSC2007_H -/******************************************************************************************** +/**************************************************************************** * Included Files - ********************************************************************************************/ + ****************************************************************************/ -/******************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - ********************************************************************************************/ + ****************************************************************************/ /* TSC2007 Address */ @@ -52,6 +53,7 @@ /* TSC2007 Command Byte */ #define TSC2007_CMD_FUNC_SHIFT (4) /* Bits 4-7: Converter function select bits */ + #define TSC2007_CMD_FUNC_MASK (15 << TSC2007_CMD_FUNC_SHIFT) # define TSC2007_CMD_FUNC_TEMP0 (0 << TSC2007_CMD_FUNC_SHIFT) /* Measure TEMP0 */ # define TSC2007_CMD_FUNC_AUX (2 << TSC2007_CMD_FUNC_SHIFT) /* Measure AUX */ @@ -64,12 +66,14 @@ # define TSC2007_CMD_FUNC_YPOS (13 << TSC2007_CMD_FUNC_SHIFT) /* Measure Y position */ # define TSC2007_CMD_FUNC_Z1POS (14 << TSC2007_CMD_FUNC_SHIFT) /* Measure Z1 position */ # define TSC2007_CMD_FUNC_Z2POS (15 << TSC2007_CMD_FUNC_SHIFT) /* Measure Z2 position */ + #define TSC2007_CMD_PWRDN_SHIFT (2) /* Bits 2-3: Power-down bits */ #define TSC2007_CMD_PWRDN_MASK (3 << TSC2007_CMD_PWRDN_SHIFT) # define TSC2007_CMD_PWRDN_IRQEN (0 << TSC2007_CMD_PWRDN_SHIFT) /* 00: Power down between cycles; PENIRQ enabled */ # define TSC2007_CMD_ADCON_IRQDIS (1 << TSC2007_CMD_PWRDN_SHIFT) /* 01: A/D converter on; PENIRQ disabled */ # define TSC2007_CMD_ADCOFF_IRQEN (2 << TSC2007_CMD_PWRDN_SHIFT) /* 10: A/D converter off; PENIRQ enabled. */ /* 11: A/D converter on; PENIRQ disabled. */ + #define TSC2007_CMD_12BIT (0) /* Bit 1: 0=12-bit */ #define TSC2007_CMD_8BIT (1 << 1) /* Bit 1: 1=8-bit */ /* Bit 0: Don't care */ @@ -77,19 +81,20 @@ /* TSC2007 Setup Command */ #define TSC2007_SETUP_CMD TSC2007_CMD_FUNC_SETUP /* Bits 4-7: Setup command */ + /* Bits 2-3: Must be zero */ #define TSC2007_CMD_USEMAV (0) /* Bit 1: 0: Use the onboard MAV filter (default) */ #define TSC2007_CMD_BYPASSMAV (1 << 1) /* Bit 1: 1: Bypass the onboard MAV filter */ #define TSC2007_CMD_PU_50KOHM (0) /* Bit 0: 0: RIRQ = 50kOhm (default). */ #define TSC2007_CMD_PU_90KOHM (1 << 1) /* Bit 0: 1: 1: RIRQ = 90kOhm */ -/******************************************************************************************** +/**************************************************************************** * Public Types - ********************************************************************************************/ + ****************************************************************************/ -/******************************************************************************************** +/**************************************************************************** * Public Function Prototypes - ********************************************************************************************/ + ****************************************************************************/ #ifdef __cplusplus #define EXTERN extern "C" diff --git a/drivers/ioexpander/pca9555.h b/drivers/ioexpander/pca9555.h index 62595b8609f..367d588aa8e 100644 --- a/drivers/ioexpander/pca9555.h +++ b/drivers/ioexpander/pca9555.h @@ -1,4 +1,4 @@ -/******************************************************************************************** +/**************************************************************************** * drivers/ioexpander/pca9555.h * * Copyright (C) 2015 Gregory Nutt. All rights reserved. @@ -35,14 +35,14 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ********************************************************************************************/ + ****************************************************************************/ #ifndef __DRIVERS_IOEXPANDER_PCA9555_H #define __DRIVERS_IOEXPANDER_PCA9555_H -/******************************************************************************************** +/**************************************************************************** * Included Files - ********************************************************************************************/ + ****************************************************************************/ #include @@ -58,9 +58,9 @@ #if defined(CONFIG_IOEXPANDER) && defined(CONFIG_IOEXPANDER_PCA9555) -/******************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - ********************************************************************************************/ + ****************************************************************************/ /* Configuration ************************************************************/ @@ -122,19 +122,19 @@ #define PCA9555_REG_POLINV 0x04 #define PCA9555_REG_CONFIG 0x06 -/******************************************************************************************** +/**************************************************************************** * Public Types - ********************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_IOEXPANDER_INT_ENABLE /* This type represents on registered pin interrupt callback */ struct pca9555_callback_s { - ioe_pinset_t pinset; /* Set of pin interrupts that will generate - * the callback. */ - ioe_callback_t cbfunc; /* The saved callback function pointer */ - FAR void *cbarg; /* Callback argument */ + ioe_pinset_t pinset; /* Set of pin interrupts that will generate + * the callback. */ + ioe_callback_t cbfunc; /* The saved callback function pointer */ + FAR void *cbarg; /* Callback argument */ }; #endif diff --git a/drivers/ioexpander/pcf8574.h b/drivers/ioexpander/pcf8574.h index dc5c1b26b76..af6bc024fce 100644 --- a/drivers/ioexpander/pcf8574.h +++ b/drivers/ioexpander/pcf8574.h @@ -1,4 +1,4 @@ -/******************************************************************************************** +/**************************************************************************** * drivers/ioexpander/pcf8574.h * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,14 +16,14 @@ * License for the specific language governing permissions and limitations * under the License. * - ********************************************************************************************/ + ****************************************************************************/ #ifndef __DRIVERS_IOEXPANDER_PCF8574_H #define __DRIVERS_IOEXPANDER_PCF8574_H -/******************************************************************************************** +/**************************************************************************** * Included Files - ********************************************************************************************/ + ****************************************************************************/ #include @@ -39,9 +39,9 @@ #if defined(CONFIG_IOEXPANDER) && defined(CONFIG_IOEXPANDER_PCF8574) -/******************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - ********************************************************************************************/ + ****************************************************************************/ /* Configuration ************************************************************/ @@ -105,9 +105,9 @@ #define PCF8574_EDGE_BOTH(d,p) \ (PCF8574_LEVEL_RISING(d,p) && PCF8574_LEVEL_FALLING(d,p)) -/******************************************************************************************** +/**************************************************************************** * Public Types - ********************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_IOEXPANDER_INT_ENABLE /* This type represents on registered pin interrupt callback */ diff --git a/drivers/ioexpander/tca64xx.h b/drivers/ioexpander/tca64xx.h index 9ae5c54b757..11d97d054d9 100644 --- a/drivers/ioexpander/tca64xx.h +++ b/drivers/ioexpander/tca64xx.h @@ -1,4 +1,4 @@ -/******************************************************************************************** +/**************************************************************************** * drivers/ioexpander/tca64.h * * Copyright (C) 2016 Gregory Nutt. All rights reserved. @@ -35,14 +35,14 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ********************************************************************************************/ + ****************************************************************************/ #ifndef __DRIVERS_IOEXPANDER_TCA64XX_H #define __DRIVERS_IOEXPANDER_TCA64XX_H -/******************************************************************************************** +/**************************************************************************** * Included Files - ********************************************************************************************/ + ****************************************************************************/ #include @@ -58,11 +58,11 @@ #if defined(CONFIG_IOEXPANDER) && defined(CONFIG_IOEXPANDER_TCA64XX) -/******************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - ********************************************************************************************/ + ****************************************************************************/ -/* Configuration ****************************************************************************/ +/* Configuration ************************************************************/ /* Prerequisites: * CONFIG_I2C @@ -103,13 +103,13 @@ # define CONFIG_TCA64XX_INT_POLLDELAY 500000 #endif -/* TCA64XX Definitions **********************************************************************/ +/* TCA64XX Definitions ******************************************************/ /* I2C frequency */ #define TCA64XX_I2C_MAXFREQUENCY 400000 /* 400KHz */ -/* TCA64XX Parts ****************************************************************************/ +/* TCA64XX Parts ************************************************************/ #define TCA6408_INPUT_REG 0x00 #define TCA6408_OUTPUT_REG 0x01 @@ -181,9 +181,9 @@ #define TCA64_EDGE_BOTH(d,p) \ (TCA64_LEVEL_RISING(d,p) && TCA64_LEVEL_FALLING(d,p)) -/******************************************************************************************** +/**************************************************************************** * Public Types - ********************************************************************************************/ + ****************************************************************************/ /* This structure represents the configuration of one part */ diff --git a/drivers/lcd/ft80x.h b/drivers/lcd/ft80x.h index e12e3794f1a..4adc3ba7da1 100644 --- a/drivers/lcd/ft80x.h +++ b/drivers/lcd/ft80x.h @@ -1,4 +1,4 @@ -/******************************************************************************************* +/**************************************************************************** * drivers/lcd/ft80x.h * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,38 +16,42 @@ * License for the specific language governing permissions and limitations * under the License. * - *******************************************************************************************/ + ****************************************************************************/ /* Definitions for the FTDI FT80x GUI * * References: - * - Document No.: FT_000792, "FT800 Embedded Video Engine", Datasheet Version 1.1, - * Clearance No.: FTDI# 334, Future Technology Devices International Ltd. - * - Document No.: FT_000986, "FT801 Embedded Video Engine Datasheet", Version 1.0, - * Clearance No.: FTDI#376, Future Technology Devices International Ltd. + * - Document No.: + * FT_000792, "FT800 Embedded Video Engine", Datasheet Version 1.1, + * Clearance No.: + * FTDI# 334, Future Technology Devices International Ltd. + * - Document No.: + * FT_000986, "FT801 Embedded Video Engine Datasheet", Version 1.0, + * Clearance No.: + * FTDI#376, Future Technology Devices International Ltd. * - Some definitions derive from FTDI sample code. */ #ifndef __DRIVERS_LCD_FT80X_H #define __DRIVERS_LCD_FT80X_H -/******************************************************************************************* +/**************************************************************************** * Included Files - *******************************************************************************************/ + ****************************************************************************/ #include #include #include -/******************************************************************************************* +/**************************************************************************** * Public Types - *******************************************************************************************/ + ****************************************************************************/ /* Host write command * - * For a SPI write command write transaction, the host writes a zero bit followed by a one - * bit, followed by the 5-bit command, followed by two bytes of zero. All data is streamed - * with a single chip select. + * For a SPI write command write transaction, the host writes a zero bit + * followed by a one bit, followed by the 5-bit command, followed by two + * bytes of zero. All data is streamed with a single chip select. * * I2C data format is equivalent (with obvious differences in bus protocol) */ @@ -59,11 +63,12 @@ struct ft80x_hostwrite_s uint8_t pad2; /* Zero */ }; -/* For SPI memory read transaction, the host sends two zero bits, followed by the 22-bit - * address. This is followed by a dummy byte. After the dummy byte, the FT80x responds to - * each host byte with read data bytes. +/* For SPI memory read transaction, the host sends two zero bits, followed + * by the 22-bit address. This is followed by a dummy byte. After the dummy + * byte, the FT80x responds to each host byte with read data bytes. * - * For I2C memory read transaction, bytes are packed in the I2C protocol as follow: + * For I2C memory read transaction, bytes are packed in the I2C protocol + * as follow: * * [start] * <00b+Address[21:16]> @@ -90,10 +95,11 @@ struct ft80x_i2cread_s uint8_t addrl; /* Address[7:0] */ }; -/* For SPI memory write transaction, the host sends a '1' bit and '0' bit, followed by the - * 22-bit address. This is followed by the write data. +/* For SPI memory write transaction, the host sends a '1' bit and '0' bit, + * followed by the 22-bit address. This is followed by the write data. * - * For I2C memory write transaction, bytes are packed in the I2C protocol as follow: + * For I2C memory write transaction, bytes are packed in the I2C protocol + * as follow: * * [start] * <10b,Address[21:16]> @@ -183,7 +189,7 @@ struct ft80x_dev_s }; /**************************************************************************** - * Public Functions + * Public Functions Definitions ****************************************************************************/ /**************************************************************************** diff --git a/drivers/lcd/mio283qt2.c b/drivers/lcd/mio283qt2.c index 0fa91d30053..d27f0d5190d 100644 --- a/drivers/lcd/mio283qt2.c +++ b/drivers/lcd/mio283qt2.c @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/mio283qt2.c * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,22 +16,23 @@ * License for the specific language governing permissions and limitations * under the License. * - **************************************************************************************/ + ****************************************************************************/ -/* This is a driver for the MI0283QT-2 LCD from Multi-Inno Technology Co., Ltd. This - * LCD is based on the Himax HX8347-D LCD controller. +/* This is a driver for the MI0283QT-2 LCD from Multi-Inno Technology Co., + * Ltd. This LCD is based on the Himax HX8347-D LCD controller. * * References: - * 1) LCD Module Specification, Model : MI0283QT-2, Multi-Inno Technology Co., - * Ltd., Revision 1.0 - * 2) Data Sheet: HX8347-D(T), 240RGB x 320 dot, 262K color, with internal GRAM, TFT - * Mobile Single Chip Driver Version 02 March, Doc No. HX8347-D(T)-DS, Himax - * Technologies, Inc., 2009, + * 1) LCD Module Specification, Model : + * MI0283QT-2, Multi-Inno Technology Co., Ltd., Revision 1.0 + * 2) Data Sheet: + * HX8347-D(T), 240RGB x 320 dot, 262K color, with internal GRAM, TFT + * Mobile Single Chip Driver Version 02 March, Doc No. HX8347-D(T)-DS, + * Himax Technologies, Inc., 2009, */ -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ #include @@ -49,10 +50,11 @@ #ifdef CONFIG_LCD_MIO283QT2 -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ -/* Configuration **********************************************************************/ + ****************************************************************************/ + +/* Configuration ************************************************************/ /* Check contrast selection */ @@ -107,25 +109,28 @@ /* Hardware LCD/LCD controller definitions **********************************/ -/* In this driver, I chose to use all literal constants for register address and - * values. Some recent experiences have shown me that during LCD bringup, it is more - * important to know the binary values rather than nice, people friendly names. Sad, - * but true. +/* In this driver, I chose to use all literal constants for register address + * and values. Some recent experiences have shown me that during LCD bringup, + * it is more important to know the binary values rather than nice, people + * friendly names. Sad, but true. */ #define HIMAX_ID 0x0047 /* LCD Profiles *************************************************************/ -/* Many details of the controller initialization must, unfortunately, vary from LCD to - * LCD. I have looked at the spec and at three different drivers for LCDs that have - * MIO283QT2 controllers. I have tried to summarize these differences as "LCD profiles" +/* Many details of the controller initialization must, unfortunately, vary + * from LCD to LCD. I have looked at the spec and at three different drivers + * for LCDs that have MIO283QT2 controllers. + * I have tried to summarize these differences as "LCD profiles" * * Most of the differences between LCDs are nothing more than a few minor bit * settings. The most significant difference between LCD drivers in is the - * manner in which the LCD is powered up and in how the power controls are set. - * My suggestion is that if you have working LCD initialization code, you should - * simply replace the code in mio283qt2_hwinitialize with your working code. + * manner in which the LCD is powered up and in how the power controls are + * set. + * My suggestion is that if you have working LCD initialization code, you + * should simply replace the code in mio283qt2_hwinitialize with your working + * code. */ #if defined (CONFIG_MIO283QT2_PROFILE2) @@ -142,16 +147,17 @@ # define PWRCTRL2_SETTING MIO283QT2_PWRCTRL2_VRC_5p1V /* PWRCTRL3: x 2.165 - * NOTE: Many drivers have bit 8 set which is not defined in the MIO283QT2 spec. + * NOTE: + * Many drivers have bit 8 set which is not defined in the MIO283QT2 spec. */ # define PWRCTRL3_SETTING MIO283QT2_PWRCTRL3_VRH_x2p165 - /* PWRCTRL4: VDV=9 + VCOMG */ + /* PWRCTRL4: VDV=9 + VCOMG */ # define PWRCTRL4_SETTING (MIO283QT2_PWRCTRL4_VDV(9) | MIO283QT2_PWRCTRL4_VCOMG) - /* PWRCTRL5: VCM=56 + NOTP */ + /* PWRCTRL5: VCM=56 + NOTP */ # define PWRCTRL5_SETTING (MIO283QT2_PWRCTRL5_VCM(56) | MIO283QT2_PWRCTRL5_NOTP) @@ -169,16 +175,17 @@ # define PWRCTRL2_SETTING MIO283QT2_PWRCTRL2_VRC_5p1V /* PWRCTRL3: x 2.165 - * NOTE: Many drivers have bit 8 set which is not defined in the MIO283QT2 spec. + * NOTE: + * Many drivers have bit 8 set which is not defined in the MIO283QT2 spec. */ # define PWRCTRL3_SETTING MIO283QT2_PWRCTRL3_VRH_x2p165 - /* PWRCTRL4: VDV=9 + VCOMG */ + /* PWRCTRL4: VDV=9 + VCOMG */ # define PWRCTRL4_SETTING (MIO283QT2_PWRCTRL4_VDV(9) | MIO283QT2_PWRCTRL4_VCOMG) - /* PWRCTRL5: VCM=56 + NOTP */ + /* PWRCTRL5: VCM=56 + NOTP */ # define PWRCTRL5_SETTING (MIO283QT2_PWRCTRL5_VCM(56) | MIO283QT2_PWRCTRL5_NOTP) @@ -197,24 +204,25 @@ # define PWRCTRL2_SETTING MIO283QT2_PWRCTRL2_VRC_5p3V /* PWRCTRL3: x 2.570 - * NOTE: Many drivers have bit 8 set which is not defined in the MIO283QT2 spec. + * NOTE: + * Many drivers have bit 8 set which is not defined in the MIO283QT2 spec. */ # define PWRCTRL3_SETTING MIO283QT2_PWRCTRL3_VRH_x2p570 - /* PWRCTRL4: VDV=12 + VCOMG */ + /* PWRCTRL4: VDV=12 + VCOMG */ # define PWRCTRL4_SETTING (MIO283QT2_PWRCTRL4_VDV(12) | MIO283QT2_PWRCTRL4_VCOMG) - /* PWRCTRL5: VCM=60 + NOTP */ + /* PWRCTRL5: VCM=60 + NOTP */ # define PWRCTRL5_SETTING (MIO283QT2_PWRCTRL5_VCM(60) | MIO283QT2_PWRCTRL5_NOTP) #endif -/************************************************************************************** +/**************************************************************************** * Private Type Definition - **************************************************************************************/ + ****************************************************************************/ /* This structure describes the state of this driver */ @@ -227,31 +235,36 @@ struct mio283qt2_dev_s /* Private LCD-specific information follows */ FAR struct mio283qt2_lcd_s *lcd; /* The contained platform-specific, LCD interface */ - uint8_t power; /* Current power setting */ + uint8_t power; /* Current power setting */ /* This is working memory allocated by the LCD driver for each LCD device - * and for each color plane. This memory will hold one raster line of data. + * and for each color plane. + * This memory will hold one raster line of data. * The size of the allocated run buffer must therefore be at least * (bpp * xres / 8). Actual alignment of the buffer must conform to the * bitwidth of the underlying pixel type. * * If there are multiple planes, they may share the same working buffer * because different planes will not be operate on concurrently. However, - * if there are multiple LCD devices, they must each have unique run buffers. + * if there are multiple LCD devices, they must each have unique run + * buffers. */ uint16_t runbuffer[MIO283QT2_XRES]; }; -/************************************************************************************** +/**************************************************************************** * Private Function Protototypes - **************************************************************************************/ + ****************************************************************************/ + /* Low Level LCD access */ -static void mio283qt2_putreg(FAR struct mio283qt2_lcd_s *lcd, uint8_t regaddr, - uint16_t regval); +static void mio283qt2_putreg(FAR struct mio283qt2_lcd_s *lcd, + uint8_t regaddr, + uint16_t regval); #ifndef CONFIG_LCD_NOGETRUN -static uint16_t mio283qt2_readreg(FAR struct mio283qt2_lcd_s *lcd, uint8_t regaddr); +static uint16_t mio283qt2_readreg(FAR struct mio283qt2_lcd_s *lcd, + uint8_t regaddr); #endif static inline void mio283qt2_gramwrite(FAR struct mio283qt2_lcd_s *lcd, uint16_t rgbcolor); @@ -262,21 +275,25 @@ static inline uint16_t mio283qt2_gramread(FAR struct mio283qt2_lcd_s *lcd, FAR uint16_t *accum); #endif static void mio283qt2_setarea(FAR struct mio283qt2_lcd_s *lcd, - uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1); + uint16_t x0, uint16_t y0, + uint16_t x1, uint16_t y1); /* LCD Data Transfer Methods */ -static int mio283qt2_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, - size_t npixels); -static int mio283qt2_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, - size_t npixels); +static int mio283qt2_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, + size_t npixels); +static int mio283qt2_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t *buffer, + size_t npixels); /* LCD Configuration */ static int mio283qt2_getvideoinfo(FAR struct lcd_dev_s *dev, - FAR struct fb_videoinfo_s *vinfo); -static int mio283qt2_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo); + FAR struct fb_videoinfo_s *vinfo); +static int mio283qt2_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo); /* LCD RGB Mapping */ @@ -295,99 +312,107 @@ static int mio283qt2_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planen static int mio283qt2_getpower(FAR struct lcd_dev_s *dev); static int mio283qt2_setpower(FAR struct lcd_dev_s *dev, int power); static int mio283qt2_getcontrast(FAR struct lcd_dev_s *dev); -static int mio283qt2_setcontrast(FAR struct lcd_dev_s *dev, unsigned int contrast); +static int mio283qt2_setcontrast(FAR struct lcd_dev_s *dev, + unsigned int contrast); /* Initialization */ static inline int mio283qt2_hwinitialize(FAR struct mio283qt2_dev_s *priv); -/************************************************************************************** +/**************************************************************************** * Private Data - **************************************************************************************/ + ****************************************************************************/ -/* This driver can support only a signal MIO283QT2 device. This is due to an - * unfortunate decision made whent he getrun and putrun methods were designed. The - * following is the single MIO283QT2 driver state instance: +/* This driver can support only a signal MIO283QT2 device. + * This is due to an unfortunate decision made whent he getrun and + * putrun methods were designed. + * The following is the single MIO283QT2 driver state instance: */ static struct mio283qt2_dev_s g_lcddev; -/************************************************************************************** +/**************************************************************************** * Private Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_putreg(lcd, * * Description: * Write to an LCD register * - **************************************************************************************/ + ****************************************************************************/ static void mio283qt2_putreg(FAR struct mio283qt2_lcd_s *lcd, uint8_t regaddr, uint16_t regval) { - /* Set the index register to the register address and write the register contents */ + /* Set the index register to the register address and write the register + * contents + */ lcd->index(lcd, regaddr); lcd->write(lcd, regval); } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_readreg * * Description: * Read from an LCD register * - **************************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_LCD_NOGETRUN -static uint16_t mio283qt2_readreg(FAR struct mio283qt2_lcd_s *lcd, uint8_t regaddr) +static uint16_t mio283qt2_readreg(FAR struct mio283qt2_lcd_s *lcd, + uint8_t regaddr) { - /* Set the index register to the register address and read the register contents. */ + /* Set the index register to the register address and read the register + * contents. + */ lcd->index(lcd, regaddr); return lcd->read(lcd); } #endif -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_gramselect * * Description: * Setup to read or write multiple pixels to the GRAM memory * - **************************************************************************************/ + ****************************************************************************/ static inline void mio283qt2_gramselect(FAR struct mio283qt2_lcd_s *lcd) { lcd->index(lcd, 0x22); } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_gramwrite * * Description: * Setup to read or write multiple pixels to the GRAM memory * - **************************************************************************************/ + ****************************************************************************/ -static inline void mio283qt2_gramwrite(FAR struct mio283qt2_lcd_s *lcd, uint16_t data) +static inline void mio283qt2_gramwrite(FAR struct mio283qt2_lcd_s *lcd, + uint16_t data) { lcd->write(lcd, data); } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_readsetup * * Description: - * Prime the operation by reading one pixel from the GRAM memory if necessary for - * this LCD type. When reading 16-bit gram data, there may be some shifts in the - * returned data: + * Prime the operation by reading one pixel from the GRAM memory if + * necessary for this LCD type. When reading 16-bit gram data, there may + * be some shifts in the returned data: * * - ILI932x: Discard first dummy read; no shift in the return data * - **************************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_LCD_NOGETRUN static inline void mio283qt2_readsetup(FAR struct mio283qt2_lcd_s *lcd, @@ -401,16 +426,17 @@ static inline void mio283qt2_readsetup(FAR struct mio283qt2_lcd_s *lcd, } #endif -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_gramread * * Description: - * Read one correctly aligned pixel from the GRAM memory. Possibly shifting the - * data and possibly swapping red and green components. + * Read one correctly aligned pixel from the GRAM memory. + * Possibly shifting the data and possibly swapping red and green + * components. * * - ILI932x: Unknown -- assuming colors are in the color order * - **************************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_LCD_NOGETRUN static inline uint16_t mio283qt2_gramread(FAR struct mio283qt2_lcd_s *lcd, @@ -422,29 +448,31 @@ static inline uint16_t mio283qt2_gramread(FAR struct mio283qt2_lcd_s *lcd, } #endif -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_setarea * * Description: - * Set the cursor position. In landscape mode, the "column" is actually the physical + * Set the cursor position. + * In landscape mode, the "column" is actually the physical * Y position and the "row" is the physical X position. * - **************************************************************************************/ + ****************************************************************************/ static void mio283qt2_setarea(FAR struct mio283qt2_lcd_s *lcd, - uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) + uint16_t x0, uint16_t y0, + uint16_t x1, uint16_t y1) { - mio283qt2_putreg(lcd, 0x03, (x0 & 0x00ff)); /* set x0 */ - mio283qt2_putreg(lcd, 0x02, (x0 >> 8)); /* set x0 */ - mio283qt2_putreg(lcd, 0x05, (x1 & 0x00ff)); /* set x1 */ - mio283qt2_putreg(lcd, 0x04, (x1 >> 8)); /* set x1 */ - mio283qt2_putreg(lcd, 0x07, (y0 & 0x00ff)); /* set y0 */ - mio283qt2_putreg(lcd, 0x06, (y0 >> 8)); /* set y0 */ - mio283qt2_putreg(lcd, 0x09, (y1 & 0x00ff)); /* set y1 */ - mio283qt2_putreg(lcd, 0x08, (y1 >> 8)); /* set y1 */ + mio283qt2_putreg(lcd, 0x03, (x0 & 0x00ff)); /* set x0 */ + mio283qt2_putreg(lcd, 0x02, (x0 >> 8)); /* set x0 */ + mio283qt2_putreg(lcd, 0x05, (x1 & 0x00ff)); /* set x1 */ + mio283qt2_putreg(lcd, 0x04, (x1 >> 8)); /* set x1 */ + mio283qt2_putreg(lcd, 0x07, (y0 & 0x00ff)); /* set y0 */ + mio283qt2_putreg(lcd, 0x06, (y0 >> 8)); /* set y0 */ + mio283qt2_putreg(lcd, 0x09, (y1 & 0x00ff)); /* set y1 */ + mio283qt2_putreg(lcd, 0x08, (y1 >> 8)); /* set y1 */ } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_dumprun * * Description: @@ -453,12 +481,15 @@ static void mio283qt2_setarea(FAR struct mio283qt2_lcd_s *lcd, * run - The buffer in containing the run read to be dumped * npixels - The number of pixels to dump * - **************************************************************************************/ + ****************************************************************************/ #if 0 /* Sometimes useful */ -static void mio283qt2_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npixels) +static void mio283qt2_dumprun(FAR const char *msg, + FAR uint16_t *run, + size_t npixels) { - int i, j; + int i; + int j; syslog(LOG_INFO, "\n%s:\n", msg); for (i = 0; i < npixels; i += 16) @@ -475,7 +506,7 @@ static void mio283qt2_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npi } #endif -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_putrun * * Description: @@ -487,9 +518,10 @@ static void mio283qt2_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npi * npixels - The number of pixels to write to the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ -static int mio283qt2_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, +static int mio283qt2_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, size_t npixels) { FAR struct mio283qt2_dev_s *priv = &g_lcddev; @@ -523,7 +555,7 @@ static int mio283qt2_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *b return OK; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_getrun * * Description: @@ -535,9 +567,10 @@ static int mio283qt2_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *b * npixels - The number of pixels to read from the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ -static int mio283qt2_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, +static int mio283qt2_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t *buffer, size_t npixels) { #ifndef CONFIG_LCD_NOGETRUN @@ -585,13 +618,13 @@ static int mio283qt2_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, #endif } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_getvideoinfo * * Description: * Get information about the LCD video controller configuration. * - **************************************************************************************/ + ****************************************************************************/ static int mio283qt2_getvideoinfo(FAR struct lcd_dev_s *dev, FAR struct fb_videoinfo_s *vinfo) @@ -607,15 +640,16 @@ static int mio283qt2_getvideoinfo(FAR struct lcd_dev_s *dev, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_getplaneinfo * * Description: * Get information about the configuration of each LCD color plane. * - **************************************************************************************/ + ****************************************************************************/ -static int mio283qt2_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, +static int mio283qt2_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, FAR struct lcd_planeinfo_s *pinfo) { FAR struct mio283qt2_dev_s *priv = (FAR struct mio283qt2_dev_s *)dev; @@ -630,14 +664,15 @@ static int mio283qt2_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planen return OK; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_getpower * * Description: - * Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Get the LCD panel power status + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int mio283qt2_getpower(FAR struct lcd_dev_s *dev) { @@ -645,14 +680,15 @@ static int mio283qt2_getpower(FAR struct lcd_dev_s *dev) return g_lcddev.power; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_poweroff * * Description: - * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Enable/disable LCD panel power + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int mio283qt2_poweroff(FAR struct mio283qt2_lcd_s *lcd) { @@ -678,14 +714,15 @@ static int mio283qt2_poweroff(FAR struct mio283qt2_lcd_s *lcd) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_setpower * * Description: - * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Enable/disable LCD panel power + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int mio283qt2_setpower(FAR struct lcd_dev_s *dev, int power) { @@ -733,13 +770,13 @@ static int mio283qt2_setpower(FAR struct lcd_dev_s *dev, int power) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_getcontrast * * Description: * Get the current contrast setting (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int mio283qt2_getcontrast(FAR struct lcd_dev_s *dev) { @@ -747,27 +784,28 @@ static int mio283qt2_getcontrast(FAR struct lcd_dev_s *dev) return -ENOSYS; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_setcontrast * * Description: * Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ -static int mio283qt2_setcontrast(FAR struct lcd_dev_s *dev, unsigned int contrast) +static int mio283qt2_setcontrast(FAR struct lcd_dev_s *dev, + unsigned int contrast) { lcdinfo("contrast: %d\n", contrast); return -ENOSYS; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_hwinitialize * * Description: * Initialize the LCD hardware. * - **************************************************************************************/ + ****************************************************************************/ static inline int mio283qt2_hwinitialize(FAR struct mio283qt2_dev_s *priv) { @@ -885,7 +923,8 @@ static inline int mio283qt2_hwinitialize(FAR struct mio283qt2_dev_s *priv) /* Window setting */ - mio283qt2_setarea(lcd, 0, 0, (MIO283QT2_XRES-1), (MIO283QT2_YRES-1)); + mio283qt2_setarea(lcd, 0, 0, (MIO283QT2_XRES - 1), + (MIO283QT2_YRES - 1)); ret = OK; } #ifndef CONFIG_LCD_NOGETRUN @@ -902,29 +941,32 @@ static inline int mio283qt2_hwinitialize(FAR struct mio283qt2_dev_s *priv) return ret; } -/************************************************************************************** +/**************************************************************************** * Public Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_lcdinitialize * * Description: - * Initialize the LCD video hardware. The initial state of the LCD is fully - * initialized, display memory cleared, and the LCD ready to use, but with the power + * Initialize the LCD video hardware. + * The initial state of the LCD is fully initialized, display memory + * cleared, and the LCD ready to use, but with the power * setting at 0 (full off). * - **************************************************************************************/ + ****************************************************************************/ -FAR struct lcd_dev_s *mio283qt2_lcdinitialize(FAR struct mio283qt2_lcd_s *lcd) +FAR struct lcd_dev_s *mio283qt2_lcdinitialize( + FAR struct mio283qt2_lcd_s *lcd) { int ret; lcdinfo("Initializing\n"); - /* If we ccould support multiple MIO283QT2 devices, this is where we would allocate - * a new driver data structure... but we can't. Why not? Because of a bad should - * the form of the getrun() and putrun methods. + /* If we ccould support multiple MIO283QT2 devices, this is where we + * would allocate a new driver data structure... but we can't. + * Why not? + * Because of a bad should the form of the getrun() and putrun methods. */ FAR struct mio283qt2_dev_s *priv = &g_lcddev; @@ -957,16 +999,17 @@ FAR struct lcd_dev_s *mio283qt2_lcdinitialize(FAR struct mio283qt2_lcd_s *lcd) return NULL; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt2_clear * * Description: - * This is a non-standard LCD interface just for the stm3240g-EVAL board. Because - * of the various rotations, clearing the display in the normal way by writing a - * sequences of runs that covers the entire display can be very slow. Here the - * display is cleared by simply setting all GRAM memory to the specified color. + * This is a non-standard LCD interface just for the stm3240g-EVAL board. + * Because of the various rotations, clearing the display in the normal + * way by writing a sequences of runs that covers the entire display can be + * very slow. Here the display is cleared by simply setting all GRAM + * memory to the specified color. * - **************************************************************************************/ + ****************************************************************************/ void mio283qt2_clear(FAR struct lcd_dev_s *dev, uint16_t color) { @@ -977,13 +1020,15 @@ void mio283qt2_clear(FAR struct lcd_dev_s *dev, uint16_t color) /* Select the LCD and set the drawring area */ lcd->select(lcd); - mio283qt2_setarea(lcd, 0, 0, (MIO283QT2_XRES-1), (MIO283QT2_YRES-1)); + mio283qt2_setarea(lcd, 0, 0, (MIO283QT2_XRES - 1), (MIO283QT2_YRES - 1)); /* Prepare to write GRAM data */ mio283qt2_gramselect(lcd); - /* Copy color into all of GRAM. Orientation does not matter in this case. */ + /* Copy color into all of GRAM. + * Orientation does not matter in this case. + */ for (i = 0; i < MIO283QT2_XRES * MIO283QT2_YRES; i++) { diff --git a/drivers/lcd/mio283qt9a.c b/drivers/lcd/mio283qt9a.c index 23210ba8ad5..5117da40a04 100644 --- a/drivers/lcd/mio283qt9a.c +++ b/drivers/lcd/mio283qt9a.c @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/mio283qt9a.c * * Copyright (C) 2012, 2014 Gregory Nutt. All rights reserved. @@ -32,11 +32,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ #include @@ -54,10 +54,11 @@ #ifdef CONFIG_LCD_MIO283QT9A -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ -/* Configuration **********************************************************************/ + ****************************************************************************/ + +/* Configuration ************************************************************/ /* Check contrast selection */ @@ -93,7 +94,8 @@ # define CONFIG_LCD_LANDSCAPE 1 #endif -/* Display/Color Properties ***********************************************************/ +/* Display/Color Properties *************************************************/ + /* Display Resolution */ #if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE) @@ -109,19 +111,20 @@ #define MIO283QT9A_BPP 16 #define MIO283QT9A_COLORFMT FB_FMT_RGB16_565 -/* Hardware LCD/LCD controller definitions ********************************************/ -/* In this driver, I chose to use all literal constants for register address and - * values. Some recent experiences have shown me that during LCD bringup, it is more - * important to know the binary values rather than nice, people friendly names. Sad, - * but true. +/* Hardware LCD/LCD controller definitions **********************************/ + +/* In this driver, I chose to use all literal constants for register address + * and values. Some recent experiences have shown me that during LCD bringup, + * it is more important to know the binary values rather than nice, people + * friendly names. Sad, but true. */ #define ILI9341_ID_1 0x93 #define ILI9341_ID_2 0x41 -/************************************************************************************** +/**************************************************************************** * Private Type Definition - **************************************************************************************/ + ****************************************************************************/ /* This structure describes the state of this driver */ @@ -134,31 +137,36 @@ struct mio283qt9a_dev_s /* Private LCD-specific information follows */ FAR struct mio283qt9a_lcd_s *lcd; /* The contained platform-specific, LCD interface */ - uint8_t power; /* Current power setting */ + uint8_t power; /* Current power setting */ /* This is working memory allocated by the LCD driver for each LCD device - * and for each color plane. This memory will hold one raster line of data. + * and for each color plane. + * This memory will hold one raster line of data. * The size of the allocated run buffer must therefore be at least * (bpp * xres / 8). Actual alignment of the buffer must conform to the * bitwidth of the underlying pixel type. * * If there are multiple planes, they may share the same working buffer - * because different planes will not be operate on concurrently. However, - * if there are multiple LCD devices, they must each have unique run buffers. + * because different planes will not be operate on concurrently. + * However, if there are multiple LCD devices, they must each have unique + * run buffers. */ uint16_t runbuffer[MIO283QT9A_XRES]; }; -/************************************************************************************** +/**************************************************************************** * Private Function Prototypes - **************************************************************************************/ + ****************************************************************************/ + /* Low Level LCD access */ -static void mio283qt9a_putreg(FAR struct mio283qt9a_lcd_s *lcd, uint8_t regaddr, - uint16_t regval); +static void mio283qt9a_putreg(FAR struct mio283qt9a_lcd_s *lcd, + uint8_t regaddr, + uint16_t regval); #ifndef CONFIG_LCD_NOGETRUN -static uint16_t mio283qt9a_readreg(FAR struct mio283qt9a_lcd_s *lcd, uint8_t regaddr); +static uint16_t mio283qt9a_readreg(FAR struct mio283qt9a_lcd_s *lcd, + uint8_t regaddr); #endif static inline void mio283qt9a_gramwrite(FAR struct mio283qt9a_lcd_s *lcd, uint16_t rgbcolor); @@ -173,17 +181,20 @@ static void mio283qt9a_setarea(FAR struct mio283qt9a_lcd_s *lcd, /* LCD Data Transfer Methods */ -static int mio283qt9a_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, - size_t npixels); -static int mio283qt9a_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, - size_t npixels); +static int mio283qt9a_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, + size_t npixels); +static int mio283qt9a_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t *buffer, + size_t npixels); /* LCD Configuration */ static int mio283qt9a_getvideoinfo(FAR struct lcd_dev_s *dev, FAR struct fb_videoinfo_s *vinfo); -static int mio283qt9a_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo); +static int mio283qt9a_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo); /* LCD RGB Mapping */ @@ -202,113 +213,125 @@ static int mio283qt9a_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int plane static int mio283qt9a_getpower(FAR struct lcd_dev_s *dev); static int mio283qt9a_setpower(FAR struct lcd_dev_s *dev, int power); static int mio283qt9a_getcontrast(FAR struct lcd_dev_s *dev); -static int mio283qt9a_setcontrast(FAR struct lcd_dev_s *dev, unsigned int contrast); +static int mio283qt9a_setcontrast(FAR struct lcd_dev_s *dev, + unsigned int contrast); /* Initialization */ -static inline int mio283qt9a_hwinitialize(FAR struct mio283qt9a_dev_s *priv); +static inline int mio283qt9a_hwinitialize( + FAR struct mio283qt9a_dev_s *priv); -/************************************************************************************** +/**************************************************************************** * Private Data - **************************************************************************************/ + ****************************************************************************/ -/* This driver can support only a signal MIO283QT9A device. This is due to an - * unfortunate decision made when the getrun and putrun methods were designed. The - * following is the single MIO283QT9A driver state instance: +/* This driver can support only a signal MIO283QT9A device. + * This is due to an unfortunate decision made when the getrun and putrun + * methods were designed. + * The following is the single MIO283QT9A driver state instance: */ static struct mio283qt9a_dev_s g_lcddev; -/************************************************************************************** +/**************************************************************************** * Private Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_putreg * * Description: * Write to an LCD register * - **************************************************************************************/ + ****************************************************************************/ static void mio283qt9a_putreg(FAR struct mio283qt9a_lcd_s *lcd, uint8_t regaddr, uint16_t regval) { - /* Set the index register to the register address and write the register contents */ + /* Set the index register to the register address and write the register + * contents + */ lcd->index(lcd, regaddr); lcd->write(lcd, regval); } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_readreg * * Description: * Read from an LCD register * - **************************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_LCD_NOGETRUN -static uint16_t mio283qt9a_readreg(FAR struct mio283qt9a_lcd_s *lcd, uint8_t regaddr) +static uint16_t mio283qt9a_readreg(FAR struct mio283qt9a_lcd_s *lcd, + uint8_t regaddr) { - /* Set the index register to the register address and read the register contents. */ + /* Set the index register to the register address and read the register + * contents. + */ lcd->index(lcd, regaddr); return lcd->read(lcd); } #endif -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_gramselect_write * * Description: * Setup to write multiple pixels to the GRAM memory * - **************************************************************************************/ + ****************************************************************************/ -static inline void mio283qt9a_gramselect_write(FAR struct mio283qt9a_lcd_s *lcd) +static inline void mio283qt9a_gramselect_write( + FAR struct mio283qt9a_lcd_s *lcd) { lcd->index(lcd, 0x2c); } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_gramselect_read * * Description: * Setup to read multiple pixels to the GRAM memory * - **************************************************************************************/ + ****************************************************************************/ -static inline void mio283qt9a_gramselect_read(FAR struct mio283qt9a_lcd_s *lcd) +static inline void mio283qt9a_gramselect_read( + FAR struct mio283qt9a_lcd_s *lcd) { lcd->index(lcd, 0x2e); lcd->readgram(lcd); } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_gramwrite * * Description: * Setup to read or write multiple pixels to the GRAM memory * - **************************************************************************************/ + ****************************************************************************/ -static inline void mio283qt9a_gramwrite(FAR struct mio283qt9a_lcd_s *lcd, uint16_t data) +static inline void mio283qt9a_gramwrite( + FAR struct mio283qt9a_lcd_s *lcd, uint16_t data) { lcd->write(lcd, data); } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_readsetup * * Description: - * Prime the operation by reading one pixel from the GRAM memory if necessary for - * this LCD type. When reading 16-bit gram data, there may be some shifts in the + * Prime the operation by reading one pixel from the GRAM memory if + * necessary for this LCD type. + * When reading 16-bit gram data, there may be some shifts in the * returned data: * * - ILI932x: Discard first dummy read; no shift in the return data * - **************************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_LCD_NOGETRUN static inline void mio283qt9a_readsetup(FAR struct mio283qt9a_lcd_s *lcd, @@ -322,16 +345,17 @@ static inline void mio283qt9a_readsetup(FAR struct mio283qt9a_lcd_s *lcd, } #endif -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_gramread * * Description: - * Read one correctly aligned pixel from the GRAM memory. Possibly shifting the - * data and possibly swapping red and green components. + * Read one correctly aligned pixel from the GRAM memory. + * Possibly shifting the data and possibly swapping red and green + * components. * * - ILI932x: Unknown -- assuming colors are in the color order * - **************************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_LCD_NOGETRUN static inline uint16_t mio283qt9a_gramread(FAR struct mio283qt9a_lcd_s *lcd, @@ -343,17 +367,18 @@ static inline uint16_t mio283qt9a_gramread(FAR struct mio283qt9a_lcd_s *lcd, } #endif -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_setarea * * Description: - * Set the cursor position. In landscape mode, the "column" is actually the physical + * Set the cursor position. + * In landscape mode, the "column" is actually the physical * Y position and the "row" is the physical X position. * - **************************************************************************************/ + ****************************************************************************/ static void mio283qt9a_setarea(FAR struct mio283qt9a_lcd_s *lcd, - uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) + uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1) { mio283qt9a_putreg(lcd, 0x2a, (x0 >> 8)); /* Set column address x0 */ lcd->write(lcd, (x0 & 0xff)); /* Set x0 */ @@ -366,7 +391,7 @@ static void mio283qt9a_setarea(FAR struct mio283qt9a_lcd_s *lcd, lcd->write(lcd, (y1 & 0xff)); /* Set y1 */ } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_dumprun * * Description: @@ -375,10 +400,12 @@ static void mio283qt9a_setarea(FAR struct mio283qt9a_lcd_s *lcd, * run - The buffer in containing the run read to be dumped * npixels - The number of pixels to dump * - **************************************************************************************/ + ****************************************************************************/ #if 0 /* Sometimes useful */ -static void mio283qt9a_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npixels) +static void mio283qt9a_dumprun(FAR const char *msg, + FAR uint16_t *run, + size_t npixels) { int i; int j; @@ -398,7 +425,7 @@ static void mio283qt9a_dumprun(FAR const char *msg, FAR uint16_t *run, size_t np } #endif -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_putrun * * Description: @@ -410,10 +437,11 @@ static void mio283qt9a_dumprun(FAR const char *msg, FAR uint16_t *run, size_t np * npixels - The number of pixels to write to the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ -static int mio283qt9a_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, - size_t npixels) +static int mio283qt9a_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, + size_t npixels) { FAR struct mio283qt9a_dev_s *priv = &g_lcddev; FAR struct mio283qt9a_lcd_s *lcd = priv->lcd; @@ -445,7 +473,7 @@ static int mio283qt9a_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t * return OK; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_getrun * * Description: @@ -457,9 +485,10 @@ static int mio283qt9a_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t * * npixels - The number of pixels to read from the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ -static int mio283qt9a_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, +static int mio283qt9a_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t *buffer, size_t npixels) { #ifndef CONFIG_LCD_NOGETRUN @@ -471,7 +500,8 @@ static int mio283qt9a_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer /* Buffer must be provided and aligned to a 16-bit address boundary */ - lcdinfo("mio283qt9a_getrun row: %d col: %d npixels: %d\n", row, col, npixels); + lcdinfo("mio283qt9a_getrun row: %d col: %d npixels: %d\n", + row, col, npixels); DEBUGASSERT(buffer && ((uintptr_t)buffer & 1) == 0); /* Read the run from GRAM. */ @@ -504,13 +534,13 @@ static int mio283qt9a_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer #endif } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_getvideoinfo * * Description: * Get information about the LCD video controller configuration. * - **************************************************************************************/ + ****************************************************************************/ static int mio283qt9a_getvideoinfo(FAR struct lcd_dev_s *dev, FAR struct fb_videoinfo_s *vinfo) @@ -526,16 +556,17 @@ static int mio283qt9a_getvideoinfo(FAR struct lcd_dev_s *dev, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_getplaneinfo * * Description: * Get information about the configuration of each LCD color plane. * - **************************************************************************************/ + ****************************************************************************/ -static int mio283qt9a_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo) +static int mio283qt9a_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo) { FAR struct mio283qt9a_dev_s *priv = (FAR struct mio283qt9a_dev_s *)dev; @@ -550,14 +581,15 @@ static int mio283qt9a_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int plane return OK; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_getpower * * Description: - * Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Get the LCD panel power status + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int mio283qt9a_getpower(FAR struct lcd_dev_s *dev) { @@ -565,18 +597,20 @@ static int mio283qt9a_getpower(FAR struct lcd_dev_s *dev) return g_lcddev.power; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_poweroff * * Description: - * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Enable/disable LCD panel power + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int mio283qt9a_poweroff(FAR struct mio283qt9a_lcd_s *lcd) { /* Select the LCD */ + lcdinfo("mio283qt9a_poweroff\n"); lcd->select(lcd); @@ -599,14 +633,15 @@ static int mio283qt9a_poweroff(FAR struct mio283qt9a_lcd_s *lcd) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_setpower * * Description: - * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Enable/disable LCD panel power + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int mio283qt9a_setpower(FAR struct lcd_dev_s *dev, int power) { @@ -650,13 +685,13 @@ static int mio283qt9a_setpower(FAR struct lcd_dev_s *dev, int power) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_getcontrast * * Description: * Get the current contrast setting (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int mio283qt9a_getcontrast(FAR struct lcd_dev_s *dev) { @@ -664,27 +699,28 @@ static int mio283qt9a_getcontrast(FAR struct lcd_dev_s *dev) return -ENOSYS; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_setcontrast * * Description: * Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ -static int mio283qt9a_setcontrast(FAR struct lcd_dev_s *dev, unsigned int contrast) +static int mio283qt9a_setcontrast(FAR struct lcd_dev_s *dev, + unsigned int contrast) { lcdinfo("contrast: %d\n", contrast); return -ENOSYS; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_hwinitialize * * Description: * Initialize the LCD hardware. * - **************************************************************************************/ + ****************************************************************************/ static inline int mio283qt9a_hwinitialize(FAR struct mio283qt9a_dev_s *priv) { @@ -743,7 +779,8 @@ static inline int mio283qt9a_hwinitialize(FAR struct mio283qt9a_dev_s *priv) /* Window setting */ - mio283qt9a_setarea(lcd, 0, 0, (MIO283QT9A_XRES-1), (MIO283QT9A_YRES-1)); + mio283qt9a_setarea(lcd, 0, 0, (MIO283QT9A_XRES - 1), + (MIO283QT9A_YRES - 1)); mio283qt9a_putreg(lcd, 0x11, 0); /* Sleep out mode */ up_mdelay(25); @@ -754,14 +791,16 @@ static inline int mio283qt9a_hwinitialize(FAR struct mio283qt9a_dev_s *priv) id_b = lcd->read(lcd); id_c = lcd->read(lcd); id_d = lcd->read(lcd); - lcdinfo("LCD man ID: %02x, version: %02x, driver ID: %02x\n", id_b, id_c, id_d); + lcdinfo("LCD man ID: %02x, version: %02x, driver ID: %02x\n", + id_b, id_c, id_d); id_a = mio283qt9a_readreg(lcd, 0x09); /* Read display status */ id_b = lcd->read(lcd); id_c = lcd->read(lcd); id_d = lcd->read(lcd); id_e = lcd->read(lcd); - lcdinfo("Display status %02x, %02x, %02x, %02x, %02x\n", id_a, id_b, id_c, id_d, id_e); + lcdinfo("Display status %02x, %02x, %02x, %02x, %02x\n", + id_a, id_b, id_c, id_d, id_e); id_a = mio283qt9a_readreg(lcd, 0x0a); /* Read power status */ id_b = lcd->read(lcd); @@ -803,30 +842,33 @@ static inline int mio283qt9a_hwinitialize(FAR struct mio283qt9a_dev_s *priv) return ret; } -/************************************************************************************** +/**************************************************************************** * Public Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_lcdinitialize * * Description: - * Initialize the LCD video hardware. The initial state of the LCD is fully - * initialized, display memory cleared, and the LCD ready to use, but with the power - * setting at 0 (full off). + * Initialize the LCD video hardware. + * The initial state of the LCD is fully initialized, display memory + * cleared, and the LCD ready to use, but with the power setting at 0 + * (full off). * - **************************************************************************************/ + ****************************************************************************/ -FAR struct lcd_dev_s *mio283qt9a_lcdinitialize(FAR struct mio283qt9a_lcd_s *lcd) +FAR struct lcd_dev_s *mio283qt9a_lcdinitialize( + FAR struct mio283qt9a_lcd_s *lcd) { FAR struct mio283qt9a_dev_s *priv; int ret; lcdinfo("Initializing\n"); - /* If we could support multiple MIO283QT9A devices, this is where we would allocate - * a new driver data structure... but we can't. Why not? Because of a bad should - * the form of the getrun() and putrun methods. + /* If we could support multiple MIO283QT9A devices, this is where we would + * allocate a new driver data structure... but we can't. + * Why not? + * Because of a bad should the form of the getrun() and putrun methods. */ priv = &g_lcddev; @@ -859,16 +901,17 @@ FAR struct lcd_dev_s *mio283qt9a_lcdinitialize(FAR struct mio283qt9a_lcd_s *lcd) return NULL; } -/************************************************************************************** +/**************************************************************************** * Name: mio283qt9a_clear * * Description: - * This is a non-standard LCD interface just for the stm3240g-EVAL board. Because - * of the various rotations, clearing the display in the normal way by writing a - * sequences of runs that covers the entire display can be very slow. Here the - * display is cleared by simply setting all GRAM memory to the specified color. + * This is a non-standard LCD interface just for the stm3240g-EVAL board. + * Because of the various rotations, clearing the display in the normal + * way by writing a sequences of runs that covers the entire display can + * be very slow. Here the display is cleared by simply setting all GRAM + * memory to the specified color. * - **************************************************************************************/ + ****************************************************************************/ void mio283qt9a_clear(FAR struct lcd_dev_s *dev, uint16_t color) { @@ -879,13 +922,16 @@ void mio283qt9a_clear(FAR struct lcd_dev_s *dev, uint16_t color) /* Select the LCD and set the drawring area */ lcd->select(lcd); - mio283qt9a_setarea(lcd, 0, 0, (MIO283QT9A_XRES-1), (MIO283QT9A_YRES-1)); + mio283qt9a_setarea(lcd, 0, 0, (MIO283QT9A_XRES - 1), + (MIO283QT9A_YRES - 1)); /* Prepare to write GRAM data */ mio283qt9a_gramselect_write(lcd); - /* Copy color into all of GRAM. Orientation does not matter in this case. */ + /* Copy color into all of GRAM. + * Orientation does not matter in this case. + */ for (i = 0; i < MIO283QT9A_XRES * MIO283QT9A_YRES; i++) { diff --git a/drivers/lcd/p14201.c b/drivers/lcd/p14201.c index b758fbe0b67..159ed827bed 100644 --- a/drivers/lcd/p14201.c +++ b/drivers/lcd/p14201.c @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/p14201.c * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,13 +16,13 @@ * License for the specific language governing permissions and limitations * under the License. * - **************************************************************************************/ + ****************************************************************************/ /* Driver for RiT P14201 series display (with SD1329 IC controller) */ -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ #include @@ -44,22 +44,22 @@ #ifdef CONFIG_LCD_P14201 -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ -/* Configuration **********************************************************************/ +/* Configuration ************************************************************/ /* P14201 Configuration Settings: * * CONFIG_P14201_SPIMODE - Controls the SPI mode * CONFIG_P14201_FREQUENCY - Define to use a different bus frequency - * CONFIG_P14201_NINTERFACES - Specifies the number of physical P14201 devices that - * will be supported. - * CONFIG_P14201_FRAMEBUFFER - If defined, accesses will be performed using an in-memory - * copy of the OLEDs GDDRAM. This cost of this buffer is 128 * 96 / 2 = 6Kb. If this - * is defined, then the driver will be fully functional. If not, then it will have the - * following limitations: + * CONFIG_P14201_NINTERFACES - Specifies the number of physical P14201 + * devices that will be supported. + * CONFIG_P14201_FRAMEBUFFER - If defined, accesses will be performed using + * an in-memory copy of the OLEDs GDDRAM. This cost of this buffer is + * 128 * 96 / 2 = 6Kb. If this is defined, then the driver will be fully + * functional. If not, then it will have the following limitations: * * - Reading graphics memory cannot be supported, and * - All pixel writes must be aligned to byte boundaries. @@ -68,7 +68,8 @@ * * Required LCD driver settings: * CONFIG_LCD_P14201 - Enable P14201 support - * CONFIG_LCD_MAXCONTRAST should be 255, but any value >0 and <=255 will be accepted. + * CONFIG_LCD_MAXCONTRAST should be 255, but any value >0 and <=255 will be + * accepted. * CONFIG_LCD_MAXPOWER must be 1 * * Required SPI driver settings: @@ -121,8 +122,8 @@ # define CONFIG_LCD_MAXPOWER 1 #endif -/* Define the CONFIG_LCD_RITDEBUG to enable detailed debug output (stuff you would - * never want to see unless you are debugging this file). +/* Define the CONFIG_LCD_RITDEBUG to enable detailed debug output + * (stuff you would never want to see unless you are debugging this file). * * Verbose debug must also be enabled */ @@ -136,7 +137,7 @@ # undef CONFIG_LCD_RITDEBUG #endif -/* Color Properties *******************************************************************/ +/* Color Properties *********************************************************/ /* Display Resolution */ @@ -152,12 +153,12 @@ #define RIT_CONTRAST ((23 * (CONFIG_LCD_MAXCONTRAST+1) / 32) - 1) -/* Helper Macros **********************************************************************/ +/* Helper Macros ************************************************************/ #define rit_sndcmd(p,b,l) rit_sndbytes(p,b,l,true); #define rit_snddata(p,b,l) rit_sndbytes(p,b,l,false); -/* Debug ******************************************************************************/ +/* Debug ********************************************************************/ #ifdef CONFIG_LCD_RITDEBUG # define riterr(format, ...) _err(format, ##__VA_ARGS__) @@ -169,9 +170,9 @@ # define ritinfo(x...) #endif -/************************************************************************************** +/**************************************************************************** * Private Type Definition - **************************************************************************************/ + ****************************************************************************/ /* This structure describes the state of this driver */ @@ -183,31 +184,36 @@ struct rit_dev_s bool on; /* true: display is on */ }; -/************************************************************************************** +/**************************************************************************** * Private Function Protototypes - **************************************************************************************/ + ****************************************************************************/ /* Low-level SPI helpers */ static void rit_select(FAR struct spi_dev_s *spi); static void rit_deselect(FAR struct spi_dev_s *spi); -static void rit_sndbytes(FAR struct rit_dev_s *priv, FAR const uint8_t *buffer, - size_t buflen, bool cmd); -static void rit_sndcmds(FAR struct rit_dev_s *priv, FAR const uint8_t *table); +static void rit_sndbytes(FAR struct rit_dev_s *priv, + FAR const uint8_t *buffer, + size_t buflen, bool cmd); +static void rit_sndcmds(FAR struct rit_dev_s *priv, + FAR const uint8_t *table); /* LCD Data Transfer Methods */ -static int rit_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, - size_t npixels); -static int rit_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, - size_t npixels); +static int rit_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, + size_t npixels); +static int rit_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t *buffer, + size_t npixels); /* LCD Configuration */ static int rit_getvideoinfo(FAR struct lcd_dev_s *dev, - FAR struct fb_videoinfo_s *vinfo); -static int rit_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo); + FAR struct fb_videoinfo_s *vinfo); +static int rit_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo); /* LCD RGB Mapping */ @@ -228,9 +234,9 @@ static int rit_setpower(struct lcd_dev_s *dev, int power); static int rit_getcontrast(struct lcd_dev_s *dev); static int rit_setcontrast(struct lcd_dev_s *dev, unsigned int contrast); -/************************************************************************************** +/**************************************************************************** * Private Data - **************************************************************************************/ + ****************************************************************************/ /* This is working memory allocated by the LCD driver for each LCD device * and for each color plane. This memory will hold one raster line of data. @@ -245,9 +251,10 @@ static int rit_setcontrast(struct lcd_dev_s *dev, unsigned int contrast); static uint8_t g_runbuffer[RIT_XRES / 2]; -/* CONFIG_P14201_FRAMEBUFFER - If defined, accesses will be performed using an in-memory - * copy of the OLEDs GDDRAM. This cost of this buffer is 128 * 64 / 2 = 4Kb. If this - * is defined, then the driver will be full functional. If not, then: +/* CONFIG_P14201_FRAMEBUFFER - If defined, accesses will be performed using + * an in-memory copy of the OLEDs GDDRAM. This cost of this buffer is + * 128 * 64 / 2 = 4Kb. If this is defined, then the driver will be full + * functional. If not, then: * * - Reading graphics memory cannot be supported, and * - All pixel writes must be aligned to byte boundaries. @@ -277,7 +284,9 @@ static const struct lcd_planeinfo_s g_planeinfo = .bpp = RIT_BPP, /* Bits-per-pixel */ }; -/* This is the OLED driver instance (only a single device is supported for now) */ +/* This is the OLED driver instance + * (only a single device is supported for now) + */ static struct rit_dev_s g_oleddev = { @@ -289,6 +298,7 @@ static struct rit_dev_s g_oleddev = .getplaneinfo = rit_getplaneinfo, /* LCD RGB Mapping -- Not supported */ + /* Cursor Controls -- Not supported */ /* LCD Specific Controls */ @@ -301,8 +311,8 @@ static struct rit_dev_s g_oleddev = }; /* A table of magic initialization commands. This initialization sequence is - * derived from RiT Application Note for the P14201 (with a few tweaked values - * as discovered in some Luminary code examples). + * derived from RiT Application Note for the P14201 (with a few tweaked + * values as discovered in some Luminary code examples). */ static const uint8_t g_initcmds[] = @@ -392,21 +402,21 @@ static const uint8_t g_setallcol[] = { SSD1329_SET_COLADDR, 0, - (RIT_XRES/2)-1 + (RIT_XRES / 2) - 1 }; static const uint8_t g_setallrow[] = { SSD1329_SET_ROWADDR, 0, - RIT_YRES-1 + RIT_YRES - 1 }; -/************************************************************************************** +/**************************************************************************** * Private Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: rit_select * * Description: @@ -420,7 +430,7 @@ static const uint8_t g_setallrow[] = * * Assumptions: * - **************************************************************************************/ + ****************************************************************************/ static void rit_select(FAR struct spi_dev_s *spi) { @@ -443,7 +453,7 @@ static void rit_select(FAR struct spi_dev_s *spi) #endif } -/************************************************************************************** +/**************************************************************************** * Name: rit_deselect * * Description: @@ -457,7 +467,7 @@ static void rit_select(FAR struct spi_dev_s *spi) * * Assumptions: * - **************************************************************************************/ + ****************************************************************************/ static void rit_deselect(FAR struct spi_dev_s *spi) { @@ -467,7 +477,7 @@ static void rit_deselect(FAR struct spi_dev_s *spi) SPI_LOCK(spi, false); } -/************************************************************************************** +/**************************************************************************** * Name: rit_sndbytes * * Description: @@ -484,9 +494,10 @@ static void rit_deselect(FAR struct spi_dev_s *spi) * Assumptions: * The caller as selected the OLED device. * - **************************************************************************************/ + ****************************************************************************/ -static void rit_sndbytes(FAR struct rit_dev_s *priv, FAR const uint8_t *buffer, +static void rit_sndbytes(FAR struct rit_dev_s *priv, + FAR const uint8_t *buffer, size_t buflen, bool cmd) { FAR struct spi_dev_s *spi = priv->spi; @@ -508,10 +519,10 @@ static void rit_sndbytes(FAR struct rit_dev_s *priv, FAR const uint8_t *buffer, tmp = *buffer++; SPI_SEND(spi, tmp); - } + } } -/************************************************************************************** +/**************************************************************************** * Name: rit_sndcmd * * Description: @@ -526,7 +537,7 @@ static void rit_sndbytes(FAR struct rit_dev_s *priv, FAR const uint8_t *buffer, * * Assumptions: * - **************************************************************************************/ + ****************************************************************************/ static void rit_sndcmds(FAR struct rit_dev_s *priv, FAR const uint8_t *table) { @@ -543,7 +554,7 @@ static void rit_sndcmds(FAR struct rit_dev_s *priv, FAR const uint8_t *table) } } -/************************************************************************************** +/**************************************************************************** * Name: rit_clear * * Description: @@ -555,7 +566,7 @@ static void rit_sndcmds(FAR struct rit_dev_s *priv, FAR const uint8_t *table) * Assumptions: * Caller has selected the OLED section. * - **************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_P14201_FRAMEBUFFER static inline void rit_clear(FAR struct rit_dev_s *priv) @@ -567,7 +578,9 @@ static inline void rit_clear(FAR struct rit_dev_s *priv) /* Initialize the framebuffer */ - memset(g_framebuffer, (RIT_Y4_BLACK << 4) | RIT_Y4_BLACK, RIT_YRES * RIT_XRES / 2); + memset(g_framebuffer, + (RIT_Y4_BLACK << 4) | RIT_Y4_BLACK, + RIT_YRES * RIT_XRES / 2); /* Set a window to fill the entire display */ @@ -613,7 +626,7 @@ static inline void rit_clear(FAR struct rit_dev_s *priv) } #endif -/************************************************************************************** +/**************************************************************************** * Name: rit_putrun * * Description: @@ -626,10 +639,11 @@ static inline void rit_clear(FAR struct rit_dev_s *priv) * npixels - The number of pixels to write to the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_P14201_FRAMEBUFFER -static int rit_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, +static int rit_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, size_t npixels) { FAR struct rit_dev_s *priv = (FAR struct rit_dev_s *)&g_oleddev; @@ -746,13 +760,13 @@ static int rit_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, */ last = curr; - curr = buffer[i-start]; + curr = buffer[i - start]; run[i] = (last << 4) | (curr >> 4); } /* An odd number of unaligned pixel have been written (where npixels - * may have been as small as one). If npixels was was even, then handle - * the final, unaligned pixel. + * may have been as small as one). If npixels was was even, then + * handle the final, unaligned pixel. */ if (aend != end) @@ -794,7 +808,8 @@ static int rit_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, return OK; } #else -static int rit_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, +static int rit_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, size_t npixels) { FAR struct rit_dev_s *priv = (FAR struct rit_dev_s *)&g_oleddev; @@ -807,7 +822,9 @@ static int rit_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, { /* Check that the X and Y coordinates are within range */ - DEBUGASSERT(col < RIT_XRES && (col + npixels) <= RIT_XRES && row < RIT_YRES); + DEBUGASSERT(col < RIT_XRES && + (col + npixels) <= RIT_XRES && + row < RIT_YRES); /* Check that the X coordinates are aligned to 8-bit boundaries * (this needs to get fixed somehow) @@ -847,7 +864,7 @@ static int rit_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, } #endif -/************************************************************************************** +/**************************************************************************** * Name: rit_getrun * * Description: @@ -859,7 +876,7 @@ static int rit_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, * npixels - The number of pixels to read from the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_P14201_FRAMEBUFFER static int rit_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, @@ -874,7 +891,10 @@ static int rit_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, ritinfo("row: %d col: %d npixels: %d\n", row, col, npixels); DEBUGASSERT(buffer); - /* Can't read from OLED GDDRAM in SPI mode, but we can read from the framebuffer */ + /* Can't read from OLED GDDRAM in SPI mode, but we can read from the + * framebuffer + */ + /* Toss out the special case of the empty run now */ if (npixels < 1) @@ -909,7 +929,9 @@ static int rit_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, memcpy(buffer, &run[start], aend - start + 1); } - /* Handle any final pixel (including the special case where npixels == 1). */ + /* Handle any final pixel + * (including the special case where npixels == 1). + */ if (aend != end) { @@ -940,7 +962,9 @@ static int rit_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, *buffer++ = (last << 4) | (curr >> 4); } - /* Handle any final pixel (including the special case where npixels == 1). */ + /* Handle any final pixel + * (including the special case where npixels == 1). + */ if (aend != end) { @@ -964,34 +988,36 @@ static int rit_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, } #endif -/************************************************************************************** +/**************************************************************************** * Name: rit_getvideoinfo * * Description: * Get information about the LCD video controller configuration. * - **************************************************************************************/ + ****************************************************************************/ static int rit_getvideoinfo(FAR struct lcd_dev_s *dev, FAR struct fb_videoinfo_s *vinfo) { DEBUGASSERT(dev && vinfo); ginfo("fmt: %d xres: %d yres: %d nplanes: %d\n", - g_videoinfo.fmt, g_videoinfo.xres, g_videoinfo.yres, g_videoinfo.nplanes); + g_videoinfo.fmt, g_videoinfo.xres, + g_videoinfo.yres, g_videoinfo.nplanes); memcpy(vinfo, &g_videoinfo, sizeof(struct fb_videoinfo_s)); return OK; } -/************************************************************************************** +/**************************************************************************** * Name: rit_getplaneinfo * * Description: * Get information about the configuration of each LCD color plane. * - **************************************************************************************/ + ****************************************************************************/ -static int rit_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo) +static int rit_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo) { DEBUGASSERT(pinfo && planeno == 0); ginfo("planeno: %d bpp: %d\n", planeno, g_planeinfo.bpp); @@ -999,14 +1025,15 @@ static int rit_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: rit_getpower * * Description: - * Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER: full on. On - * backlit LCDs, this setting may correspond to the backlight setting. + * Get the LCD panel power status + * (0: full off - CONFIG_LCD_MAXPOWER: full on. + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int rit_getpower(FAR struct lcd_dev_s *dev) { @@ -1017,14 +1044,15 @@ static int rit_getpower(FAR struct lcd_dev_s *dev) return priv->on ? CONFIG_LCD_MAXPOWER : 0; } -/************************************************************************************** +/**************************************************************************** * Name: rit_setpower * * Description: - * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Enable/disable LCD panel power + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int rit_setpower(struct lcd_dev_s *dev, int power) { @@ -1064,13 +1092,13 @@ static int rit_setpower(struct lcd_dev_s *dev, int power) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: rit_getcontrast * * Description: * Get the current contrast setting (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int rit_getcontrast(struct lcd_dev_s *dev) { @@ -1080,13 +1108,13 @@ static int rit_getcontrast(struct lcd_dev_s *dev) return priv->contrast; } -/************************************************************************************** +/**************************************************************************** * Name: rit_setcontrast * * Description: * Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int rit_setcontrast(struct lcd_dev_s *dev, unsigned int contrast) { @@ -1114,30 +1142,32 @@ static int rit_setcontrast(struct lcd_dev_s *dev, unsigned int contrast) return OK; } -/************************************************************************************** +/**************************************************************************** * Public Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: rit_initialize * * Description: - * Initialize the P14201 video hardware. The initial state of the OLED is fully - * initialized, display memory cleared, and the OLED ready to use, but with the power - * setting at 0 (full off == sleep mode). + * Initialize the P14201 video hardware. + * The initial state of the OLED is fully initialized, display memory + * cleared, and the OLED ready to use, but with the power setting at 0 + * (full off == sleep mode). * * Input Parameters: * spi - A reference to the SPI driver instance. - * devno - A value in the range of 0 through CONFIG_P14201_NINTERFACES-1. This allows - * support for multiple OLED devices. + * devno - A value in the range of 0 through CONFIG_P14201_NINTERFACES-1. + * This allows support for multiple OLED devices. * * Returned Value: - * On success, this function returns a reference to the LCD object for the specified - * OLED. NULL is returned on any failure. + * On success, this function returns a reference to the LCD object for the + * specified OLED. NULL is returned on any failure. * - **************************************************************************************/ + ****************************************************************************/ -FAR struct lcd_dev_s *rit_initialize(FAR struct spi_dev_s *spi, unsigned int devno) +FAR struct lcd_dev_s *rit_initialize(FAR struct spi_dev_s *spi, + unsigned int devno) { FAR struct rit_dev_s *priv = (FAR struct rit_dev_s *)&g_oleddev; DEBUGASSERT(devno == 0 && spi); diff --git a/drivers/lcd/pcd8544.h b/drivers/lcd/pcd8544.h index 8bbf36c0e1e..e60f7db3777 100644 --- a/drivers/lcd/pcd8544.h +++ b/drivers/lcd/pcd8544.h @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/pcd8544.h * Definitions for the PCD8544 LCD Display * @@ -32,18 +32,18 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - **************************************************************************************/ + ****************************************************************************/ #ifndef __DRIVERS_LCD_PCD8544_H #define __DRIVERS_LCD_PCD8544_H -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ #define PCD8544_MAX_BANKS 6 #define PCD8544_MAX_COLS 84 diff --git a/drivers/lcd/pcf8833.h b/drivers/lcd/pcf8833.h index 9b15ab10933..c63c170834b 100644 --- a/drivers/lcd/pcf8833.h +++ b/drivers/lcd/pcf8833.h @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/pcf8833.h * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,7 +16,7 @@ * License for the specific language governing permissions and limitations * under the License. * - **************************************************************************************/ + ****************************************************************************/ /* Definitions for the Phillips PCF8833 LCD controller * @@ -27,13 +27,14 @@ #ifndef __DRIVERS_LCD_PCF8833_H #define __DRIVERS_LCD_PCF8833_H -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ + /* Pixel format codes */ #define PCF8833_FMT_8BPS (2) @@ -104,7 +105,9 @@ #define MADCTL_MY (1 << 7) /* Bit 7: Mirror Y */ /* PCF8833 status register bit definitions */ + /* CMD format: RDDST command followed by four status bytes: */ + /* Byte 1: D31 d30 D29 D28 D27 D26 --- --- */ #define PCF8833_ST_RGB (1 << 2) /* Bit 2: D26 - RGB/BGR order */ diff --git a/drivers/lcd/ra8875.c b/drivers/lcd/ra8875.c index c977f963537..cce2ffd7c23 100644 --- a/drivers/lcd/ra8875.c +++ b/drivers/lcd/ra8875.c @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/ra8875.c * * Driver for the RAiO Technologies RA8875 LCD controller @@ -35,11 +35,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ #include @@ -59,10 +59,11 @@ #ifdef CONFIG_LCD_RA8875 -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ -/* Configuration **********************************************************************/ + ****************************************************************************/ + +/* Configuration ************************************************************/ /* Check contrast selection */ @@ -99,7 +100,8 @@ # define CONFIG_LCD_LANDSCAPE 1 #endif -/* Display/Color Properties ***********************************************************/ +/* Display/Color Properties *************************************************/ + /* Display Resolution */ #if defined(CONFIG_RA8875_XRES) @@ -158,9 +160,9 @@ # define RA8875_2LAYER_POSSIBLE 1 #endif -/************************************************************************************** +/**************************************************************************** * Private Type Definition - **************************************************************************************/ + ****************************************************************************/ /* This structure describes the state of this driver */ @@ -180,8 +182,10 @@ struct ra8875_dev_s #endif /* Shadow these registers to speed up rendering */ + uint8_t shadow_mwcr0; - uint16_t shadow_w_curh, shadow_w_curv; + uint16_t shadow_w_curh; + uint16_t shadow_w_curv; /* These fields simplify and reduce debug output */ @@ -194,48 +198,59 @@ struct ra8875_dev_s #endif /* This is working memory allocated by the LCD driver for each LCD device - * and for each color plane. This memory will hold one raster line of data. + * and for each color plane. + * This memory will hold one raster line of data. * The size of the allocated run buffer must therefore be at least * (bpp * xres / 8). Actual alignment of the buffer must conform to the * bitwidth of the underlying pixel type. * * If there are multiple planes, they may share the same working buffer * because different planes will not be operate on concurrently. However, - * if there are multiple LCD devices, they must each have unique run buffers. + * if there are multiple LCD devices, they must each have unique run + * buffers. */ uint16_t runbuffer[RA8875_XRES]; }; -/************************************************************************************** +/**************************************************************************** * Private Function Prototypes - **************************************************************************************/ + ****************************************************************************/ + /* Low Level LCD access */ -static inline void ra8875_putreg(FAR struct ra8875_lcd_s *lcd, uint8_t regaddr, - uint8_t regval); -static inline void ra8875_putreg16(FAR struct ra8875_lcd_s *lcd, uint8_t regaddr, - uint16_t regval); +static inline void ra8875_putreg(FAR struct ra8875_lcd_s *lcd, + uint8_t regaddr, + uint8_t regval); +static inline void ra8875_putreg16(FAR struct ra8875_lcd_s *lcd, + uint8_t regaddr, + uint16_t regval); #ifndef CONFIG_LCD_NOGETRUN -static inline uint8_t ra8875_readreg(FAR struct ra8875_lcd_s *lcd, uint8_t regaddr); -static inline void ra8875_waitreg(FAR struct ra8875_lcd_s *lcd, uint8_t regaddr, - uint8_t mask); +static inline uint8_t ra8875_readreg(FAR struct ra8875_lcd_s *lcd, + uint8_t regaddr); +static inline void ra8875_waitreg(FAR struct ra8875_lcd_s *lcd, + uint8_t regaddr, uint8_t mask); #endif -static void ra8875_set_writecursor(FAR struct ra8875_dev_s *dev, uint16_t column, - uint16_t row); -static void ra8875_set_readcursor(FAR struct ra8875_lcd_s *lcd, uint16_t column, - uint16_t row); +static void ra8875_set_writecursor(FAR struct ra8875_dev_s *dev, + uint16_t column, uint16_t row); +static void ra8875_set_readcursor(FAR struct ra8875_lcd_s *lcd, + uint16_t column, uint16_t row); static void ra8875_set_mwcr0(FAR struct ra8875_dev_s *dev, uint8_t value); -static void ra8875_setwindow(FAR struct ra8875_lcd_s *lcd, uint16_t x, uint16_t y, - uint16_t width, uint16_t height); -static inline void ra8875_setbackground(FAR struct ra8875_lcd_s *lcd, uint16_t color); -static inline void ra8875_setforeground(FAR struct ra8875_lcd_s *lcd, uint16_t color); +static void ra8875_setwindow(FAR struct ra8875_lcd_s *lcd, + uint16_t x, uint16_t y, + uint16_t width, uint16_t height); +static inline void ra8875_setbackground(FAR struct ra8875_lcd_s *lcd, + uint16_t color); +static inline void ra8875_setforeground(FAR struct ra8875_lcd_s *lcd, + uint16_t color); static void ra8875_clearmem(FAR struct ra8875_lcd_s *lcd); /* LCD Data Transfer Methods */ #if 0 /* Sometimes useful */ -static void ra8875_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npixels); +static void ra8875_dumprun(FAR const char *msg, + FAR uint16_t *run, + size_t npixels); #else # define ra8875_dumprun(m,r,n) #endif @@ -247,17 +262,20 @@ static void ra8875_showrun(FAR struct ra8875_dev_s *priv, fb_coord_t row, # define ra8875_showrun(p,r,c,n,b) #endif -static int ra8875_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, - size_t npixels); -static int ra8875_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, - size_t npixels); +static int ra8875_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, + size_t npixels); +static int ra8875_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t *buffer, + size_t npixels); /* LCD Configuration */ static int ra8875_getvideoinfo(FAR struct lcd_dev_s *dev, - FAR struct fb_videoinfo_s *vinfo); -static int ra8875_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo); + FAR struct fb_videoinfo_s *vinfo); +static int ra8875_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo); /* LCD RGB Mapping */ @@ -276,76 +294,83 @@ static int ra8875_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, static int ra8875_getpower(FAR struct lcd_dev_s *dev); static int ra8875_setpower(FAR struct lcd_dev_s *dev, int power); static int ra8875_getcontrast(FAR struct lcd_dev_s *dev); -static int ra8875_setcontrast(FAR struct lcd_dev_s *dev, unsigned int contrast); +static int ra8875_setcontrast(FAR struct lcd_dev_s *dev, + unsigned int contrast); /* Initialization */ static inline int ra8875_hwinitialize(FAR struct ra8875_dev_s *priv); -/************************************************************************************** +/**************************************************************************** * Private Data - **************************************************************************************/ + ****************************************************************************/ /* This driver can support only a signal RA8875 device. This is due to an - * unfortunate decision made when the getrun and putrun methods were designed. The - * following is the single RA8875 driver state instance: + * unfortunate decision made when the getrun and putrun methods were + * designed. The following is the single RA8875 driver state instance: */ static struct ra8875_dev_s g_lcddev; -/************************************************************************************** +/**************************************************************************** * Private Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: ra8875_putreg(lcd, * * Description: * Write to an LCD register * - **************************************************************************************/ + ****************************************************************************/ static void ra8875_putreg(FAR struct ra8875_lcd_s *lcd, uint8_t regaddr, uint8_t regval) { - /* Set the index register to the register address and write the register contents */ + /* Set the index register to the register address and write the register + * contents + */ lcdinfo("putreg 0x%02x = 0x%02x\n", regaddr, regval); lcd->write_reg(lcd, regaddr, regval); } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_putreg16(lcd, * * Description: * Write to an LCD register * - **************************************************************************************/ + ****************************************************************************/ static void ra8875_putreg16(FAR struct ra8875_lcd_s *lcd, uint8_t regaddr, uint16_t regval) { - /* Set the index register to the register address and write the register contents */ + /* Set the index register to the register address and write the register + * contents + */ lcdinfo("putreg 0x%02x = 0x%04x\n", regaddr, regval); lcd->write_reg16(lcd, regaddr, regval); } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_readreg * * Description: * Read from an LCD register * - **************************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_LCD_NOGETRUN static uint8_t ra8875_readreg(FAR struct ra8875_lcd_s *lcd, uint8_t regaddr) { uint8_t regval; - /* Set the index register to the register address and read the register contents */ + /* Set the index register to the register address and read the register + * contents + */ regval = lcd->read_reg(lcd, regaddr); @@ -354,18 +379,19 @@ static uint8_t ra8875_readreg(FAR struct ra8875_lcd_s *lcd, uint8_t regaddr) } #endif -/************************************************************************************** +/**************************************************************************** * Name: ra8875_waitreg * * Description: * Wait while an LCD register match set mask * - **************************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_LCD_NOGETRUN -static void ra8875_waitreg(FAR struct ra8875_lcd_s *lcd, uint8_t regaddr, uint8_t mask) +static void ra8875_waitreg(FAR struct ra8875_lcd_s *lcd, + uint8_t regaddr, uint8_t mask) { - int i = 20000/100; + int i = 20000 / 100; while (i-- && ra8875_readreg(lcd, regaddr) & mask) { @@ -374,15 +400,16 @@ static void ra8875_waitreg(FAR struct ra8875_lcd_s *lcd, uint8_t regaddr, uint8_ } #endif -/************************************************************************************** +/**************************************************************************** * Name: ra8875_set_writecursor * * Description: * Set the position to use for the write cursor * - **************************************************************************************/ + ****************************************************************************/ -static void ra8875_set_writecursor(FAR struct ra8875_dev_s *dev, uint16_t column, +static void ra8875_set_writecursor(FAR struct ra8875_dev_s *dev, + uint16_t column, uint16_t row) { FAR struct ra8875_lcd_s *lcd = dev->lcd; @@ -414,15 +441,16 @@ static void ra8875_set_writecursor(FAR struct ra8875_dev_s *dev, uint16_t column #endif } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_set_readcursor * * Description: * Set the position to use for the read cursor * - **************************************************************************************/ + ****************************************************************************/ -static void ra8875_set_readcursor(FAR struct ra8875_lcd_s *lcd, uint16_t column, +static void ra8875_set_readcursor(FAR struct ra8875_lcd_s *lcd, + uint16_t column, uint16_t row) { #if defined(CONFIG_LCD_PORTRAIT) || defined(CONFIG_LCD_RPORTRAIT) @@ -445,67 +473,70 @@ static void ra8875_set_mwcr0(FAR struct ra8875_dev_s *dev, uint8_t value) } } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_setwindow * * Description: * Set hardware clipping window * - **************************************************************************************/ + ****************************************************************************/ -static void ra8875_setwindow(FAR struct ra8875_lcd_s *lcd, uint16_t x, uint16_t y, +static void ra8875_setwindow(FAR struct ra8875_lcd_s *lcd, + uint16_t x, uint16_t y, uint16_t width, uint16_t height) { #if defined(CONFIG_LCD_PORTRAIT) || defined(CONFIG_LCD_RPORTRAIT) ra8875_putreg16(lcd, RA8875_HSAW0, y); ra8875_putreg16(lcd, RA8875_VSAW0, x); - ra8875_putreg16(lcd, RA8875_HEAW0, (y+height-1)); - ra8875_putreg16(lcd, RA8875_VEAW0, (x+width-1)); + ra8875_putreg16(lcd, RA8875_HEAW0, (y + height - 1)); + ra8875_putreg16(lcd, RA8875_VEAW0, (x + width - 1)); #elif defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE) ra8875_putreg16(lcd, RA8875_HSAW0, x); ra8875_putreg16(lcd, RA8875_VSAW0, y); - ra8875_putreg16(lcd, RA8875_HEAW0, (x+width-1)); - ra8875_putreg16(lcd, RA8875_VEAW0, (y+height-1)); + ra8875_putreg16(lcd, RA8875_HEAW0, (x + width - 1)); + ra8875_putreg16(lcd, RA8875_VEAW0, (y + height - 1)); #endif } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_setbackground * * Description: * Set the background color to use for the BTE engine * - **************************************************************************************/ + ****************************************************************************/ -static inline void ra8875_setbackground(FAR struct ra8875_lcd_s *lcd, uint16_t color) +static inline void ra8875_setbackground(FAR struct ra8875_lcd_s *lcd, + uint16_t color) { ra8875_putreg(lcd, RA8875_BGCR0, RA8875_UNPACK_RED(color)); ra8875_putreg(lcd, RA8875_BGCR1, RA8875_UNPACK_GREEN(color)); ra8875_putreg(lcd, RA8875_BGCR2, RA8875_UNPACK_BLUE(color)); } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_setforeground * * Description: * Set the foreground color to use for the BTE engine * - **************************************************************************************/ + ****************************************************************************/ -static inline void ra8875_setforeground(FAR struct ra8875_lcd_s *lcd, uint16_t color) +static inline void ra8875_setforeground(FAR struct ra8875_lcd_s *lcd, + uint16_t color) { ra8875_putreg(lcd, RA8875_FGCR0, RA8875_UNPACK_RED(color)); ra8875_putreg(lcd, RA8875_FGCR1, RA8875_UNPACK_GREEN(color)); ra8875_putreg(lcd, RA8875_FGCR2, RA8875_UNPACK_BLUE(color)); } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_clearmem * * Description: * * - **************************************************************************************/ + ****************************************************************************/ static void ra8875_clearmem(FAR struct ra8875_lcd_s *lcd) { @@ -518,14 +549,14 @@ static void ra8875_clearmem(FAR struct ra8875_lcd_s *lcd) lcdinfo("clearmem done\n"); } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_showrun * * Description: - * When LCD debug is enabled, try to reduce then amount of output data generated by - * ra8875_putrun and ra8875_getrun + * When LCD debug is enabled, try to reduce then amount of output data + * generated by ra8875_putrun and ra8875_getrun * - **************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_DEBUG_LCD static void ra8875_showrun(FAR struct ra8875_dev_s *priv, fb_coord_t row, @@ -533,7 +564,9 @@ static void ra8875_showrun(FAR struct ra8875_dev_s *priv, fb_coord_t row, { fb_coord_t nextrow = priv->lastrow + 1; - /* Has anything changed (other than the row is the next row in the sequence)? */ + /* Has anything changed + * (other than the row is the next row in the sequence)? + */ if (put == priv->put && row == nextrow && col == priv->col && npixels == priv->npixels) @@ -544,7 +577,8 @@ static void ra8875_showrun(FAR struct ra8875_dev_s *priv, fb_coord_t row, } else { - /* Yes... then this is the end of the preceding sequence. Output the last run + /* Yes... then this is the end of the preceding sequence. + * Output the last run * (if there were more than one run in the sequence). */ @@ -563,8 +597,8 @@ static void ra8875_showrun(FAR struct ra8875_dev_s *priv, fb_coord_t row, lcdinfo("%s row: %d col: %d npixels: %d\n", put ? "PUT" : "GET", row, col, npixels); - /* And save information about the run so that we can detect continuations - * of the sequence. + /* And save information about the run so that we can detect + * continuations of the sequence. */ priv->put = put; @@ -576,7 +610,7 @@ static void ra8875_showrun(FAR struct ra8875_dev_s *priv, fb_coord_t row, } #endif -/************************************************************************************** +/**************************************************************************** * Name: ra8875_putrun * * Description: @@ -588,9 +622,10 @@ static void ra8875_showrun(FAR struct ra8875_dev_s *priv, fb_coord_t row, * npixels - The number of pixels to write to the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ -static int ra8875_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, +static int ra8875_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, size_t npixels) { FAR struct ra8875_dev_s *priv = &g_lcddev; @@ -615,7 +650,8 @@ static int ra8875_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buff /* Set the cursor position */ - ra8875_set_mwcr0(priv, RA8875_MWCR0_MODE_GRAPHICS | RA8875_MWCR0_MEMDIR_LEFTRIGHT | + ra8875_set_mwcr0(priv, RA8875_MWCR0_MODE_GRAPHICS | + RA8875_MWCR0_MEMDIR_LEFTRIGHT | RA8875_MWCR0_WINC_ENABLE); ra8875_set_writecursor(priv, col, row); @@ -626,12 +662,14 @@ static int ra8875_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buff /* Retransform coordinates, write right to left */ - col = (RA8875_XRES-1) - col; - row = (RA8875_YRES-1) - row; + col = (RA8875_XRES - 1) - col; + row = (RA8875_YRES - 1) - row; /* Set the cursor position */ - ra8875_set_mwcr0(priv, RA8875_MWCR0_MODE_GRAPHICS | RA8875_MWCR0_MEMDIR_RIGHTLEFT | RA8875_MWCR0_WINC_ENABLE); + ra8875_set_mwcr0(priv, RA8875_MWCR0_MODE_GRAPHICS | + RA8875_MWCR0_MEMDIR_RIGHTLEFT | + RA8875_MWCR0_WINC_ENABLE); ra8875_set_writecursor(priv, col, row); curhinc = -npixels; @@ -639,11 +677,12 @@ static int ra8875_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buff #elif defined(CONFIG_LCD_PORTRAIT) - row = (RA8875_YRES-1) - row; + row = (RA8875_YRES - 1) - row; /* Set the cursor position */ - ra8875_set_mwcr0(priv, RA8875_MWCR0_MODE_GRAPHICS | RA8875_MWCR0_MEMDIR_TOPDOWN | + ra8875_set_mwcr0(priv, RA8875_MWCR0_MODE_GRAPHICS | + RA8875_MWCR0_MEMDIR_TOPDOWN | RA8875_MWCR0_WINC_ENABLE); ra8875_set_writecursor(priv, col, row); @@ -652,11 +691,12 @@ static int ra8875_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buff #else /* CONFIG_LCD_RPORTRAIT */ - col = (RA8875_XRES-1) - col; + col = (RA8875_XRES - 1) - col; /* Set the cursor position */ - ra8875_set_mwcr0(priv, RA8875_MWCR0_MODE_GRAPHICS | RA8875_MWCR0_MEMDIR_DOWNTOP | + ra8875_set_mwcr0(priv, RA8875_MWCR0_MODE_GRAPHICS | + RA8875_MWCR0_MEMDIR_DOWNTOP | RA8875_MWCR0_WINC_ENABLE); ra8875_set_writecursor(priv, col, row); @@ -690,7 +730,7 @@ static int ra8875_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buff return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_getrun * * Description: @@ -702,7 +742,7 @@ static int ra8875_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buff * npixels - The number of pixels to read from the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ static int ra8875_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, size_t npixels) @@ -718,7 +758,6 @@ static int ra8875_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, ra8875_showrun(priv, row, col, npixels, false); DEBUGASSERT(buffer && ((uintptr_t)buffer & 1) == 0); - #ifdef CONFIG_LCD_LANDSCAPE /* Set the cursor position */ @@ -732,8 +771,8 @@ static int ra8875_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, #elif defined(CONFIG_LCD_RLANDSCAPE) /* Retransform coordinates, write right to left */ - col = (RA8875_XRES-1) - col; - row = (RA8875_YRES-1) - row; + col = (RA8875_XRES - 1) - col; + row = (RA8875_YRES - 1) - row; /* Set the cursor position */ @@ -747,7 +786,7 @@ static int ra8875_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, #elif defined(CONFIG_LCD_PORTRAIT) /* Retransform coordinates, write right to left */ - row = (RA8875_YRES-1) - row; + row = (RA8875_YRES - 1) - row; /* Set the cursor position */ @@ -761,7 +800,7 @@ static int ra8875_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, #else /* CONFIG_LCD_RPORTRAIT */ /* Retransform coordinates, write right to left */ - col = (RA8875_XRES-1) - col; + col = (RA8875_XRES - 1) - col; /* Set the cursor position */ @@ -793,13 +832,13 @@ static int ra8875_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, #endif } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_getvideoinfo * * Description: * Get information about the LCD video controller configuration. * - **************************************************************************************/ + ****************************************************************************/ static int ra8875_getvideoinfo(FAR struct lcd_dev_s *dev, FAR struct fb_videoinfo_s *vinfo) @@ -815,16 +854,17 @@ static int ra8875_getvideoinfo(FAR struct lcd_dev_s *dev, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_getplaneinfo * * Description: * Get information about the configuration of each LCD color plane. * - **************************************************************************************/ + ****************************************************************************/ -static int ra8875_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo) +static int ra8875_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo) { FAR struct ra8875_dev_s *priv = (FAR struct ra8875_dev_s *)dev; @@ -838,14 +878,15 @@ static int ra8875_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_getpower * * Description: - * Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Get the LCD panel power status + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int ra8875_getpower(FAR struct lcd_dev_s *dev) { @@ -853,14 +894,15 @@ static int ra8875_getpower(FAR struct lcd_dev_s *dev) return g_lcddev.power; } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_poweroff * * Description: - * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Enable/disable LCD panel power + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int ra8875_poweroff(FAR struct ra8875_lcd_s *lcd) { @@ -879,14 +921,15 @@ static int ra8875_poweroff(FAR struct ra8875_lcd_s *lcd) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_setpower * * Description: - * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Enable/disable LCD panel power + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int ra8875_setpower(FAR struct lcd_dev_s *dev, int power) { @@ -905,7 +948,8 @@ static int ra8875_setpower(FAR struct lcd_dev_s *dev, int power) /* Set the backlight level */ ra8875_putreg(lcd, RA8875_P1CR, RA8875_P1CR_PWM_ENABLE); - ra8875_putreg(lcd, RA8875_P1CR, RA8875_P1CR_PWM_ENABLE | RA8875_P1CR_CSDIV(1)); + ra8875_putreg(lcd, RA8875_P1CR, + RA8875_P1CR_PWM_ENABLE | RA8875_P1CR_CSDIV(1)); } ra8875_putreg(lcd, RA8875_P1DCR, power); @@ -926,13 +970,13 @@ static int ra8875_setpower(FAR struct lcd_dev_s *dev, int power) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_getcontrast * * Description: * Get the current contrast setting (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int ra8875_getcontrast(FAR struct lcd_dev_s *dev) { @@ -940,27 +984,28 @@ static int ra8875_getcontrast(FAR struct lcd_dev_s *dev) return -ENOSYS; } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_setcontrast * * Description: * Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ -static int ra8875_setcontrast(FAR struct lcd_dev_s *dev, unsigned int contrast) +static int ra8875_setcontrast(FAR struct lcd_dev_s *dev, + unsigned int contrast) { lcdinfo("contrast: %d\n", contrast); return -ENOSYS; } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_hwinitialize * * Description: * Initialize the LCD hardware. * - **************************************************************************************/ + ****************************************************************************/ static inline int ra8875_hwinitialize(FAR struct ra8875_dev_s *priv) { @@ -1000,7 +1045,8 @@ static inline int ra8875_hwinitialize(FAR struct ra8875_dev_s *priv) /* Pixel clock, invert + 4*SYS */ - ra8875_putreg(lcd, RA8875_PCSR, RA8875_PCSR_PCLK_INV | RA8875_PCSR_PERIOD_4SYS); + ra8875_putreg(lcd, RA8875_PCSR, + RA8875_PCSR_PCLK_INV | RA8875_PCSR_PERIOD_4SYS); up_mdelay(1); /* Horizontal Settings */ @@ -1056,19 +1102,20 @@ static inline int ra8875_hwinitialize(FAR struct ra8875_dev_s *priv) return OK; } -/************************************************************************************** +/**************************************************************************** * Public Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: ra8875_lcdinitialize * * Description: - * Initialize the LCD video hardware. The initial state of the LCD is fully - * initialized, display memory cleared, and the LCD ready to use, but with the power - * setting at 0 (full off). + * Initialize the LCD video hardware. + * The initial state of the LCD is fully initialized, display memory + * cleared, and the LCD ready to use, but with the power setting at 0 + * (full off). * - **************************************************************************************/ + ****************************************************************************/ FAR struct lcd_dev_s *ra8875_lcdinitialize(FAR struct ra8875_lcd_s *lcd) { @@ -1076,9 +1123,10 @@ FAR struct lcd_dev_s *ra8875_lcdinitialize(FAR struct ra8875_lcd_s *lcd) lcdinfo("Initializing\n"); - /* If we could support multiple RA8875 devices, this is where we would allocate - * a new driver data structure... but we can't. Why not? Because of a bad should - * the form of the getrun() and putrun methods. + /* If we could support multiple RA8875 devices, this is where we would + * allocate a new driver data structure... but we can't. + * Why not? Because of a bad should the form of the getrun() and putrun + * methods. */ FAR struct ra8875_dev_s *priv = &g_lcddev; @@ -1114,19 +1162,20 @@ FAR struct lcd_dev_s *ra8875_lcdinitialize(FAR struct ra8875_lcd_s *lcd) return NULL; } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_clear * * Description: * This is a non-standard LCD interface just for the RA8875. Because - * of the various rotations, clearing the display in the normal way by writing a - * sequences of runs that covers the entire display can be very slow. Here the - * display is cleared by simply setting all video memory to the specified color. + * of the various rotations, clearing the display in the normal way by + * writing a sequences of runs that covers the entire display can be very + * slow. Here the display is cleared by simply setting all video memory to + * the specified color. * - * NOTE: This function is not available to applications in the protected or kernel - * build modes. + * NOTE: This function is not available to applications in the protected + * or kernel build modes. * - **************************************************************************************/ + ****************************************************************************/ void ra8875_clear(FAR struct lcd_dev_s *dev, uint16_t color) { @@ -1157,25 +1206,31 @@ void ra8875_clear(FAR struct lcd_dev_s *dev, uint16_t color) ra8875_drawrectangle(dev, 0, 0, RA8875_XRES, RA8875_YRES, color, true); } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_drawrectangle * - * This is a non-standard function to draw a rectangle on the LCD. This function is - * also used internally as part of the ra8875_clear implementation + * This is a non-standard function to draw a rectangle on the LCD. + * This function is also used internally as part of the ra8875_clear + * implementation * - * NOTE: This non-standard function is not available to applications in the - * protected or kernel build modes. + * NOTE: This non-standard function is not available to applications in + * the protected or kernel build modes. * - **************************************************************************************/ + ****************************************************************************/ -void ra8875_drawrectangle(FAR struct lcd_dev_s *dev, uint16_t x, uint16_t y, - uint16_t width, uint16_t height, uint16_t color, bool fill) +void ra8875_drawrectangle(FAR struct lcd_dev_s *dev, + uint16_t x, uint16_t y, + uint16_t width, uint16_t height, + uint16_t color, bool fill) { FAR struct ra8875_dev_s *priv = (FAR struct ra8875_dev_s *)dev; FAR struct ra8875_lcd_s *lcd = priv->lcd; uint8_t draw_cmd = RA8875_DCR_SQUARE; - uint16_t sx, sy, ex, ey; + uint16_t sx; + uint16_t sy; + uint16_t ex; + uint16_t ey; /* Set the color to use for filling */ @@ -1185,11 +1240,11 @@ void ra8875_drawrectangle(FAR struct lcd_dev_s *dev, uint16_t x, uint16_t y, if (width == 1) { - ra8875_drawline(dev, x, y, x, y+height, color); + ra8875_drawline(dev, x, y, x, y + height, color); } else if (height == 1) { - ra8875_drawline(dev, x, y, x+width, y, color); + ra8875_drawline(dev, x, y, x + width, y, color); } if (fill) @@ -1242,32 +1297,39 @@ void ra8875_drawrectangle(FAR struct lcd_dev_s *dev, uint16_t x, uint16_t y, ra8875_waitreg(lcd, RA8875_DCR, RA8875_DCR_LINE_START); } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_drawline * * Description: - * This is a non-standard function to draw a line on the LCD. This function is - * also used internally as part of the ra8875_rectandle implementation. + * This is a non-standard function to draw a line on the LCD. + * This function is also used internally as part of the + * ra8875_rectandle implementation. * - * NOTE: This non-standard function is not available to applications in the - * protected or kernel build modes. + * NOTE: This non-standard function is not available to applications in + * the protected or kernel build modes. * - **************************************************************************************/ + ****************************************************************************/ -void ra8875_drawline(FAR struct lcd_dev_s *dev, uint16_t x1, uint16_t y1, uint16_t x2, - uint16_t y2, uint16_t color) +void ra8875_drawline(FAR struct lcd_dev_s *dev, + uint16_t x1, uint16_t y1, + uint16_t x2, uint16_t y2, + uint16_t color) { FAR struct ra8875_dev_s *priv = (FAR struct ra8875_dev_s *)dev; FAR struct ra8875_lcd_s *lcd = priv->lcd; uint8_t draw_cmd = RA8875_DCR_LINE; - uint16_t sx, sy, ex, ey; + uint16_t sx; + uint16_t sy; + uint16_t ex; + uint16_t ey; /* Set the color to use for filling */ ra8875_setforeground(lcd, color); /* Handle degenerate cases */ + /* Setup coordinates */ #if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE) @@ -1299,28 +1361,35 @@ void ra8875_drawline(FAR struct lcd_dev_s *dev, uint16_t x1, uint16_t y1, uint16 ra8875_waitreg(lcd, RA8875_DCR, RA8875_DCR_LINE_START); } -/************************************************************************************** +/**************************************************************************** * Name: ra8875_drawtriangle * * Description: - * This is a non-standard function to draw a triangle on the LCD. This function is - * also used internally as part of the ra8875_rectandle implementation. + * This is a non-standard function to draw a triangle on the LCD. + * This function is also used internally as part of the ra8875_rectandle + * implementation. * * NOTE: This non-standard function is not available to applications in the * protected or kernel build modes. * - **************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_LCD_RA8875_EXTENDED -void ra8875_drawtriangle(FAR struct lcd_dev_s *dev, uint16_t x0, uint16_t y0, uint16_t x1, - uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color, bool fill) +void ra8875_drawtriangle(FAR struct lcd_dev_s *dev, + uint16_t x0, uint16_t y0, uint16_t x1, + uint16_t y1, uint16_t x2, uint16_t y2, + uint16_t color, bool fill) { FAR struct ra8875_dev_s *priv = (FAR struct ra8875_dev_s *)dev; FAR struct ra8875_lcd_s *lcd = priv->lcd; uint8_t draw_cmd = RA8875_DCR_TRIANGLE; - uint16_t _x0, _x1, _x2; - uint16_t _y0, _y1, _y2; + uint16_t _x0; + uint16_t _x1; + uint16_t _x2; + uint16_t _y0; + uint16_t _y1; + uint16_t _y2; /* Set the color to use for filling */ @@ -1371,27 +1440,30 @@ void ra8875_drawtriangle(FAR struct lcd_dev_s *dev, uint16_t x0, uint16_t y0, ui } #endif -/************************************************************************************** +/**************************************************************************** * Name: ra8875_drawcircle * * Description: - * This is a non-standard function to draw a circle on the LCD. This function is - * also used internally as part of the ra8875_rectandle implementation. + * This is a non-standard function to draw a circle on the LCD. + * This function is also used internally as part of the ra8875_rectandle + * implementation. * * NOTE: This non-standard function is not available to applications in the * protected or kernel build modes. * - **************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_LCD_RA8875_EXTENDED -void ra8875_drawcircle(FAR struct lcd_dev_s *dev, uint16_t x, uint16_t y, uint8_t radius, +void ra8875_drawcircle(FAR struct lcd_dev_s *dev, + uint16_t x, uint16_t y, uint8_t radius, uint16_t color, bool fill) { FAR struct ra8875_dev_s *priv = (FAR struct ra8875_dev_s *)dev; FAR struct ra8875_lcd_s *lcd = priv->lcd; uint8_t draw_cmd = 0; - uint16_t _x, _y; + uint16_t _x; + uint16_t _y; /* Set the color to use for filling */ @@ -1420,7 +1492,7 @@ void ra8875_drawcircle(FAR struct lcd_dev_s *dev, uint16_t x, uint16_t y, uint8_ ra8875_putreg16(lcd, RA8875_DCVR0, _y); ra8875_putreg(lcd, RA8875_DCRR, radius); - /* Run drawing */ + /* Run drawing */ ra8875_putreg(lcd, RA8875_DCR, draw_cmd); ra8875_putreg(lcd, RA8875_DCR, draw_cmd | RA8875_DCR_CIRCLE_START); diff --git a/drivers/lcd/ra8875.h b/drivers/lcd/ra8875.h index 0560351ae09..318fc0c46ea 100644 --- a/drivers/lcd/ra8875.h +++ b/drivers/lcd/ra8875.h @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/ra8875.h * Definitions for the RAiO Technologies RA8875 LCD controller * @@ -34,22 +34,22 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - **************************************************************************************/ + ****************************************************************************/ #ifndef __DRIVERS_LCD_RA8875_H #define __DRIVERS_LCD_RA8875_H -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ #include #ifdef CONFIG_LCD_RA8875 -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ /* RA8875 Register Addresses (All with RS=1) */ @@ -150,6 +150,7 @@ #define RA8875_DTPV1 0xAC /* Draw Triangle Point 2 Vertical Address Register 1 */ /* Bit definitions */ + /* Power and display control */ #define RA8875_PWRR_DISPLAY_OFF (0) diff --git a/drivers/lcd/s1d15g10.h b/drivers/lcd/s1d15g10.h index b39dafd27a7..a6cbb9b17d0 100644 --- a/drivers/lcd/s1d15g10.h +++ b/drivers/lcd/s1d15g10.h @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/s1d15g10.h * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,7 +16,7 @@ * License for the specific language governing permissions and limitations * under the License. * - **************************************************************************************/ + ****************************************************************************/ /* Definitions for the Epson S1D15G0 LCD controller * @@ -25,13 +25,13 @@ #ifndef __DRIVERS_LCD_S1D15G10_H #define __DRIVERS_LCD_S1D15G10_H -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ /* Epson S1D15G10 Command Set */ diff --git a/drivers/lcd/sd1329.h b/drivers/lcd/sd1329.h index 71e251c07d1..926150ecbdd 100644 --- a/drivers/lcd/sd1329.h +++ b/drivers/lcd/sd1329.h @@ -33,17 +33,18 @@ ****************************************************************************/ /* SD1329 Commands **********************************************************/ + /* Set column Address. * * This triple byte command specifies column start address and end address of * the display data RAM. This command also sets the column address pointer to - * column start address. This pointer is used to define the current read/write - * column address in graphic display data RAM. If horizontal address increment - * mode is enabled by command 0xa0, after finishing read/write one column data, - * it is incremented automatically to the next column address. Whenever the - * column address pointer finishes accessing the end column address, it is - * reset back to start column address and the row address is incremented to the - * next row. + * column start address. This pointer is used to define the current + * read/write column address in graphic display data RAM. If horizontal + * address increment mode is enabled by command 0xa0, after finishing + * read/write one column data, it is incremented automatically to the next + * column address. Whenever the column address pointer finishes accessing the + * end column address, it is reset back to start column address and the row + * address is incremented to the next row. * * Byte 1: 0x15 * Byte 2: A[5:0]: Start Address, range: 0x00-0x3f @@ -54,14 +55,14 @@ /* Set Row Address. * - * This triple byte command specifies row start address and end address of the - * display data RAM. This command also sets the row address pointer to row - * start address. This pointer is used to define the current read/write row - * address in graphic display data RAM. If vertical address increment mode is - * enabled by command 0xa0, after finishing read/write one row data, it is - * incremented automatically to the next row address. Whenever the row address - * pointer finishes accessing the end row address, it is reset back to start - * row address. + * This triple byte command specifies row start address and end address of + * the display data RAM. This command also sets the row address pointer to + * row start address. This pointer is used to define the current read/write + * row address in graphic display data RAM. If vertical address increment + * mode is enabled by command 0xa0, after finishing read/write one row data, + * it is incremented automatically to the next row address. Whenever the row + * address pointer finishes accessing the end row address, it is reset back + * to start row address. * * Byte 1: 0x75 * Byte 2: A[6:0]: Start Address, range: 0x00-0x7f @@ -116,9 +117,9 @@ /* Set Icon Current Range * - * This double byte command is used to set one fix current range for all icons - * between the range of 0uA and 127.5uA. The uniformity improves as the icon - * current range increases. + * This double byte command is used to set one fix current range for all + * icons between the range of 0uA and 127.5uA. The uniformity improves as + * the icon current range increases. * * Byte 1: 0x91 * Byte 2: A[7:0]: Max icon current: @@ -132,12 +133,13 @@ /* Set Individual Icon Current * - * This multiple byte command is used to fine tune the current for each of the - * 64 icons. Command 0x92 followed by 64 single byte data. These 64 byte data - * have to be entered in order to make this command function. Below is the - * formula for calculating the icon current. + * This multiple byte command is used to fine tune the current for each of + * the 64 icons. Command 0x92 followed by 64 single byte data. These 64 byte + * data have to be entered in order to make this command function. Below is + * the formula for calculating the icon current. * - * Icon Current = Single byte value / 127 x Maximum icon current set with command 0x91 + * Icon Current = Single byte value / 127 x Maximum icon current set with + * command 0x91 * * Byte 1: 0x92 * Byte 2-65: An[6:0]: icon current for ICSn, range: 0x00-0x7f @@ -148,8 +150,8 @@ /* Set Individual Icon ON / OFF Register * - * This double byte command is used to select one of the 64 icons and choose the - * ON, OFF or blinking condition of the selected icon. + * This double byte command is used to select one of the 64 icons and choose + * the ON, OFF or blinking condition of the selected icon. * * Byte 1: 0x93 * Byte 2: A[5:0]: Select one of the 64 icons from ICS0 ~ ICS63 @@ -163,7 +165,8 @@ /* Set Icon ON / OFF Registers * - * This double byte command is used to set the ON / OFF status of all 64 icons. + * This double byte command is used to set the ON / OFF status of all 64 + * icons. * * Byte 1: 0x94 * Byte 2: A[7:6]: OFF/ON/BLINK (Same as 0x93) @@ -198,8 +201,8 @@ /* Set Icon Duty * - * This double byte command is used to set the icon frame frequency and icon AC - * drive duty ratio. + * This double byte command is used to set the icon frame frequency and icon + * AC drive duty ratio. * * Byte 1: 0x96 * Byte 2: @@ -223,40 +226,42 @@ * described as follows: * * Column Address Remapping (A[0]) - * This bit is made for increase the flexibility layout of segment signals in - * OLED module with segment arranged from left to right (when A[0] is set to 0) - * or from right to left (when A[0] is set to 1). + * This bit is made for increase the flexibility layout of segment signals + * in OLED module with segment arranged from left to right (when A[0] is + * set to 0) or from right to left (when A[0] is set to 1). * * Nibble Remapping (A[1]) - * When A[1] is set to 1, the two nibbles of the data bus for RAM access are - * re-mapped, such that (D7, D6, D5, D4, D3, D2, D1, D0) acts like (D3, D2, D1, - * D0, D7, D6, D5, D4) If this feature works together with Column Address - * Re-map, it would produce an effect of flipping the outputs from SEG0-127 to - * SEG127-SEG0. + * When A[1] is set to 1, the two nibbles of the data bus for RAM access + * are re-mapped, such that (D7, D6, D5, D4, D3, D2, D1, D0) acts like + * (D3, D2, D1, D0, D7, D6, D5, D4) If this feature works together with + * Column Address Re-map, it would produce an effect of flipping the + * outputs from SEG0-127 to SEG127-SEG0. * * Address increment mode (A[2]) * When A[2] is set to 0, the driver is set as horizontal address incremen - * mode. After the display RAM is read/written, the column address pointer is - * increased automatically by 1. If the column address pointer reaches column - * end address, the column address pointer is reset to column start address and - * row address pointer is increased by 1. + * mode. After the display RAM is read/written, the column address pointer + * is increased automatically by 1. If the column address pointer reaches + * column end address, the column address pointer is reset to column start + * address and row address pointer is increased by 1. * - * When A[2] is set to 1, the driver is set to vertical address increment mode. - * After the display RAM is read/written, the row address pointer is increased - * automatically by 1. If the row address pointer reaches the row end address, - * the row address pointer is reset to row start address and column address - * pointer is increased by 1. + * When A[2] is set to 1, the driver is set to vertical address increment + * mode. + * After the display RAM is read/written, the row address pointer is + * increased automatically by 1. If the row address pointer reaches the row + * end address, the row address pointer is reset to row start address and + * column address pointer is increased by 1. * * COM Remapping (A[4]) - * This bit defines the scanning direction of the common for flexible layout - * of common signals in OLED module either from up to down (when A[4] is set to - * 0) or from bottom to up (when A[4] is set to 1). + * This bit defines the scanning direction of the common for flexible + * layout of common signals in OLED module either from up to down (when + * A[4] is set to 0) or from bottom to up (when A[4] is set to 1). * * Splitting of Odd / Even COM Signals (A[6]) - * This bit is made to match the COM layout connection on the panel. When A[6] - * is set to 0, no splitting odd / even of the COM signal is performed. When - * A[6] is set to 1, splitting odd / even of the COM signal is performed, - * output pin assignment sequence is shown as below (for 128MUX ratio): + * This bit is made to match the COM layout connection on the panel. + * When A[6] is set to 0, no splitting odd / even of the COM signal is + * performed. When A[6] is set to 1, splitting odd / even of the COM signal + * is performed, output pin assignment sequence is shown as below + * (for 128MUX ratio): * * Byte 1: 0xa0 * Byte 2: A[7:0] @@ -272,8 +277,8 @@ /* Set Display Start Line * * This double byte command is to set Display Start Line register for - * determining the starting address of display RAM to be displayed by selecting - * a value from 0 to 127. + * determining the starting address of display RAM to be displayed by + * selecting a value from 0 to 127. * * Byte 1: 0xa1 * Byte 2: A[6:0]: Vertical scroll by setting the starting address of @@ -284,9 +289,9 @@ /* Set Display Offset * - * This double byte command specifies the mapping of display start line (it is - * assumed that COM0 is the display start line, display start line register - * equals to 0) to one of COM0-COM127. + * This double byte command specifies the mapping of display start line + * (it is assumed that COM0 is the display start line, display start line + * register equals to 0) to one of COM0-COM127. * * Byte 1: 0xa2 * Byte 2: A[6:0]: Set vertical offset by COM from 0-127 @@ -296,24 +301,24 @@ /* Set Display Mode - Normal, all on, all off, inverse * - * These are single byte commands and are used to set display status to Normal - * Display, Entire Display ON, Entire Display OFF or Inverse Display. + * These are single byte commands and are used to set display status to + * Normal Display, Entire Display ON, Entire Display OFF or Inverse Display. * * Normal Display (0xa4) - * Reset the “Entire Display ON, Entire Display OFF or Inverse Display” effects - * and turn the data to ON at the corresponding gray level. + * Reset the “Entire Display ON, Entire Display OFF or Inverse Display” + * effects and turn the data to ON at the corresponding gray level. * * Set Entire Display ON (0xa5) - * Force the entire display to be at gray scale level GS15, regardless of the - * contents of the display data RAM. + * Force the entire display to be at gray scale level GS15, regardless + * of the contents of the display data RAM. * * Set Entire Display OFF (0xa6) - * Force the entire display to be at gray scale level GS0, regardless of the - * contents of the display data RAM. + * Force the entire display to be at gray scale level GS0, regardless + * of the contents of the display data RAM. * * Inverse Display (0xa7) - * The gray scale level of display data are swapped such that “GS0” <-> “GS15”, - * “GS1” <-> “GS14”, etc. + * The gray scale level of display data are swapped such that + * “GS0” <-> “GS15”, “GS1” <-> “GS14”, etc. * * Byte 1: Display mode command */ @@ -337,10 +342,10 @@ /* Set Sleep mode ON / OFF * * These single byte commands are used to turn the matrix display on the OLED - * panel display either ON or OFF. When the sleep mode is set to ON (0xae), the - * display is OFF, the segment and common output are in high impedance state - * and circuits will be turned OFF. When the sleep mode is set to OFF (0xaf), - * the display is ON. + * panel display either ON or OFF. When the sleep mode is set to ON (0xae), + * the display is OFF, the segment and common output are in high impedance + * state and circuits will be turned OFF. When the sleep mode is set to OFF + * (0xaf), the display is ON. * * Byte 1: sleep mode command */ @@ -350,13 +355,14 @@ /* Set Phase Length * - * In the second byte of this double command, lower nibble and higher nibble is - * defined separately. The lower nibble adjusts the phase length of Reset (phase - * 1). The higher nibble is used to select the phase length of first pre-charge - * phase (phase 2). The phase length is ranged from 1 to 16 DCLK's. RESET for - * A[3:0] is set to 3 which means 4 DCLK’s selected for Reset phase. POR for - * A[7:4] is set to 5 which means 6 DCLK’s is selected for first pre-charge - * phase. Please refer to Table 9-1 for detail breakdown levels of each step. + * In the second byte of this double command, lower nibble and higher nibble + * is defined separately. The lower nibble adjusts the phase length of Reset + * (phase 1). The higher nibble is used to select the phase length of first + * pre-charge phase (phase 2). The phase length is ranged from 1 to 16 + * DCLK's. RESET for A[3:0] is set to 3 which means 4 DCLK’s selected for + * Reset phase. POR for A[7:4] is set to 5 which means 6 DCLK’s is selected + * for first pre-charge phase. + * Please refer to Table 9-1 for detail breakdown levels of each step. * * Byte 1: 0xb1 * Byte 2: A[3:0]: Phase 1 period of 1~16 DCLK’s @@ -367,9 +373,9 @@ /* Set Frame Frequency * - * This double byte command is used to set the number of DCLK’s per row between - * the range of 0x14 and 0x7f. Then the Frame frequency of the matrix display - * is equal to DCLK frequency / A[6:0]. + * This double byte command is used to set the number of DCLK’s per row + * between the range of 0x14 and 0x7f. Then the Frame frequency of the + * matrix display is equal to DCLK frequency / A[6:0]. * * Byte 1: 0xb2 * Byte 2: A[6:0]:Total number of DCLK’s per row. Ranging from @@ -383,7 +389,8 @@ * This double command is used to set the frequency of the internal display * clocks, DCLK's. It is defined by dividing the oscillator frequency by the * divide ratio (Value from 1 to 16). Frame frequency is determined by divide - * ratio, number of display clocks per row, MUX ratio and oscillator frequency. + * ratio, number of display clocks per row, MUX ratio and oscillator + * frequency. * The lower nibble of the second byte is used to select the oscillator * frequency. Please refer to Table 9-1 for detail breakdown levels of each * step. @@ -408,7 +415,8 @@ /* Look Up Table for Gray Scale Pulse width * - * This command is used to set each individual gray scale level for the display. + * This command is used to set each individual gray scale level for the + * display. * Except gray scale level GS0 that has no pre-charge and current drive, each * gray scale level is programmed in the length of current drive stage pulse * width with unit of DCLK. The longer the length of the pulse width, the @@ -416,9 +424,10 @@ * * The setting of gray scale table entry can perform gamma correction on OLED * panel display. Normally, it is desired that the brightness response of the - * panel is linearly proportional to the image data value in display data RAM. - * However, the OLED panel is somehow responded in non-linear way. Appropriate - * gray scale table setting like example below can compensate this effect. + * panel is linearly proportional to the image data value in display data + * RAM. However, the OLED panel is somehow responded in non-linear way. + * Appropriate gray scale table setting like example below can compensate + * this effect. * * Byte 1: 0xb8 * Bytes 2-16: An[5:0], value for GSn level Pulse width @@ -428,9 +437,9 @@ /* Set Second Pre-charge Period * - * This double byte command is used to set the phase 3 second pre-charge period. - * The period of phase 3 can be programmed by command 0xbb and it is ranged from - * 0 to 15 DCLK's. + * This double byte command is used to set the phase 3 second pre-charge + * period. The period of phase 3 can be programmed by command 0xbb and it + * is ranged from 0 to 15 DCLK's. * * Byte 1: 0xbb * Byte 2: 0-15 DCLKs @@ -441,8 +450,8 @@ /* Set First Precharge voltage, VP * * This double byte command is used to set phase 2 first pre-charge voltage - * level. It can be programmed to set the first pre-charge voltage reference to - * VCC or VCOMH. + * level. It can be programmed to set the first pre-charge voltage reference + * to VCC or VCOMH. * * Byte 1: 0xbc * Byte 2: A[5] == 0, Pre-charge voltage is (0.30 + A[4:0]) * Vcc @@ -453,8 +462,8 @@ /* Set VCOMH * - * This double byte command sets the high voltage level of common pins, VCOMH. - * The level of VCOMH is programmed with reference to VCC. + * This double byte command sets the high voltage level of common pins, + * VCOMH. The level of VCOMH is programmed with reference to VCC. * * Byte 1: 0xbe * Byte 2: (0.51 + A[5:0]) * Vcc @@ -494,13 +503,14 @@ ****************************************************************************/ /**************************************************************************** - * Public Functions + * Public Functions Definitions ****************************************************************************/ #undef EXTERN #if defined(__cplusplus) #define EXTERN extern "C" -extern "C" { +extern "C" +{ #else #define EXTERN extern #endif diff --git a/drivers/lcd/skeleton.c b/drivers/lcd/skeleton.c index 77ef04a8e74..b34db01af78 100644 --- a/drivers/lcd/skeleton.c +++ b/drivers/lcd/skeleton.c @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/skeleton.c * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,11 +16,11 @@ * License for the specific language governing permissions and limitations * under the License. * - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ #include @@ -37,14 +37,16 @@ #include "up_arch.h" -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ + +/* Configuration ************************************************************/ -/* Configuration **********************************************************************/ /* Verify that all configuration requirements have been met */ -/* Debug ******************************************************************************/ +/* Debug ********************************************************************/ + /* Define the following to enable register-level debug output */ #undef CONFIG_LCD_SKELDEBUG @@ -60,7 +62,7 @@ # undef CONFIG_LCD_SKELDEBUG #endif -/* Color Properties *******************************************************************/ +/* Color Properties *********************************************************/ /* Display Resolution */ @@ -72,7 +74,7 @@ #define SKEL_BPP 16 #define SKEL_COLORFMT FB_FMT_RGB16_565 -/* Debug ******************************************************************************/ +/* Debug ********************************************************************/ #ifdef CONFIG_LCD_SKELDEBUG # define skelerr(format, ...) _err(format, ##__VA_ARGS__) @@ -84,9 +86,9 @@ # define skelinfo(x...) #endif -/************************************************************************************** +/**************************************************************************** * Private Type Definition - **************************************************************************************/ + ****************************************************************************/ /* This structure describes the state of this driver */ @@ -99,23 +101,26 @@ struct skel_dev_s /* Private LCD-specific information follows */ }; -/************************************************************************************** +/**************************************************************************** * Private Function Protototypes - **************************************************************************************/ + ****************************************************************************/ /* LCD Data Transfer Methods */ -static int skel_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, - size_t npixels); -static int skel_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, - size_t npixels); +static int skel_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, + size_t npixels); +static int skel_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t *buffer, + size_t npixels); /* LCD Configuration */ static int skel_getvideoinfo(FAR struct lcd_dev_s *dev, - FAR struct fb_videoinfo_s *vinfo); -static int skel_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo); + FAR struct fb_videoinfo_s *vinfo); +static int skel_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo); /* LCD RGB Mapping */ @@ -134,11 +139,12 @@ static int skel_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, static int skel_getpower(struct lcd_dev_s *dev); static int skel_setpower(struct lcd_dev_s *dev, int power); static int skel_getcontrast(struct lcd_dev_s *dev); -static int skel_setcontrast(struct lcd_dev_s *dev, unsigned int contrast); +static int skel_setcontrast(struct lcd_dev_s *dev, + unsigned int contrast); -/************************************************************************************** +/**************************************************************************** * Private Data - **************************************************************************************/ + ****************************************************************************/ /* This is working memory allocated by the LCD driver for each LCD device * and for each color plane. This memory will hold one raster line of data. @@ -185,6 +191,7 @@ static struct skel_dev_s g_lcddev = .getplaneinfo = skel_getplaneinfo, /* LCD RGB Mapping -- Not supported */ + /* Cursor Controls -- Not supported */ /* LCD Specific Controls */ @@ -196,11 +203,11 @@ static struct skel_dev_s g_lcddev = }, }; -/************************************************************************************** +/**************************************************************************** * Private Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: skel_putrun * * Description: @@ -212,9 +219,10 @@ static struct skel_dev_s g_lcddev = * npixels - The number of pixels to write to the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ -static int skel_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, +static int skel_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, size_t npixels) { /* Buffer must be provided and aligned to a 16-bit address boundary */ @@ -229,7 +237,7 @@ static int skel_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer return OK; } -/************************************************************************************** +/**************************************************************************** * Name: skel_getrun * * Description: @@ -241,7 +249,7 @@ static int skel_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer * npixels - The number of pixels to read from the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ static int skel_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, size_t npixels) @@ -255,34 +263,36 @@ static int skel_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, return -ENOSYS; } -/************************************************************************************** +/**************************************************************************** * Name: skel_getvideoinfo * * Description: * Get information about the LCD video controller configuration. * - **************************************************************************************/ + ****************************************************************************/ static int skel_getvideoinfo(FAR struct lcd_dev_s *dev, FAR struct fb_videoinfo_s *vinfo) { DEBUGASSERT(dev && vinfo); ginfo("fmt: %d xres: %d yres: %d nplanes: %d\n", - g_videoinfo.fmt, g_videoinfo.xres, g_videoinfo.yres, g_videoinfo.nplanes); + g_videoinfo.fmt, g_videoinfo.xres, + g_videoinfo.yres, g_videoinfo.nplanes); memcpy(vinfo, &g_videoinfo, sizeof(struct fb_videoinfo_s)); return OK; } -/************************************************************************************** +/**************************************************************************** * Name: skel_getplaneinfo * * Description: * Get information about the configuration of each LCD color plane. * - **************************************************************************************/ + ****************************************************************************/ -static int skel_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo) +static int skel_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo) { DEBUGASSERT(dev && pinfo && planeno == 0); ginfo("planeno: %d bpp: %d\n", planeno, g_planeinfo.bpp); @@ -290,14 +300,15 @@ static int skel_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: skel_getpower * * Description: - * Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Get the LCD panel power status + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int skel_getpower(struct lcd_dev_s *dev) { @@ -307,14 +318,15 @@ static int skel_getpower(struct lcd_dev_s *dev) return 0; } -/************************************************************************************** +/**************************************************************************** * Name: skel_setpower * * Description: - * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Enable/disable LCD panel power + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int skel_setpower(struct lcd_dev_s *dev, int power) { @@ -329,13 +341,13 @@ static int skel_setpower(struct lcd_dev_s *dev, int power) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: skel_getcontrast * * Description: * Get the current contrast setting (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int skel_getcontrast(struct lcd_dev_s *dev) { @@ -344,13 +356,13 @@ static int skel_getcontrast(struct lcd_dev_s *dev) return -ENOSYS; } -/************************************************************************************** +/**************************************************************************** * Name: skel_setcontrast * * Description: * Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int skel_setcontrast(struct lcd_dev_s *dev, unsigned int contrast) { @@ -359,19 +371,20 @@ static int skel_setcontrast(struct lcd_dev_s *dev, unsigned int contrast) return -ENOSYS; } -/************************************************************************************** +/**************************************************************************** * Public Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: up_oledinitialize * * Description: - * Initialize the LCD video hardware. The initial state of the LCD is fully - * initialized, display memory cleared, and the LCD ready to use, but with the power - * setting at 0 (full off). + * Initialize the LCD video hardware. + * The initial state of the LCD is fully initialized, display memory + * cleared, and the LCD ready to use, but with the power setting at 0 + * (full off). * - **************************************************************************************/ + ****************************************************************************/ FAR struct lcd_dev_s *up_oledinitialize(FAR struct spi_dev_s *spi) { diff --git a/drivers/lcd/ssd1289.c b/drivers/lcd/ssd1289.c index 0d809e08cc9..122df9bddbb 100644 --- a/drivers/lcd/ssd1289.c +++ b/drivers/lcd/ssd1289.c @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/ssd1289.c * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,18 +16,19 @@ * License for the specific language governing permissions and limitations * under the License. * - **************************************************************************************/ + ****************************************************************************/ -/* Generic LCD driver for LCDs based on the Solomon Systech SSD1289 LCD controller. - * Think of this as a template for an LCD driver that you will probably have to - * customize for any particular LCD hardware. +/* Generic LCD driver for LCDs based on the Solomon Systech SSD1289 LCD + * controller. + * Think of this as a template for an LCD driver that you will probably have + * to customize for any particular LCD hardware. * * References: SSD1289, Rev 1.3, Apr 2007, Solomon Systech Limited */ -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ #include @@ -47,10 +48,11 @@ #ifdef CONFIG_LCD_SSD1289 -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ -/* Configuration **********************************************************************/ + ****************************************************************************/ + +/* Configuration ************************************************************/ /* Check contrast selection */ @@ -86,7 +88,8 @@ # define CONFIG_LCD_LANDSCAPE 1 #endif -/* Display/Color Properties ***********************************************************/ +/* Display/Color Properties *************************************************/ + /* Display Resolution */ #if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE) @@ -102,16 +105,20 @@ #define SSD1289_BPP 16 #define SSD1289_COLORFMT FB_FMT_RGB16_565 -/* LCD Profiles ***********************************************************************/ -/* Many details of the controller initialization must, unfortunately, vary from LCD to - * LCD. I have looked at the spec and at three different drivers for LCDs that have - * SSD1289 controllers. I have tried to summarize these differences as "LCD profiles" +/* LCD Profiles *************************************************************/ + +/* Many details of the controller initialization must, unfortunately, vary + * from LCD to LCD. I have looked at the spec and at three different drivers + * for LCDs that have SSD1289 controllers. + * I have tried to summarize these differences as "LCD profiles" * * Most of the differences between LCDs are nothing more than a few minor bit * settings. The most significant difference between LCD drivers in is the - * manner in which the LCD is powered up and in how the power controls are set. - * My suggestion is that if you have working LCD initialization code, you should - * simply replace the code in ssd1289_hwinitialize with your working code. + * manner in which the LCD is powered up and in how the power controls are + * set. + * My suggestion is that if you have working LCD initialization code, you + * should simply replace the code in ssd1289_hwinitialize with your working + * code. */ #if defined (CONFIG_SSD1289_PROFILE2) @@ -128,16 +135,17 @@ # define PWRCTRL2_SETTING SSD1289_PWRCTRL2_VRC_5p1V /* PWRCTRL3: x 2.165 - * NOTE: Many drivers have bit 8 set which is not defined in the SSD1289 spec. + * NOTE: + * Many drivers have bit 8 set which is not defined in the SSD1289 spec. */ # define PWRCTRL3_SETTING SSD1289_PWRCTRL3_VRH_x2p165 - /* PWRCTRL4: VDV=9 + VCOMG */ + /* PWRCTRL4: VDV=9 + VCOMG */ # define PWRCTRL4_SETTING (SSD1289_PWRCTRL4_VDV(9) | SSD1289_PWRCTRL4_VCOMG) - /* PWRCTRL5: VCM=56 + NOTP */ + /* PWRCTRL5: VCM=56 + NOTP */ # define PWRCTRL5_SETTING (SSD1289_PWRCTRL5_VCM(56) | SSD1289_PWRCTRL5_NOTP) @@ -155,16 +163,17 @@ # define PWRCTRL2_SETTING SSD1289_PWRCTRL2_VRC_5p1V /* PWRCTRL3: x 2.165 - * NOTE: Many drivers have bit 8 set which is not defined in the SSD1289 spec. + * NOTE: + * Many drivers have bit 8 set which is not defined in the SSD1289 spec. */ # define PWRCTRL3_SETTING SSD1289_PWRCTRL3_VRH_x2p165 - /* PWRCTRL4: VDV=9 + VCOMG */ + /* PWRCTRL4: VDV=9 + VCOMG */ # define PWRCTRL4_SETTING (SSD1289_PWRCTRL4_VDV(9) | SSD1289_PWRCTRL4_VCOMG) - /* PWRCTRL5: VCM=56 + NOTP */ + /* PWRCTRL5: VCM=56 + NOTP */ # define PWRCTRL5_SETTING (SSD1289_PWRCTRL5_VCM(56) | SSD1289_PWRCTRL5_NOTP) @@ -183,24 +192,25 @@ # define PWRCTRL2_SETTING SSD1289_PWRCTRL2_VRC_5p3V /* PWRCTRL3: x 2.570 - * NOTE: Many drivers have bit 8 set which is not defined in the SSD1289 spec. + * NOTE: + * Many drivers have bit 8 set which is not defined in the SSD1289 spec. */ # define PWRCTRL3_SETTING SSD1289_PWRCTRL3_VRH_x2p570 - /* PWRCTRL4: VDV=12 + VCOMG */ + /* PWRCTRL4: VDV=12 + VCOMG */ # define PWRCTRL4_SETTING (SSD1289_PWRCTRL4_VDV(12) | SSD1289_PWRCTRL4_VCOMG) - /* PWRCTRL5: VCM=60 + NOTP */ + /* PWRCTRL5: VCM=60 + NOTP */ # define PWRCTRL5_SETTING (SSD1289_PWRCTRL5_VCM(60) | SSD1289_PWRCTRL5_NOTP) #endif -/************************************************************************************** +/**************************************************************************** * Private Type Definition - **************************************************************************************/ + ****************************************************************************/ /* This structure describes the state of this driver */ @@ -226,41 +236,51 @@ struct ssd1289_dev_s #endif /* This is working memory allocated by the LCD driver for each LCD device - * and for each color plane. This memory will hold one raster line of data. + * and for each color plane. This memory will hold one raster line of + * data. * The size of the allocated run buffer must therefore be at least * (bpp * xres / 8). Actual alignment of the buffer must conform to the * bitwidth of the underlying pixel type. * * If there are multiple planes, they may share the same working buffer * because different planes will not be operate on concurrently. However, - * if there are multiple LCD devices, they must each have unique run buffers. + * if there are multiple LCD devices, they must each have unique run + * buffers. */ uint16_t runbuffer[SSD1289_XRES]; }; -/************************************************************************************** +/**************************************************************************** * Private Function Protototypes - **************************************************************************************/ + ****************************************************************************/ + /* Low Level LCD access */ -static void ssd1289_putreg(FAR struct ssd1289_lcd_s *lcd, uint8_t regaddr, +static void ssd1289_putreg(FAR struct ssd1289_lcd_s *lcd, + uint8_t regaddr, uint16_t regval); #ifndef CONFIG_LCD_NOGETRUN -static uint16_t ssd1289_readreg(FAR struct ssd1289_lcd_s *lcd, uint8_t regaddr); +static uint16_t ssd1289_readreg(FAR struct ssd1289_lcd_s *lcd, + uint8_t regaddr); #endif -static inline void ssd1289_gramwrite(FAR struct ssd1289_lcd_s *lcd, uint16_t rgbcolor); +static inline void ssd1289_gramwrite(FAR struct ssd1289_lcd_s *lcd, + uint16_t rgbcolor); #ifndef CONFIG_LCD_NOGETRUN -static inline void ssd1289_readsetup(FAR struct ssd1289_lcd_s *lcd, FAR uint16_t *accum); -static inline uint16_t ssd1289_gramread(FAR struct ssd1289_lcd_s *lcd, FAR uint16_t *accum); +static inline void ssd1289_readsetup(FAR struct ssd1289_lcd_s *lcd, + FAR uint16_t *accum); +static inline uint16_t ssd1289_gramread(FAR struct ssd1289_lcd_s *lcd, + FAR uint16_t *accum); #endif -static void ssd1289_setcursor(FAR struct ssd1289_lcd_s *lcd, uint16_t column, +static void ssd1289_setcursor(FAR struct ssd1289_lcd_s *lcd, + uint16_t column, uint16_t row); /* LCD Data Transfer Methods */ #if 0 /* Sometimes useful */ -static void ssd1289_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npixels); +static void ssd1289_dumprun(FAR const char *msg, FAR uint16_t *run, + size_t npixels); #else # define ssd1289_dumprun(m,r,n) #endif @@ -272,17 +292,20 @@ static void ssd1289_showrun(FAR struct ssd1289_dev_s *priv, fb_coord_t row, # define ssd1289_showrun(p,r,c,n,b) #endif -static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, - size_t npixels); -static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, - size_t npixels); +static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, + size_t npixels); +static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t *buffer, + size_t npixels); /* LCD Configuration */ static int ssd1289_getvideoinfo(FAR struct lcd_dev_s *dev, - FAR struct fb_videoinfo_s *vinfo); -static int ssd1289_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo); + FAR struct fb_videoinfo_s *vinfo); +static int ssd1289_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo); /* LCD RGB Mapping */ @@ -301,101 +324,110 @@ static int ssd1289_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, static int ssd1289_getpower(FAR struct lcd_dev_s *dev); static int ssd1289_setpower(FAR struct lcd_dev_s *dev, int power); static int ssd1289_getcontrast(FAR struct lcd_dev_s *dev); -static int ssd1289_setcontrast(FAR struct lcd_dev_s *dev, unsigned int contrast); +static int ssd1289_setcontrast(FAR struct lcd_dev_s *dev, + unsigned int contrast); /* Initialization */ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv); -/************************************************************************************** +/**************************************************************************** * Private Data - **************************************************************************************/ + ****************************************************************************/ /* This driver can support only a signal SSD1289 device. This is due to an - * unfortunate decision made whent he getrun and putrun methods were designed. The - * following is the single SSD1289 driver state instance: + * unfortunate decision made whent he getrun and putrun methods were + * designed. The following is the single SSD1289 driver state instance: */ static struct ssd1289_dev_s g_lcddev; -/************************************************************************************** +/**************************************************************************** * Private Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_putreg(lcd, * * Description: * Write to an LCD register * - **************************************************************************************/ + ****************************************************************************/ -static void ssd1289_putreg(FAR struct ssd1289_lcd_s *lcd, uint8_t regaddr, uint16_t regval) +static void ssd1289_putreg(FAR struct ssd1289_lcd_s *lcd, + uint8_t regaddr, uint16_t regval) { - /* Set the index register to the register address and write the register contents */ + /* Set the index register to the register address and write the register + * contents + */ lcd->index(lcd, regaddr); lcd->write(lcd, regval); } -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_readreg * * Description: * Read from an LCD register * - **************************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_LCD_NOGETRUN -static uint16_t ssd1289_readreg(FAR struct ssd1289_lcd_s *lcd, uint8_t regaddr) +static uint16_t ssd1289_readreg(FAR struct ssd1289_lcd_s *lcd, + uint8_t regaddr) { - /* Set the index register to the register address and read the register contents */ + /* Set the index register to the register address and read the register + * contents + */ lcd->index(lcd, regaddr); return lcd->read(lcd); } #endif -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_gramselect * * Description: * Setup to read or write multiple pixels to the GRAM memory * - **************************************************************************************/ + ****************************************************************************/ static inline void ssd1289_gramselect(FAR struct ssd1289_lcd_s *lcd) { lcd->index(lcd, SSD1289_DATA); } -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_gramwrite * * Description: * Setup to read or write multiple pixels to the GRAM memory * - **************************************************************************************/ + ****************************************************************************/ -static inline void ssd1289_gramwrite(FAR struct ssd1289_lcd_s *lcd, uint16_t data) +static inline void ssd1289_gramwrite(FAR struct ssd1289_lcd_s *lcd, + uint16_t data) { lcd->write(lcd, data); } -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_readsetup * * Description: - * Prime the operation by reading one pixel from the GRAM memory if necessary for - * this LCD type. When reading 16-bit gram data, there may be some shifts in the - * returned data: + * Prime the operation by reading one pixel from the GRAM memory if + * necessary for this LCD type. When reading 16-bit gram data, there + * may be some shifts in the returned data: * * - ILI932x: Discard first dummy read; no shift in the return data * - **************************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_LCD_NOGETRUN -static inline void ssd1289_readsetup(FAR struct ssd1289_lcd_s *lcd, FAR uint16_t *accum) +static inline void ssd1289_readsetup(FAR struct ssd1289_lcd_s *lcd, + FAR uint16_t *accum) { /* Read-ahead one pixel */ @@ -403,19 +435,21 @@ static inline void ssd1289_readsetup(FAR struct ssd1289_lcd_s *lcd, FAR uint16_t } #endif -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_gramread * * Description: - * Read one correctly aligned pixel from the GRAM memory. Possibly shifting the - * data and possibly swapping red and green components. + * Read one correctly aligned pixel from the GRAM memory. + * Possibly shifting the data and possibly swapping red and green + * components. * * - ILI932x: Unknown -- assuming colors are in the color order * - **************************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_LCD_NOGETRUN -static inline uint16_t ssd1289_gramread(FAR struct ssd1289_lcd_s *lcd, FAR uint16_t *accum) +static inline uint16_t ssd1289_gramread(FAR struct ssd1289_lcd_s *lcd, + FAR uint16_t *accum) { /* Read the value (GRAM register already selected) */ @@ -423,16 +457,18 @@ static inline uint16_t ssd1289_gramread(FAR struct ssd1289_lcd_s *lcd, FAR uint1 } #endif -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_setcursor * * Description: - * Set the cursor position. In landscape mode, the "column" is actually the physical + * Set the cursor position. + * In landscape mode, the "column" is actually the physical * Y position and the "row" is the physical X position. * - **************************************************************************************/ + ****************************************************************************/ -static void ssd1289_setcursor(FAR struct ssd1289_lcd_s *lcd, uint16_t column, uint16_t row) +static void ssd1289_setcursor(FAR struct ssd1289_lcd_s *lcd, + uint16_t column, uint16_t row) { #if defined(CONFIG_LCD_PORTRAIT) || defined(CONFIG_LCD_RPORTRAIT) ssd1289_putreg(lcd, SSD1289_XADDR, column); /* 0-239 */ @@ -443,7 +479,7 @@ static void ssd1289_setcursor(FAR struct ssd1289_lcd_s *lcd, uint16_t column, ui #endif } -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_dumprun * * Description: @@ -452,12 +488,14 @@ static void ssd1289_setcursor(FAR struct ssd1289_lcd_s *lcd, uint16_t column, ui * run - The buffer in containing the run read to be dumped * npixels - The number of pixels to dump * - **************************************************************************************/ + ****************************************************************************/ #if 0 /* Sometimes useful */ -static void ssd1289_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npixels) +static void ssd1289_dumprun(FAR const char *msg, + FAR uint16_t *run, size_t npixels) { - int i, j; + int i; + int j; syslog(LOG_INFO, "\n%s:\n", msg); for (i = 0; i < npixels; i += 16) @@ -468,19 +506,20 @@ static void ssd1289_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npixe { syslog(LOG_INFO, " %04x", *run++); } + up_putc('\n'); } } #endif -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_showrun * * Description: - * When LCD debug is enabled, try to reduce then amount of output data generated by - * ssd1289_putrun and ssd1289_getrun + * When LCD debug is enabled, try to reduce then amount of output data + * generated by ssd1289_putrun and ssd1289_getrun * - **************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_DEBUG_LCD static void ssd1289_showrun(FAR struct ssd1289_dev_s *priv, fb_coord_t row, @@ -488,7 +527,9 @@ static void ssd1289_showrun(FAR struct ssd1289_dev_s *priv, fb_coord_t row, { fb_coord_t nextrow = priv->lastrow + 1; - /* Has anything changed (other than the row is the next row in the sequence)? */ + /* Has anything changed + * (other than the row is the next row in the sequence)? + */ if (put == priv->put && row == nextrow && col == priv->col && npixels == priv->npixels) @@ -499,7 +540,8 @@ static void ssd1289_showrun(FAR struct ssd1289_dev_s *priv, fb_coord_t row, } else { - /* Yes... then this is the end of the preceding sequence. Output the last run + /* Yes... then this is the end of the preceding sequence. + * Output the last run * (if there were more than one run in the sequence). */ @@ -518,8 +560,8 @@ static void ssd1289_showrun(FAR struct ssd1289_dev_s *priv, fb_coord_t row, lcdinfo("%s row: %d col: %d npixels: %d\n", put ? "PUT" : "GET", row, col, npixels); - /* And save information about the run so that we can detect continuations - * of the sequence. + /* And save information about the run so that we can detect + * continuations of the sequence. */ priv->put = put; @@ -531,7 +573,7 @@ static void ssd1289_showrun(FAR struct ssd1289_dev_s *priv, fb_coord_t row, } #endif -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_putrun * * Description: @@ -543,9 +585,10 @@ static void ssd1289_showrun(FAR struct ssd1289_dev_s *priv, fb_coord_t row, * npixels - The number of pixels to write to the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ -static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, +static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, size_t npixels) { FAR struct ssd1289_dev_s *priv = &g_lcddev; @@ -589,8 +632,8 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf * the STM3240G-EVAL is used as the top. */ - col = (SSD1289_XRES-1) - col; - row = (SSD1289_YRES-1) - row; + col = (SSD1289_XRES - 1) - col; + row = (SSD1289_YRES - 1) - row; /* Set the cursor position */ @@ -601,18 +644,21 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf ssd1289_gramselect(lcd); for (i = 0; i < npixels; i++) { - /* Write the next pixel to this position (auto-decrements to the next column) */ + /* Write the next pixel to this position + * (auto-decrements to the next column) + */ ssd1289_gramwrite(lcd, *src); src++; } #elif defined(CONFIG_LCD_PORTRAIT) - /* Convert coordinates. In this configuration, the top of the display is to the left - * of the buttons (if the board is held so that the buttons are at the bottom of the - * board). + /* Convert coordinates. + * In this configuration, the top of the display is to the left + * of the buttons (if the board is held so that the buttons are + * at the bottom of the board). */ - col = (SSD1289_XRES-1) - col; + col = (SSD1289_XRES - 1) - col; /* Then write the GRAM data, manually incrementing Y (which is col) */ @@ -635,7 +681,7 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf * board). */ - row = (SSD1289_YRES-1) - row; + row = (SSD1289_YRES - 1) - row; /* Then write the GRAM data, manually incrementing Y (which is col) */ @@ -660,7 +706,7 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_getrun * * Description: @@ -672,9 +718,10 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf * npixels - The number of pixels to read from the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ -static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, +static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t *buffer, size_t npixels) { #ifndef CONFIG_LCD_NOGETRUN @@ -718,8 +765,8 @@ static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, * the STM3240G-EVAL is used as the top. */ - col = (SSD1289_XRES-1) - col; - row = (SSD1289_YRES-1) - row; + col = (SSD1289_XRES - 1) - col; + row = (SSD1289_YRES - 1) - row; /* Set the cursor position */ @@ -735,17 +782,19 @@ static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, for (i = 0; i < npixels; i++) { - /* Read the next pixel from this position (autoincrements to the next row) */ + /* Read the next pixel from this position + * (autoincrements to the next row) + */ *dest++ = ssd1289_gramread(lcd, &accum); } #elif defined(CONFIG_LCD_PORTRAIT) - /* Convert coordinates. In this configuration, the top of the display is to the left - * of the buttons (if the board is held so that the buttons are at the bottom of the - * board). + /* Convert coordinates. In this configuration, the top of the display is + * to the left of the buttons (if the board is held so that the buttons + * are at the bottom of the board). */ - col = (SSD1289_XRES-1) - col; + col = (SSD1289_XRES - 1) - col; /* Then read the GRAM data, manually incrementing Y (which is col) */ @@ -768,7 +817,7 @@ static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, * board). */ - row = (SSD1289_YRES-1) - row; + row = (SSD1289_YRES - 1) - row; /* Then write the GRAM data, manually incrementing Y (which is col) */ @@ -796,13 +845,13 @@ static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, #endif } -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_getvideoinfo * * Description: * Get information about the LCD video controller configuration. * - **************************************************************************************/ + ****************************************************************************/ static int ssd1289_getvideoinfo(FAR struct lcd_dev_s *dev, FAR struct fb_videoinfo_s *vinfo) @@ -818,15 +867,16 @@ static int ssd1289_getvideoinfo(FAR struct lcd_dev_s *dev, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_getplaneinfo * * Description: * Get information about the configuration of each LCD color plane. * - **************************************************************************************/ + ****************************************************************************/ -static int ssd1289_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, +static int ssd1289_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, FAR struct lcd_planeinfo_s *pinfo) { FAR struct ssd1289_dev_s *priv = (FAR struct ssd1289_dev_s *)dev; @@ -841,14 +891,15 @@ static int ssd1289_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_getpower * * Description: - * Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Get the LCD panel power status + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int ssd1289_getpower(FAR struct lcd_dev_s *dev) { @@ -856,14 +907,15 @@ static int ssd1289_getpower(FAR struct lcd_dev_s *dev) return g_lcddev.power; } -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_poweroff * * Description: - * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Enable/disable LCD panel power + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int ssd1289_poweroff(FAR struct ssd1289_lcd_s *lcd) { @@ -881,14 +933,15 @@ static int ssd1289_poweroff(FAR struct ssd1289_lcd_s *lcd) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_setpower * * Description: - * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Enable/disable LCD panel power + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int ssd1289_setpower(FAR struct lcd_dev_s *dev, int power) { @@ -926,13 +979,13 @@ static int ssd1289_setpower(FAR struct lcd_dev_s *dev, int power) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_getcontrast * * Description: * Get the current contrast setting (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int ssd1289_getcontrast(FAR struct lcd_dev_s *dev) { @@ -940,27 +993,28 @@ static int ssd1289_getcontrast(FAR struct lcd_dev_s *dev) return -ENOSYS; } -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_setcontrast * * Description: * Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ -static int ssd1289_setcontrast(FAR struct lcd_dev_s *dev, unsigned int contrast) +static int ssd1289_setcontrast(FAR struct lcd_dev_s *dev, + unsigned int contrast) { lcdinfo("contrast: %d\n", contrast); return -ENOSYS; } -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_hwinitialize * * Description: * Initialize the LCD hardware. * - **************************************************************************************/ + ****************************************************************************/ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv) { @@ -985,8 +1039,9 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv) lcdinfo("LCD ID: %04x\n", id); } - /* If we could not get the ID, then let's just assume that this is an SSD1289. - * Perhaps we have some early register access issues. This seems to happen. + /* If we could not get the ID, then let's just assume that this is an + * SSD1289. Perhaps we have some early register access issues. + * This seems to happen. * But then perhaps we should not even bother to read the device ID at all? */ @@ -1001,17 +1056,20 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv) if (id == SSD1289_DEVCODE_VALUE) #endif { - /* LCD controller configuration. Many details of the controller initialization - * must, unfortunately, vary from LCD to LCD. I have looked at the spec and at - * three different drivers for LCDs that have SSD1289 controllers. I have tried - * to summarize these differences as profiles (defined above). Some other - * alternatives are noted below. + /* LCD controller configuration. + * Many details of the controller initialization must, unfortunately, + * vary from LCD to LCD. I have looked at the spec and at three + * different drivers for LCDs that have SSD1289 controllers. I have + * tried to summarize these differences as profiles (defined above). + * Some other alternatives are noted below. * - * Most of the differences between LCDs are nothing more than a few minor bit - * settings. The most significant difference between LCD drivers in is the - * manner in which the LCD is powered up and in how the power controls are set. - * My suggestion is that if you have working LCD initialization code, you should - * simply replace the following guesses with your working code. + * Most of the differences between LCDs are nothing more than a few + * minor bit settings. The most significant difference between LCD + * drivers in is the manner in which the LCD is powered up and in how + * the power controls are set. + * My suggestion is that if you have working LCD initialization code, + * you should simply replace the following guesses with your working + * code. */ /* Most drivers just enable the oscillator */ @@ -1019,8 +1077,8 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv) #ifdef SSD1289_USE_SIMPLE_INIT ssd1289_putreg(lcd, SSD1289_OSCSTART, SSD1289_OSCSTART_OSCEN); #else - /* But one goes through a more complex start-up sequence. Something like the - * following: + /* But one goes through a more complex start-up sequence. + * Something like the following: * * First, put the display in INTERNAL operation: * D=INTERNAL(1) CM=0 DTE=0 GON=1 SPT=0 VLE=0 PT=0 @@ -1042,7 +1100,7 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv) (SSD1289_DSPCTRL_ON | SSD1289_DSPCTRL_GON | SSD1289_DSPCTRL_VLE(0))); - /* Take the LCD out of sleep mode */ + /* Take the LCD out of sleep mode */ ssd1289_putreg(lcd, SSD1289_SLEEP, 0); up_mdelay(30); @@ -1063,7 +1121,10 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv) ssd1289_putreg(lcd, SSD1289_PWRCTRL1, PWRCTRL1_SETTING); ssd1289_putreg(lcd, SSD1289_PWRCTRL2, PWRCTRL2_SETTING); - /* One driver adds a delay here.. I doubt that this is really necessary. */ + /* One driver adds a delay here.. I doubt that this is really + * necessary. + */ + /* up_mdelay(15); */ ssd1289_putreg(lcd, SSD1289_PWRCTRL3, PWRCTRL3_SETTING); @@ -1111,8 +1172,8 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv) ssd1289_putreg(lcd, SSD1289_ACCTRL, (SSD1289_ACCTRL_EOR | SSD1289_ACCTRL_BC)); - /* Take the LCD out of sleep mode (isn't this redundant in the non- - * simple case?) + /* Take the LCD out of sleep mode (isn't this redundant in the + * non-simple case?) */ ssd1289_putreg(lcd, SSD1289_SLEEP, 0); @@ -1129,6 +1190,7 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv) SSD1289_ENTRY_DMODE_RAM | SSD1289_ENTRY_DFM_65K)); #else /* LG=0, AM=1, ID=3, TY=2, DMODE=0, WMODE=0, OEDEF=0, TRANS=0, DRM=3 */ + /* Alternative TY=2 (But TY only applies in 262K color mode anyway) */ ssd1289_putreg(lcd, SSD1289_ENTRY, @@ -1143,6 +1205,7 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv) ssd1289_putreg(lcd, SSD1289_CMP2, 0); /* One driver puts a huge, 100 millisecond delay here */ + /* up_mdelay(100); */ /* Set Horizontal and vertical porch. @@ -1151,9 +1214,11 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv) */ ssd1289_putreg(lcd, SSD1289_HPORCH, - (28 << SSD1289_HPORCH_HBP_SHIFT) | (239 << SSD1289_HPORCH_XL_SHIFT)); + (28 << SSD1289_HPORCH_HBP_SHIFT) | + (239 << SSD1289_HPORCH_XL_SHIFT)); ssd1289_putreg(lcd, SSD1289_VPORCH, - (3 << SSD1289_VPORCH_VBP_SHIFT) | (0 << SSD1289_VPORCH_XFP_SHIFT)); + (3 << SSD1289_VPORCH_VBP_SHIFT) | + (0 << SSD1289_VPORCH_XFP_SHIFT)); /* Set display control. * D=ON(3), CM=0 (not 8-color), DTE=1, GON=1, SPT=0, VLE=1 PT=0 @@ -1189,7 +1254,8 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv) /* Horizontal start and end (0-239) */ ssd1289_putreg(lcd, SSD1289_HADDR, - (0 << SSD1289_HADDR_HSA_SHIFT) | (239 << SSD1289_HADDR_HEA_SHIFT)); + (0 << SSD1289_HADDR_HSA_SHIFT) | + (239 << SSD1289_HADDR_HEA_SHIFT)); /* Vertical start and end (0-319) */ @@ -1228,6 +1294,7 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv) ssd1289_gramselect(lcd); /* One driver has a 50 msec delay here */ + /* up_mdelay(50); */ ret = OK; @@ -1246,19 +1313,20 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv) return ret; } -/************************************************************************************** +/**************************************************************************** * Public Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_lcdinitialize * * Description: - * Initialize the LCD video hardware. The initial state of the LCD is fully - * initialized, display memory cleared, and the LCD ready to use, but with the power - * setting at 0 (full off). + * Initialize the LCD video hardware. + * The initial state of the LCD is fully initialized, display memory + * cleared, and the LCD ready to use, but with the power setting at 0 + * (full off). * - **************************************************************************************/ + ****************************************************************************/ FAR struct lcd_dev_s *ssd1289_lcdinitialize(FAR struct ssd1289_lcd_s *lcd) { @@ -1266,9 +1334,10 @@ FAR struct lcd_dev_s *ssd1289_lcdinitialize(FAR struct ssd1289_lcd_s *lcd) lcdinfo("Initializing\n"); - /* If we ccould support multiple SSD1289 devices, this is where we would allocate - * a new driver data structure... but we can't. Why not? Because of a bad should - * the form of the getrun() and putrun methods. + /* If we ccould support multiple SSD1289 devices, this is where we would + * allocate a new driver data structure... but we can't. + * Why not? Because of a bad should the form of the getrun() and + * putrun methods. */ FAR struct ssd1289_dev_s *priv = &g_lcddev; @@ -1301,16 +1370,17 @@ FAR struct lcd_dev_s *ssd1289_lcdinitialize(FAR struct ssd1289_lcd_s *lcd) return NULL; } -/************************************************************************************** +/**************************************************************************** * Name: ssd1289_clear * * Description: - * This is a non-standard LCD interface just for the stm3240g-EVAL board. Because - * of the various rotations, clearing the display in the normal way by writing a - * sequences of runs that covers the entire display can be very slow. Here the - * display is cleared by simply setting all GRAM memory to the specified color. + * This is a non-standard LCD interface just for the stm3240g-EVAL board. + * Because of the various rotations, clearing the display in the normal way + * by writing a sequences of runs that covers the entire display can be + * very slow. Here the display is cleared by simply setting all GRAM + * memory to the specified color. * - **************************************************************************************/ + ****************************************************************************/ void ssd1289_clear(FAR struct lcd_dev_s *dev, uint16_t color) { @@ -1327,7 +1397,9 @@ void ssd1289_clear(FAR struct lcd_dev_s *dev, uint16_t color) ssd1289_gramselect(lcd); - /* Copy color into all of GRAM. Orientation does not matter in this case. */ + /* Copy color into all of GRAM. + * Orientation does not matter in this case. + */ for (i = 0; i < SSD1289_XRES * SSD1289_YRES; i++) { diff --git a/drivers/lcd/ssd1289.h b/drivers/lcd/ssd1289.h index 1226bab9cd5..13bb1200c01 100644 --- a/drivers/lcd/ssd1289.h +++ b/drivers/lcd/ssd1289.h @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/ssd1289.h * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,7 +16,7 @@ * License for the specific language governing permissions and limitations * under the License. * - **************************************************************************************/ + ****************************************************************************/ /* Definitions for the Solomon Systech SSD1289 LCD controller * @@ -26,17 +26,17 @@ #ifndef __DRIVERS_LCD_SSD1289_H #define __DRIVERS_LCD_SSD1289_H -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ #include #ifdef CONFIG_LCD_SSD1289 -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ /* SSD1289 Register Addresses (All with DC=1) */ @@ -229,9 +229,11 @@ #define SSD1289_FCYCCTRL_EQ_SHIFT (8) /* Sets the equalizing period */ #define SSD1289_FCYCCTRL_EQ_MASK (3 << SSD1289_FCYCCTRL_EQ_SHIFT) # define SSD1289_FCYCCTRL_EQ(n) (((n)-1) << SSD1289_FCYCCTRL_EQ_SHIFT) /* n = 2-8 clocks */ + #define SSD1289_FCYCCTRL_SDT_SHIFT (12) /* Set delay amount from the gate output */ #define SSD1289_FCYCCTRL_SDT_MASK (3 << SSD1289_FCYCCTRL_SDT_SHIFT) # define SSD1289_FCYCCTRL_SDT(n) ((n) << SSD1289_FCYCCTRL_SDT_SHIFT) /* n = 1-3 clocks */ + #define SSD1289_FCYCCTRL_NO_SHIFT (14) /* Sets amount of non-overlap of the gate output */ #define SSD1289_FCYCCTRL_NO_MASK (3 << SSD1289_FCYCCTRL_NO_SHIFT) # define SSD1289_FCYCCTRL_NO(n) ((n) << SSD1289_FCYCCTRL_NO_SHIFT) /* n = 1-3 clocks */ diff --git a/drivers/lcd/ssd1305.h b/drivers/lcd/ssd1305.h index ae7005b938b..4e7bfc0150d 100644 --- a/drivers/lcd/ssd1305.h +++ b/drivers/lcd/ssd1305.h @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/ssd1305.h * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,7 +16,7 @@ * License for the specific language governing permissions and limitations * under the License. * - **************************************************************************************/ + ****************************************************************************/ /* Definitions for the Solomon Systech SSD1305 132x64 Dot Matrix OLED/PLED * Segment/Common Driver with C @@ -30,13 +30,14 @@ #ifndef __DRIVERS_LCD_SSD1305_H #define __DRIVERS_LCD_SSD1305_H -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ + /* General Definitions ******************************************************/ #define SSD1305_COLORA 0 @@ -72,6 +73,7 @@ /* Data 2: Color A: 31-63 */ /* Data 3: Color B: 31-63 */ /* Data 4: Color C: 31-63 */ + #define SSD1305_SETBANKCOLOR1 0x92 /* 0x92: Set bank 1-16 color */ # define SSD1305_SETBANK1(c) (c) /* Data 1, Bits 0-1: Bank 1 color */ # define SSD1305_SETBANK2(c) (c << 2) /* Data 1, Bits 2-3: Bank 2 color */ @@ -106,6 +108,7 @@ # define SSD1305_SETBANK30(c) (c << 2) /* Data 4, Bits 2-3: Bank 30 color */ # define SSD1305_SETBANK31(c) (c << 4) /* Data 4, Bits 4-5: Bank 31 color */ # define SSD1305_SETBANK32(c) (c << 6) /* Data 4, Bits 6-7: Bank 32 color */ + #define SSD1305_MAPCOL0 0xa0 /* 0xa0: Column address 0 is mapped to SEG0 */ #define SSD1305_MAPCOL131 0xa1 /* 0xa1: Column address 131 is mapped to SEG0 */ #define SSD1305_DISPRAM 0xa4 /* 0xa4: Resume to RAM content display */ @@ -152,9 +155,9 @@ # define SSD1305_COMCONFIG_NOREMAP 0x02 /* Data 1, Bit 5: 0=Disable COM Left/Right remap */ # define SSD1305_COMCONFIG_REMAP 0x22 /* Data 1, Bit 5: 1=Enable COM Left/Right remap */ #define SSD1305_SETVCOMHDESEL 0xdb /* 0xdb: Set VCOMH delselect level */ -# define SSD1305_VCOMH_x4p3 0x00 /* Data 1: ~0.43 x Vcc */ -# define SSD1305_VCOMH_x7p7 0x34 /* Data 1: ~0.77 x Vcc */ -# define SSD1305_VCOMH_x8p3 0x3c /* Data 1: ~0.83 x Vcc */ +# define SSD1305_VCOMH_X4P3 0x00 /* Data 1: ~0.43 x Vcc */ +# define SSD1305_VCOMH_X7P7 0x34 /* Data 1: ~0.77 x Vcc */ +# define SSD1305_VCOMH_X8P3 0x3c /* Data 1: ~0.83 x Vcc */ #define SSD1305_ENTER_RMWMODE 0xe0 /* 0xe0: Enter the Read Modify Write mode */ #define SSD1305_NOP 0xe3 /* 0xe3: NOP Command for no operation */ #define SSD1305_EXIT_RMWMODE 0xee /* 0xee: Leave the Read Modify Write mode */ diff --git a/drivers/lcd/st7565.c b/drivers/lcd/st7565.c index 08d9b1df392..ec9f7b3c903 100644 --- a/drivers/lcd/st7565.c +++ b/drivers/lcd/st7565.c @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/st7565.c * * Definitions for the ST7565 128x64 Dot Matrix LCD Driver with C @@ -45,11 +45,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ #include @@ -67,11 +67,11 @@ #include "st7565.h" -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ -/* Configuration **********************************************************************/ +/* Configuration ************************************************************/ /* ST7565 Configuration Settings: * @@ -83,7 +83,8 @@ * * Required LCD driver settings: * CONFIG_LCD_ST7565 - Enable ST7565 support - * CONFIG_LCD_MAXCONTRAST should be 255, but any value >0 and <=255 will be accepted. + * CONFIG_LCD_MAXCONTRAST should be 255, but any value >0 and <=255 will be + * accepted. * */ @@ -128,10 +129,9 @@ # warning "Optimal setting of CONFIG_LCD_MAXCONTRAST is 255" #endif -/* Color Properties *******************************************************************/ +/* Color Properties *********************************************************/ -/* The ST7565 display controller can handle a resolution of 128x64. - */ +/* The ST7565 display controller can handle a resolution of 128x64. */ /* Display Resolution */ @@ -155,9 +155,9 @@ /* Bytes per logical row andactual device row */ #define ST7565_XSTRIDE (ST7565_XRES >> 3) /* Pixels arrange "horizontally - * for user" */ + * for 'user' */ #define ST7565_YSTRIDE (ST7565_YRES >> 3) /* But actual device - * arrangement is "vertical" */ + * arrangement is 'vertical' */ /* The size of the shadow frame buffer */ @@ -168,9 +168,9 @@ #define LS_BIT (1 << 0) #define MS_BIT (1 << 7) -/************************************************************************************** +/**************************************************************************** * Private Type Definition - **************************************************************************************/ + ****************************************************************************/ /* This structure describes the state of this driver */ @@ -196,9 +196,9 @@ struct st7565_dev_s uint8_t fb[ST7565_FBSIZE]; }; -/************************************************************************************** +/**************************************************************************** * Private Function Prototypes - **************************************************************************************/ + ****************************************************************************/ /* Drivers helpers */ @@ -218,14 +218,16 @@ static inline int st7565_backlight(FAR struct st7565_dev_s *priv, int level); static int st7565_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t * buffer, size_t npixels); -static int st7565_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t * buffer, +static int st7565_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t * buffer, size_t npixels); /* LCD Configuration */ static int st7565_getvideoinfo(FAR struct lcd_dev_s *dev, FAR struct fb_videoinfo_s *vinfo); -static int st7565_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, +static int st7565_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, FAR struct lcd_planeinfo_s *pinfo); /* LCD RGB Mapping */ @@ -245,15 +247,16 @@ static int st7565_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, static int st7565_getpower(struct lcd_dev_s *dev); static int st7565_setpower(struct lcd_dev_s *dev, int power); static int st7565_getcontrast(struct lcd_dev_s *dev); -static int st7565_setcontrast(struct lcd_dev_s *dev, unsigned int contrast); +static int st7565_setcontrast(struct lcd_dev_s *dev, + unsigned int contrast); /* Initialization */ static inline void up_clear(FAR struct st7565_dev_s *priv); -/************************************************************************************** +/**************************************************************************** * Private Data - **************************************************************************************/ + ****************************************************************************/ /* This is working memory allocated by the LCD driver for each LCD device * and for each color plane. This memory will hold one raster line of data. @@ -312,11 +315,11 @@ static struct st7565_dev_s g_st7565dev = }, }; -/************************************************************************************** +/**************************************************************************** * Private Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: st7565_reset * * Description: @@ -324,7 +327,7 @@ static struct st7565_dev_s g_st7565dev = * * priv - A reference to the driver specific structure * - **************************************************************************************/ + ****************************************************************************/ static inline void st7565_reset(FAR struct st7565_dev_s *priv, bool on) { @@ -334,7 +337,7 @@ static inline void st7565_reset(FAR struct st7565_dev_s *priv, bool on) } } -/************************************************************************************** +/**************************************************************************** * Name: st7565_select * * Description: @@ -342,14 +345,14 @@ static inline void st7565_reset(FAR struct st7565_dev_s *priv, bool on) * * priv - A reference to the driver specific structure * - **************************************************************************************/ + ****************************************************************************/ static inline void st7565_select(FAR struct st7565_dev_s *priv) { priv->lcd->select(priv->lcd); } -/************************************************************************************** +/**************************************************************************** * Name: st7565_deselect * * Description: @@ -357,14 +360,14 @@ static inline void st7565_select(FAR struct st7565_dev_s *priv) * * priv - A reference to the driver specific structure * - **************************************************************************************/ + ****************************************************************************/ static inline void st7565_deselect(FAR struct st7565_dev_s *priv) { priv->lcd->deselect(priv->lcd); } -/************************************************************************************** +/**************************************************************************** * Name: st7565_cmddata * * Description: @@ -373,14 +376,14 @@ static inline void st7565_deselect(FAR struct st7565_dev_s *priv) * priv - A reference to the driver specific structure. * cmd - If true command mode will be selected. * - **************************************************************************************/ + ****************************************************************************/ static inline void st7565_cmddata(FAR struct st7565_dev_s *priv, bool cmd) { priv->lcd->cmddata(priv->lcd, cmd); } -/************************************************************************************** +/**************************************************************************** * Name: st7565_send_one_data * * Description: @@ -389,7 +392,7 @@ static inline void st7565_cmddata(FAR struct st7565_dev_s *priv, bool cmd) * priv - A reference to the driver specific structure. * data - Byte to send as data to LCD driver. * - **************************************************************************************/ + ****************************************************************************/ static inline int st7565_send_one_data(FAR struct st7565_dev_s *priv, uint8_t data) @@ -397,7 +400,7 @@ static inline int st7565_send_one_data(FAR struct st7565_dev_s *priv, return priv->lcd->senddata(priv->lcd, &data, 1); } -/************************************************************************************** +/**************************************************************************** * Name: st7565_send_data_buf * * Description: @@ -407,7 +410,7 @@ static inline int st7565_send_one_data(FAR struct st7565_dev_s *priv, * buf - Buffer sent as data to LCD driver. * size - Size of buffer in bytes. * - **************************************************************************************/ + ****************************************************************************/ static inline int st7565_send_data_buf(FAR struct st7565_dev_s *priv, FAR const uint8_t * buf, int size) @@ -415,7 +418,7 @@ static inline int st7565_send_data_buf(FAR struct st7565_dev_s *priv, return priv->lcd->senddata(priv->lcd, buf, size); } -/************************************************************************************** +/**************************************************************************** * Name: st7565_backlight * * Description: @@ -424,14 +427,14 @@ static inline int st7565_send_data_buf(FAR struct st7565_dev_s *priv, * priv - A reference to the driver specific structure. * level - Set backlight pwm from 0 CONFIG_LCD_MAXPOWER-1. * - **************************************************************************************/ + ****************************************************************************/ static inline int st7565_backlight(FAR struct st7565_dev_s *priv, int level) { return priv->lcd->backlight(priv->lcd, level); } -/************************************************************************************** +/**************************************************************************** * Name: st7565_putrun * * Description: @@ -443,7 +446,7 @@ static inline int st7565_backlight(FAR struct st7565_dev_s *priv, int level) * npixels - The number of pixels to write to the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ static int st7565_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t * buffer, size_t npixels) @@ -479,14 +482,15 @@ static int st7565_putrun(fb_coord_t row, fb_coord_t col, return OK; } - /* Get the page number. The range of 64 lines is divided up into eight pages - * of 8 lines each. + /* Get the page number. + * The range of 64 lines is divided up into eight pages of 8 lines each. */ page = row >> 3; - /* Update the shadow frame buffer memory. First determine the pixel position - * in the frame buffer memory. Pixels are organized like this: + /* Update the shadow frame buffer memory. + * First determine the pixel position in the frame buffer memory. + * Pixels are organized like this: * * --------+---+---+---+---+-...-+-----+ * Segment | 0 | 1 | 2 | 3 | ... | 131 | @@ -582,7 +586,7 @@ static int st7565_putrun(fb_coord_t row, fb_coord_t col, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: st7565_getrun * * TODO implement read function that possible in 8080bus @@ -596,9 +600,10 @@ static int st7565_putrun(fb_coord_t row, fb_coord_t col, * npixels - The number of pixels to read from the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ -static int st7565_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t * buffer, +static int st7565_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t * buffer, size_t npixels) { /* Because of this line of code, we will only be able to support a single @@ -633,14 +638,15 @@ static int st7565_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t * buffer, /* Then transfer the display data from the shadow frame buffer memory */ - /* Get the page number. The range of 64 lines is divided up into eight pages - * of 8 lines each. + /* Get the page number. + * The range of 64 lines is divided up into eight pages of 8 lines each. */ page = row >> 3; - /* Update the shadow frame buffer memory. First determine the pixel position - * in the frame buffer memory. Pixels are organized like this: + /* Update the shadow frame buffer memory. + * First determine the pixel position in the frame buffer memory. + * Pixels are organized like this: * * --------+---+---+---+---+-...-+-----+ * Segment | 0 | 1 | 2 | 3 | ... | 131 | @@ -679,8 +685,9 @@ static int st7565_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t * buffer, *buffer |= usrmask; } - /* Inc/Decrement to the next destination pixel. Hmmmm. It looks like this - * logic could write past the end of the user buffer. Revisit this! + /* Inc/Decrement to the next destination pixel. + * Hmmmm. It looks like this logic could write past the end of the + * user buffer. Revisit this! */ #ifdef CONFIG_LCD_PACKEDMSFIRST @@ -711,13 +718,13 @@ static int st7565_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t * buffer, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: st7565_getvideoinfo * * Description: * Get information about the LCD video controller configuration. * - **************************************************************************************/ + ****************************************************************************/ static int st7565_getvideoinfo(FAR struct lcd_dev_s *dev, FAR struct fb_videoinfo_s *vinfo) @@ -730,15 +737,16 @@ static int st7565_getvideoinfo(FAR struct lcd_dev_s *dev, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: st7565_getplaneinfo * * Description: * Get information about the configuration of each LCD color plane. * - **************************************************************************************/ + ****************************************************************************/ -static int st7565_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, +static int st7565_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, FAR struct lcd_planeinfo_s *pinfo) { DEBUGASSERT(dev && pinfo && planeno == 0); @@ -747,14 +755,15 @@ static int st7565_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: st7565_getpower * * Description: - * Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Get the LCD panel power status + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int st7565_getpower(struct lcd_dev_s *dev) { @@ -764,14 +773,15 @@ static int st7565_getpower(struct lcd_dev_s *dev) return priv->power_level; } -/************************************************************************************** +/**************************************************************************** * Name: st7565_setpower * * Description: - * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlight LCDs, this setting may correspond to the backlight setting. + * Enable/disable LCD panel power + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlight LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int st7565_setpower(struct lcd_dev_s *dev, int power) { @@ -819,13 +829,13 @@ static int st7565_setpower(struct lcd_dev_s *dev, int power) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: st7565_getcontrast * * Description: * Get the current contrast setting (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int st7565_getcontrast(struct lcd_dev_s *dev) { @@ -834,13 +844,13 @@ static int st7565_getcontrast(struct lcd_dev_s *dev) return (int)priv->contrast; } -/************************************************************************************** +/**************************************************************************** * Name: st7565_setcontrast * * Description: * Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int st7565_setcontrast(struct lcd_dev_s *dev, unsigned int contrast) { @@ -878,13 +888,13 @@ static int st7565_setcontrast(struct lcd_dev_s *dev, unsigned int contrast) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: up_clear * * Description: * Clear the display. * - **************************************************************************************/ + ****************************************************************************/ static inline void up_clear(FAR struct st7565_dev_s *priv) { @@ -928,11 +938,11 @@ static inline void up_clear(FAR struct st7565_dev_s *priv) st7565_deselect(priv); } -/************************************************************************************** +/**************************************************************************** * Public Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: st7565_initialize * * Description: @@ -952,7 +962,7 @@ static inline void up_clear(FAR struct st7565_dev_s *priv) * for the specified * OLED. NULL is returned on any failure. * - **************************************************************************************/ + ****************************************************************************/ FAR struct lcd_dev_s *st7565_initialize(FAR struct st7565_lcd_s *lcd, unsigned int devno) diff --git a/drivers/lcd/st7565.h b/drivers/lcd/st7565.h index cc9d17dd0f4..9d3a11bcbec 100644 --- a/drivers/lcd/st7565.h +++ b/drivers/lcd/st7565.h @@ -1,9 +1,6 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/st7565.h * - * Definitions for the ST7565 128x64 Dot Matrix LCD - * Driver with C - * * Copyright (C) 2014 Pierre-noel Bouteville. All rights reserved. * Author: Pierre-noel Boutevlle * @@ -16,10 +13,6 @@ * Copyright (C) 2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * - * References: SSD1305.pdf, "Solomon Systech SSD1305 136x64 Dot Matrix OLED/PLED - * Segment/Common Driver with Controller," Solomon Systech Limited, - * http://www.solomon-systech.com, May, 2008. - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -47,20 +40,29 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - **************************************************************************************/ + ****************************************************************************/ + +/* Definitions for the ST7565 128x64 Dot Matrix LCD + * Driver with C + * + * References: + * SSD1305.pdf, "Solomon Systech SSD1305 136x64 Dot Matrix OLED/PLED + * Segment/Common Driver with Controller," Solomon Systech Limited, + * http://www.solomon-systech.com, May, 2008. + */ #ifndef __DRIVERS_LCD_ST7565_H #define __DRIVERS_LCD_ST7565_H -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ -/* Fundamental Commands ***************************************************************/ +/* Fundamental Commands *****************************************************/ #define ST7565_DISPOFF 0xae /* 0xae: Display OFF (sleep mode) */ #define ST7565_DISPON 0xaf /* 0xaf: Display ON in normal mode */ @@ -139,8 +141,8 @@ #define ST7565_NOP 0xe3 /* 0xe3: NOP Command for no operation */ -/************************************************************************************** +/**************************************************************************** * Public Data - **************************************************************************************/ + ****************************************************************************/ #endif /* __DRIVERS_LCD_ST7565_H */ diff --git a/drivers/lcd/st7567.c b/drivers/lcd/st7567.c index 7aee6295093..75ad64c4f58 100644 --- a/drivers/lcd/st7567.c +++ b/drivers/lcd/st7567.c @@ -1,9 +1,6 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/st7567.c * - * Driver for the TM12864J1CCWGWA Display with the ST7567 LCD - * controller. - * * Copyright (C) 2013 Zilogic Systems. All rights reserved. * Author: Manikandan * @@ -12,9 +9,6 @@ * Copyright (C) 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * - * Reference: "Product Specification, OEL Display Module, ST7567", Univision - * Technology Inc., SAS1-6020-B, January 3, 2008. - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -42,11 +36,19 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/* Driver for the TM12864J1CCWGWA Display with the ST7567 LCD + * controller. + * + * Reference: + * "Product Specification, OEL Display Module, ST7567", Univision + * Technology Inc., SAS1-6020-B, January 3, 2008. + */ + +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ #include @@ -64,11 +66,11 @@ #include "st7567.h" -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ -/* Configuration **********************************************************************/ +/* Configuration ************************************************************/ /* ST7567 Configuration Settings: * @@ -85,7 +87,8 @@ * * Required LCD driver settings: * CONFIG_LCD_ST7567 - Enable ST7567 support - * CONFIG_LCD_MAXCONTRAST should be 255, but any value >0 and <=255 will be accepted. + * CONFIG_LCD_MAXCONTRAST should be 255, but any value >0 and <=255 will be + * accepted. * CONFIG_LCD_MAXPOWER should be 2: 0=off, 1=dim, 2=normal * * Required SPI driver settings: @@ -94,8 +97,8 @@ /* Verify that all configuration requirements have been met */ -/* The ST7567 spec says that is supports SPI mode 0,0 only. However, sometimes - * you need to tinker with these things. +/* The ST7567 spec says that is supports SPI mode 0,0 only. + * However, sometimes you need to tinker with these things. */ #ifndef CONFIG_ST7567_SPIMODE @@ -165,7 +168,7 @@ # error "CONFIG_SPI_CMDDATA must be defined in your NuttX configuration" #endif -/* Color Properties *******************************************************************/ +/* Color Properties *********************************************************/ /* The ST7567 display controller can handle a resolution of 128x64. */ @@ -203,9 +206,9 @@ #define LS_BIT (1 << 0) #define MS_BIT (1 << 7) -/************************************************************************************** +/**************************************************************************** * Private Type Definition - **************************************************************************************/ + ****************************************************************************/ /* This structure describes the state of this driver */ @@ -229,9 +232,9 @@ struct st7567_dev_s uint8_t fb[ST7567_FBSIZE]; }; -/************************************************************************************** +/**************************************************************************** * Private Function Protototypes - **************************************************************************************/ + ****************************************************************************/ /* SPI helpers */ @@ -240,17 +243,20 @@ static void st7567_deselect(FAR struct spi_dev_s *spi); /* LCD Data Transfer Methods */ -static int st7567_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, - size_t npixels); -static int st7567_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, - size_t npixels); +static int st7567_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, + size_t npixels); +static int st7567_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t *buffer, + size_t npixels); /* LCD Configuration */ static int st7567_getvideoinfo(FAR struct lcd_dev_s *dev, - FAR struct fb_videoinfo_s *vinfo); -static int st7567_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo); + FAR struct fb_videoinfo_s *vinfo); +static int st7567_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo); /* LCD RGB Mapping */ @@ -269,15 +275,16 @@ static int st7567_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, static int st7567_getpower(struct lcd_dev_s *dev); static int st7567_setpower(struct lcd_dev_s *dev, int power); static int st7567_getcontrast(struct lcd_dev_s *dev); -static int st7567_setcontrast(struct lcd_dev_s *dev, unsigned int contrast); +static int st7567_setcontrast(struct lcd_dev_s *dev, + unsigned int contrast); /* Initialization */ static inline void up_clear(FAR struct st7567_dev_s *priv); -/************************************************************************************** +/**************************************************************************** * Private Data - **************************************************************************************/ + ****************************************************************************/ /* This is working memory allocated by the LCD driver for each LCD device * and for each color plane. This memory will hold one raster line of data. @@ -336,11 +343,11 @@ static struct st7567_dev_s g_st7567dev = }, }; -/************************************************************************************** +/**************************************************************************** * Private Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: st7567_select * * Description: @@ -354,7 +361,7 @@ static struct st7567_dev_s g_st7567dev = * * Assumptions: * - **************************************************************************************/ + ****************************************************************************/ static void st7567_select(FAR struct spi_dev_s *spi) { @@ -377,7 +384,7 @@ static void st7567_select(FAR struct spi_dev_s *spi) #endif } -/************************************************************************************** +/**************************************************************************** * Name: st7567_deselect * * Description: @@ -391,7 +398,7 @@ static void st7567_select(FAR struct spi_dev_s *spi) * * Assumptions: * - **************************************************************************************/ + ****************************************************************************/ static void st7567_deselect(FAR struct spi_dev_s *spi) { @@ -401,7 +408,7 @@ static void st7567_deselect(FAR struct spi_dev_s *spi) SPI_LOCK(spi, false); } -/************************************************************************************** +/**************************************************************************** * Name: st7567_putrun * * Description: @@ -413,10 +420,11 @@ static void st7567_deselect(FAR struct spi_dev_s *spi) * npixels - The number of pixels to write to the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ -static int st7567_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, - size_t npixels) +static int st7567_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, + size_t npixels) { /* Because of this line of code, we will only be able to support a single * ST7567 device @@ -552,7 +560,7 @@ static int st7567_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buff return OK; } -/************************************************************************************** +/**************************************************************************** * Name: st7567_getrun * * Description: @@ -564,7 +572,7 @@ static int st7567_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buff * npixels - The number of pixels to read from the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ static int st7567_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, size_t npixels) @@ -681,34 +689,36 @@ static int st7567_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: st7567_getvideoinfo * * Description: * Get information about the LCD video controller configuration. * - **************************************************************************************/ + ****************************************************************************/ static int st7567_getvideoinfo(FAR struct lcd_dev_s *dev, FAR struct fb_videoinfo_s *vinfo) { DEBUGASSERT(dev && vinfo); ginfo("fmt: %d xres: %d yres: %d nplanes: %d\n", - g_videoinfo.fmt, g_videoinfo.xres, g_videoinfo.yres, g_videoinfo.nplanes); + g_videoinfo.fmt, g_videoinfo.xres, + g_videoinfo.yres, g_videoinfo.nplanes); memcpy(vinfo, &g_videoinfo, sizeof(struct fb_videoinfo_s)); return OK; } -/************************************************************************************** +/**************************************************************************** * Name: st7567_getplaneinfo * * Description: * Get information about the configuration of each LCD color plane. * - **************************************************************************************/ + ****************************************************************************/ -static int st7567_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo) +static int st7567_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo) { DEBUGASSERT(dev && pinfo && planeno == 0); ginfo("planeno: %d bpp: %d\n", planeno, g_planeinfo.bpp); @@ -716,14 +726,15 @@ static int st7567_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: st7567_getpower * * Description: - * Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Get the LCD panel power status + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int st7567_getpower(struct lcd_dev_s *dev) { @@ -733,14 +744,15 @@ static int st7567_getpower(struct lcd_dev_s *dev) return priv->powered; } -/************************************************************************************** +/**************************************************************************** * Name: st7567_setpower * * Description: - * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Enable/disable LCD panel power + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int st7567_setpower(struct lcd_dev_s *dev, int power) { @@ -772,13 +784,13 @@ static int st7567_setpower(struct lcd_dev_s *dev, int power) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: st7567_getcontrast * * Description: * Get the current contrast setting (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int st7567_getcontrast(struct lcd_dev_s *dev) { @@ -787,13 +799,13 @@ static int st7567_getcontrast(struct lcd_dev_s *dev) return (int)priv->contrast; } -/************************************************************************************** +/**************************************************************************** * Name: st7567_setcontrast * * Description: * Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int st7567_setcontrast(struct lcd_dev_s *dev, unsigned int contrast) { @@ -827,13 +839,13 @@ static int st7567_setcontrast(struct lcd_dev_s *dev, unsigned int contrast) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: up_clear * * Description: * Clear the display. * - **************************************************************************************/ + ****************************************************************************/ static inline void up_clear(FAR struct st7567_dev_s *priv) { @@ -877,11 +889,11 @@ static inline void up_clear(FAR struct st7567_dev_s *priv) st7567_deselect(spi); } -/************************************************************************************** +/**************************************************************************** * Public Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: st7567_initialize * * Description: @@ -892,17 +904,19 @@ static inline void up_clear(FAR struct st7567_dev_s *priv) * Input Parameters: * * spi - A reference to the SPI driver instance. - * devno - A value in the range of 0 throst7567h CONFIG_ST7567_NINTERFACES-1. + * devno - A value in the range of 0 throst7567h + * CONFIG_ST7567_NINTERFACES-1. * This allows support for multiple OLED devices. * * Returned Value: * - * On success, this function returns a reference to the LCD object for the specified - * OLED. NULL is returned on any failure. + * On success, this function returns a reference to the LCD object for the + * specified OLED. NULL is returned on any failure. * - **************************************************************************************/ + ****************************************************************************/ -FAR struct lcd_dev_s *st7567_initialize(FAR struct spi_dev_s *spi, unsigned int devno) +FAR struct lcd_dev_s *st7567_initialize(FAR struct spi_dev_s *spi, + unsigned int devno) { /* Configure and enable LCD */ diff --git a/drivers/lcd/st7567.h b/drivers/lcd/st7567.h index 384af3295c8..e523148922d 100644 --- a/drivers/lcd/st7567.h +++ b/drivers/lcd/st7567.h @@ -1,9 +1,6 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/st7567.h * - * Definitions for the ST7567 128x64 Dot Matrix LCD - * Driver with C - * * Copyright (C) 2013 Zilogic Systems. All rights reserved. * Author: Manikandan * @@ -12,10 +9,6 @@ * Copyright (C) 2010 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * - * References: SSD1305.pdf, "Solomon Systech SSD1305 136x64 Dot Matrix OLED/PLED - * Segment/Common Driver with Controller," Solomon Systech Limited, - * http://www.solomon-systech.com, May, 2008. - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -43,18 +36,27 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - **************************************************************************************/ + ****************************************************************************/ + +/* Definitions for the ST7567 128x64 Dot Matrix LCD + * Driver with C + * + * References: + * SSD1305.pdf, "Solomon Systech SSD1305 136x64 Dot Matrix OLED/PLED + * Segment/Common Driver with Controller," Solomon Systech Limited, + * http://www.solomon-systech.com, May, 2008. + */ #ifndef __DRIVERS_LCD_ST7567_H #define __DRIVERS_LCD_ST7567_H -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ /* Fundamental Commands *****************************************************/ diff --git a/drivers/lcd/st7735.h b/drivers/lcd/st7735.h index e94160e85e1..d7cd5256cd5 100644 --- a/drivers/lcd/st7735.h +++ b/drivers/lcd/st7735.h @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/st7735.h * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,18 +16,18 @@ * License for the specific language governing permissions and limitations * under the License. * - **************************************************************************************/ + ****************************************************************************/ #ifndef __DRIVERS_LCD_ST7735_H #define __DRIVERS_LCD_ST7735_H -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ #define ST7735_NOP 0x00 /* No Operation */ #define ST7735_SWRESET 0x01 /* Software Reset */ diff --git a/drivers/lcd/st7789.h b/drivers/lcd/st7789.h index 02cf6077b08..b8bb0a8e146 100644 --- a/drivers/lcd/st7789.h +++ b/drivers/lcd/st7789.h @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/st7789.h * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,18 +16,18 @@ * License for the specific language governing permissions and limitations * under the License. * - **************************************************************************************/ + ****************************************************************************/ #ifndef __DRIVERS_LCD_ST7789_H #define __DRIVERS_LCD_ST7789_H -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ #define ST7789_NOP 0x00 /* No Operation */ #define ST7789_SWRESET 0x01 /* Software Reset */ diff --git a/drivers/lcd/tda19988.h b/drivers/lcd/tda19988.h index e156e97bbfc..cfd0fc573ad 100644 --- a/drivers/lcd/tda19988.h +++ b/drivers/lcd/tda19988.h @@ -1,4 +1,4 @@ -/****************************************************************************************************** +/**************************************************************************** * drivers/lcd/tda19988.h * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,24 +16,26 @@ * License for the specific language governing permissions and limitations * under the License. * - ******************************************************************************************************/ + ****************************************************************************/ -/* Definitions for the TDA19988. The TDA19988 is a very low power and very small - * size High-Definition Multimedia Interface (HDMI) 1.4a transmitter - * +/* Definitions for the TDA19988. + * The TDA19988 is a very low power and very small size + * High-Definition Multimedia Interface (HDMI) 1.4a transmitter + */ #ifndef __DRIVERS_LCD_TDA19988_H #define __DRIVERS_LCD_TDA19988_H -/****************************************************************************************************** +/**************************************************************************** * Included Files - ******************************************************************************************************/ + ****************************************************************************/ -/****************************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - ******************************************************************************************************/ + ****************************************************************************/ + +/* CEC Registers ************************************************************/ -/* CEC Registers **************************************************************************************/ /* The device has two I2C interfaces CEC (0x34) and HDMI (0x70). */ #define CEC_FRO_IM_CLK_CTRL_REG 0xfb @@ -48,10 +50,11 @@ # define CEC_ENAMODS_RXSENS (1 << 2) # define CEC_ENABLE_ALL 0x87 -/* HDMI Memory Pages **********************************************************************************/ -/* HDMI Memory is accessed via page and address. The page must first be selected, then - * only the address is sent in order accessing memory locations within the selected - * page. +/* HDMI Memory Pages ********************************************************/ + +/* HDMI Memory is accessed via page and address. + * The page must first be selected, then only the address is sent in order + * accessing memory locations within the selected page. */ #define HDMI_CTRL_PAGE 0x00 /* General control page */ @@ -62,8 +65,8 @@ #define HDMI_HDCPOTP_PAGE 0x12 /* HDCP (TDA19988AHN and TDA19988AET only) and OTP */ #define HDMI_GAMUT_PAGE 0x13 /* Gamut-related metadata packets page */ -/* The page select register does not lie within the above pages. The value of 0xff is - * used for this access. +/* The page select register does not lie within the above pages. + * The value of 0xff is used for this access. */ #define HDMI_NO_PAGE 0xff @@ -262,7 +265,9 @@ #define HDMI_INFO_AUD MKREG(HDMI_INFO_PAGE, 0x80) #define HDMI_INFO_MPS MKREG(HDMI_INFO_PAGE, 0xa0) -/* Audio settings and content info packets page Registers and Bit Definitions */ +/* Audio settings and content info packets page Registers and Bit + * Definitions + */ #define HDMI_AUDIO_ENC_CTRL_REG MKREG(HDMI_AUDIO_PAGE, 0x0d) # define HDMI_AUDIO_ENC_CNTRL_DVI_MODE (0 << 2) diff --git a/drivers/lcd/ug-2864ambag01.c b/drivers/lcd/ug-2864ambag01.c index 44496178fac..4f436c35177 100644 --- a/drivers/lcd/ug-2864ambag01.c +++ b/drivers/lcd/ug-2864ambag01.c @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/ug-2864ambag01.c * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,19 +16,21 @@ * License for the specific language governing permissions and limitations * under the License. * - **************************************************************************************/ + ****************************************************************************/ -/* Driver for Univision UG-2864AMBAG01 OLED display (with SH1101A controller) in SPI - * mode +/* Driver for Univision UG-2864AMBAG01 OLED display (with SH1101A controller) + * in SPI mode * * References: - * 1. Product Specification (Preliminary), Part Name: OEL Display Module, Part ID: + * 1. Product Specification (Preliminary), + * Part Name: OEL Display Module, Part ID: * UG-2864AMBAG01, Doc No: SASI-9015-A, Univision Technology Inc. - * 2. SH1101A, 132 X 64 Dot Matrix OLED/PLED, Preliminary Segment/Common Driver with + * 2. SH1101A, 132 X 64 Dot Matrix OLED/PLED, + * Preliminary Segment/Common Driver with * Controller, Sino Wealth */ -/************************************************************************************** +/**************************************************************************** * Device memory organization: * * +----------------------------+ @@ -60,50 +62,50 @@ * Page 7 | | | | | | | * --------+----+---+---+---+-...-+-----+ * - * -----------------------------------+--------------------------------------- - * Landscape Display: | Reverse Landscape Display: - * --------+-----------------------+ | --------+---------------------------+ - * | Column | | | Column | - * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ - * Page 0 | 0 | 1 | 2 | | 131 | | Page 7 | 131 | 130 | 129 | | 0 | - * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ - * Page 1 | V | | Page 6 | ^ | - * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ - * Page 2 | V | | Page 5 | ^ | - * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ - * Page 3 | V | | Page 4 | ^ | - * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ - * Page 4 | V | | Page 3 | ^ | - * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ - * Page 5 | V | | Page 2 | ^ | - * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ - * Page 6 | V | | Page 1 | ^ | - * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ - * Page 7 | V | | Page 0 | ^ | - * --------+---+---+---+-...-+-----+ | --------+-----+-----+-----+-...-+---+ - * -----------------------------------+--------------------------------------- + * ----------------------------------+-------------------------------------- + * Landscape Display: | Reverse Landscape Display: + * --------+-----------------------+ | -------+---------------------------+ + * | Column | | | Column | + * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+ + * Page 0 | 0 | 1 | 2 | | 131 | | Page 7 | 131 | 130 | 129 | | 0 | + * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+ + * Page 1 | V | | Page 6 | ^ | + * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+ + * Page 2 | V | | Page 5 | ^ | + * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+ + * Page 3 | V | | Page 4 | ^ | + * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+ + * Page 4 | V | | Page 3 | ^ | + * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+ + * Page 5 | V | | Page 2 | ^ | + * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+ + * Page 6 | V | | Page 1 | ^ | + * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+ + * Page 7 | V | | Page 0 | ^ | + * --------+---+---+---+-...-+-----+ | -------+-----+-----+-----+-...-+---+ + * ----------------------------------+-------------------------------------- * - * -----------------------------------+--------------------------------------- - * Portrait Display: | Reverse Portrait Display: - * -----------+---------------------+ | -----------+---------------------+ - * | Page | | | Page | - * -----------+---+---+---+-...-+---+ | -----------+---+---+---+-...-+---+ - * Column 0 | 0 | 1 | 2 | | 7 | | Column 131 | 7 | 6 | 5 | | 0 | - * -----------+---+---+---+-...-+---+ | -----------+---+---+---+-...-+---+ - * Column 1 | > > > > > | | Column 130 | | - * -----------+---+---+---+-...-+---+ | -----------+---+---+---+-...-+---+ - * Column 2 | | | Column 129 | | - * -----------+---+---+---+-...-+---+ | -----------+---+---+---+-...-+---+ - * ... | | | ... | | - * -----------+---+---+---+-...-+---+ | -----------+---+---+---+-...-+---+ - * Column 131 | | | Column 0 | < < < < < | - * -----------+---+---+---+-...-+---+ | -----------+---+---+---+-...-+---+ - * -----------------------------------+---------------------------------------- - **************************************************************************************/ + * ----------------------------------+-------------------------------------- + * Portrait Display: | Reverse Portrait Display: + * -----------+---------------------+| -----------+---------------------+ + * | Page || | Page | + * -----------+---+---+---+-...-+---+| -----------+---+---+---+-...-+---+ + * Column 0 | 0 | 1 | 2 | | 7 || Column 131 | 7 | 6 | 5 | | 0 | + * -----------+---+---+---+-...-+---+| -----------+---+---+---+-...-+---+ + * Column 1 | > > > > > || Column 130 | | + * -----------+---+---+---+-...-+---+| -----------+---+---+---+-...-+---+ + * Column 2 | || Column 129 | | + * -----------+---+---+---+-...-+---+| -----------+---+---+---+-...-+---+ + * ... | || ... | | + * -----------+---+---+---+-...-+---+| -----------+---+---+---+-...-+---+ + * Column 131 | || Column 0 | < < < < < | + * -----------+---+---+---+-...-+---+| -----------+---+---+---+-...-+---+ + * ----------------------------------+-------------------------------------- + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ #include @@ -123,10 +125,12 @@ #ifdef CONFIG_LCD_UG2864AMBAG01 -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ -/* Configuration **********************************************************************/ + ****************************************************************************/ + +/* Configuration ************************************************************/ + /* Limitations of the current configuration that I hope to fix someday */ #if CONFIG_UG2864AMBAG01_NINTERFACES != 1 @@ -143,7 +147,7 @@ # undef CONFIG_LCD_RPORTRAIT #endif -/* SH1101A Commands *******************************************************************/ +/* SH1101A Commands *********************************************************/ #define SH1101A_SETCOLL(ad) (0x00 | ((ad) & 0x0f)) /* Set Lower Column Address: (00h - 0fh) */ #define SH1101A_SETCOLH(ad) (0x10 | ((ad) & 0x0f)) /* Set Higher Column Address: (10h - 1fh) */ @@ -190,11 +194,12 @@ #define SH1101A_STATUS_ONOFF (0x40) #define SH1101A_RDDATA(d) (d) /* Read Display Data */ -/* Color Properties *******************************************************************/ +/* Color Properties *********************************************************/ + /* Display Resolution * - * The SH1101A display controller can handle a resolution of 132x64. The UG-2864AMBAG01 - * on the base board is 128x64. + * The SH1101A display controller can handle a resolution of 132x64. + * The UG-2864AMBAG01 on the base board is 128x64. */ #define UG2864AMBAG01_DEV_XRES 128 /* Only 128 of 131 columns used */ @@ -248,9 +253,9 @@ #define LS_BIT (1 << 0) #define MS_BIT (1 << 7) -/************************************************************************************** +/**************************************************************************** * Private Type Definition - **************************************************************************************/ + ****************************************************************************/ /* This structure describes the state of this driver */ @@ -264,18 +269,18 @@ struct ug2864ambag01_dev_s uint8_t contrast; /* Current contrast setting */ bool on; /* true: display is on */ - - /* The SH1101A does not support reading from the display memory in SPI mode. - * Since there is 1 BPP and access is byte-by-byte, it is necessary to keep - * a shadow copy of the framebuffer memory. At 128x64, this amounts to 1KB. + /* The SH1101A does not support reading from the display memory in SPI + * mode. Since there is 1 BPP and access is byte-by-byte, it is necessary + * to keep a shadow copy of the framebuffer memory. At 128x64, this amounts + * to 1KB. */ uint8_t fb[UG2864AMBAG01_FBSIZE]; }; -/************************************************************************************** +/**************************************************************************** * Private Function Protototypes - **************************************************************************************/ + ****************************************************************************/ /* Low-level SPI helpers */ @@ -286,14 +291,16 @@ static void ug2864ambag01_unlock(FAR struct spi_dev_s *spi); static int ug2864ambag01_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, size_t npixels); -static int ug2864ambag01_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, +static int ug2864ambag01_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t *buffer, size_t npixels); /* LCD Configuration */ static int ug2864ambag01_getvideoinfo(FAR struct lcd_dev_s *dev, FAR struct fb_videoinfo_s *vinfo); -static int ug2864ambag01_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, +static int ug2864ambag01_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, FAR struct lcd_planeinfo_s *pinfo); /* LCD RGB Mapping */ @@ -313,11 +320,12 @@ static int ug2864ambag01_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int pl static int ug2864ambag01_getpower(struct lcd_dev_s *dev); static int ug2864ambag01_setpower(struct lcd_dev_s *dev, int power); static int ug2864ambag01_getcontrast(struct lcd_dev_s *dev); -static int ug2864ambag01_setcontrast(struct lcd_dev_s *dev, unsigned int contrast); +static int ug2864ambag01_setcontrast(struct lcd_dev_s *dev, + unsigned int contrast); -/************************************************************************************** +/**************************************************************************** * Private Data - **************************************************************************************/ + ****************************************************************************/ /* This is working memory allocated by the LCD driver for each LCD device * and for each color plane. This memory will hold one raster line of data. @@ -352,7 +360,9 @@ static const struct lcd_planeinfo_s g_planeinfo = .bpp = UG2864AMBAG01_BPP, /* Bits-per-pixel */ }; -/* This is the OLED driver instance (only a single device is supported for now) */ +/* This is the OLED driver instance + * (only a single device is supported for now) + */ static struct ug2864ambag01_dev_s g_oleddev = { @@ -364,6 +374,7 @@ static struct ug2864ambag01_dev_s g_oleddev = .getplaneinfo = ug2864ambag01_getplaneinfo, /* LCD RGB Mapping -- Not supported */ + /* Cursor Controls -- Not supported */ /* LCD Specific Controls */ @@ -375,11 +386,11 @@ static struct ug2864ambag01_dev_s g_oleddev = }, }; -/************************************************************************************** +/**************************************************************************** * Private Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: ug2864ambag01_lock * * Description: @@ -393,11 +404,13 @@ static struct ug2864ambag01_dev_s g_oleddev = * * Assumptions: * - **************************************************************************************/ + ****************************************************************************/ static inline void ug2864ambag01_lock(FAR struct spi_dev_s *spi) { - /* Lock the SPI bus if there are multiple devices competing for the SPI bus. */ + /* Lock the SPI bus if there are multiple devices competing for the SPI + * bus. + */ SPI_LOCK(spi, true); @@ -411,7 +424,7 @@ static inline void ug2864ambag01_lock(FAR struct spi_dev_s *spi) SPI_SETFREQUENCY(spi, CONFIG_UG2864AMBAG01_FREQUENCY); } -/************************************************************************************** +/**************************************************************************** * Name: ug2864ambag01_unlock * * Description: @@ -425,7 +438,7 @@ static inline void ug2864ambag01_lock(FAR struct spi_dev_s *spi) * * Assumptions: * - **************************************************************************************/ + ****************************************************************************/ static inline void ug2864ambag01_unlock(FAR struct spi_dev_s *spi) { @@ -434,7 +447,7 @@ static inline void ug2864ambag01_unlock(FAR struct spi_dev_s *spi) SPI_LOCK(spi, false); } -/************************************************************************************** +/**************************************************************************** * Name: ug2864ambag01_putrun * * Description: @@ -447,15 +460,19 @@ static inline void ug2864ambag01_unlock(FAR struct spi_dev_s *spi) * npixels - The number of pixels to write to the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ #if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE) -static int ug2864ambag01_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, +static int ug2864ambag01_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, size_t npixels) { - /* Because of this line of code, we will only be able to support a single UG device */ + /* Because of this line of code, we will only be able to support a single + * UG device + */ - FAR struct ug2864ambag01_dev_s *priv = (FAR struct ug2864ambag01_dev_s *)&g_oleddev; + FAR struct ug2864ambag01_dev_s *priv = + (FAR struct ug2864ambag01_dev_s *)&g_oleddev; FAR uint8_t *fbptr; FAR uint8_t *ptr; uint8_t devcol; @@ -471,7 +488,8 @@ static int ug2864ambag01_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_ /* Clip the run to the display */ pixlen = npixels; - if ((unsigned int)col + (unsigned int)pixlen > (unsigned int)UG2864AMBAG01_XRES) + if ((unsigned int)col + (unsigned int)pixlen > + (unsigned int)UG2864AMBAG01_XRES) { pixlen = (int)UG2864AMBAG01_XRES - (int)col; } @@ -489,7 +507,7 @@ static int ug2864ambag01_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_ */ #ifdef UG2864AMBAG01_DEV_REVERSEY - row = (UG2864AMBAG01_DEV_YRES-1) - row; + row = (UG2864AMBAG01_DEV_YRES - 1) - row; #endif /* If the column is switched then the start of the run is the mirror of @@ -506,7 +524,7 @@ static int ug2864ambag01_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_ */ #ifdef UG2864AMBAG01_DEV_REVERSEX - col = (UG2864AMBAG01_DEV_XRES-1) - col; + col = (UG2864AMBAG01_DEV_XRES - 1) - col; col -= (pixlen - 1); #endif @@ -617,6 +635,7 @@ static int ug2864ambag01_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_ SPI_CMDDATA(priv->spi, SPIDEV_DISPLAY(0), true); /* Set the starting position for the run */ + /* Set the column address to the XOFFSET value */ SPI_SEND(priv->spi, SH1101A_SETCOLL(devcol & 0x0f)); @@ -644,7 +663,7 @@ static int ug2864ambag01_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_ # error "Configuration not implemented" #endif -/************************************************************************************** +/**************************************************************************** * Name: ug2864ambag01_getrun * * Description: @@ -659,13 +678,16 @@ static int ug2864ambag01_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_ * npixels - The number of pixels to read from the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ #if defined(CONFIG_LCD_LANDSCAPE) || defined(CONFIG_LCD_RLANDSCAPE) -static int ug2864ambag01_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, +static int ug2864ambag01_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t *buffer, size_t npixels) { - /* Because of this line of code, we will only be able to support a single UG device */ + /* Because of this line of code, we will only be able to support a single + * UG device + */ FAR struct ug2864ambag01_dev_s *priv = &g_oleddev; FAR uint8_t *fbptr; @@ -681,7 +703,8 @@ static int ug2864ambag01_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buf /* Clip the run to the display */ pixlen = npixels; - if ((unsigned int)col + (unsigned int)pixlen > (unsigned int)UG2864AMBAG01_XRES) + if ((unsigned int)col + (unsigned int)pixlen > + (unsigned int)UG2864AMBAG01_XRES) { pixlen = (int)UG2864AMBAG01_XRES - (int)col; } @@ -699,7 +722,7 @@ static int ug2864ambag01_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buf */ #ifdef UG2864AMBAG01_DEV_REVERSEY - row = (UG2864AMBAG01_DEV_YRES-1) - row; + row = (UG2864AMBAG01_DEV_YRES - 1) - row; #endif /* If the column is switched then the start of the run is the mirror of @@ -716,10 +739,11 @@ static int ug2864ambag01_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buf */ #ifdef UG2864AMBAG01_DEV_REVERSEX - col = (UG2864AMBAG01_DEV_XRES-1) - col; + col = (UG2864AMBAG01_DEV_XRES - 1) - col; #endif /* Then transfer the display data from the shadow frame buffer memory */ + /* Get the page number. The range of 64 lines is divided up into eight * pages of 8 lines each. */ @@ -808,34 +832,36 @@ static int ug2864ambag01_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buf # error "Configuration not implemented" #endif -/************************************************************************************** +/**************************************************************************** * Name: ug2864ambag01_getvideoinfo * * Description: * Get information about the LCD video controller configuration. * - **************************************************************************************/ + ****************************************************************************/ static int ug2864ambag01_getvideoinfo(FAR struct lcd_dev_s *dev, FAR struct fb_videoinfo_s *vinfo) { DEBUGASSERT(dev && vinfo); lcdinfo("fmt: %d xres: %d yres: %d nplanes: %d\n", - g_videoinfo.fmt, g_videoinfo.xres, g_videoinfo.yres, g_videoinfo.nplanes); + g_videoinfo.fmt, g_videoinfo.xres, + g_videoinfo.yres, g_videoinfo.nplanes); memcpy(vinfo, &g_videoinfo, sizeof(struct fb_videoinfo_s)); return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ug2864ambag01_getplaneinfo * * Description: * Get information about the configuration of each LCD color plane. * - **************************************************************************************/ + ****************************************************************************/ -static int ug2864ambag01_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, - FAR struct lcd_planeinfo_s *pinfo) +static int ug2864ambag01_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, + FAR struct lcd_planeinfo_s *pinfo) { DEBUGASSERT(pinfo && planeno == 0); lcdinfo("planeno: %d bpp: %d\n", planeno, g_planeinfo.bpp); @@ -843,32 +869,35 @@ static int ug2864ambag01_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int pl return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ug2864ambag01_getpower * * Description: - * Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER: full on. On - * backlit LCDs, this setting may correspond to the backlight setting. + * Get the LCD panel power status + * (0: full off - CONFIG_LCD_MAXPOWER: full on.) + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int ug2864ambag01_getpower(FAR struct lcd_dev_s *dev) { - FAR struct ug2864ambag01_dev_s *priv = (FAR struct ug2864ambag01_dev_s *)dev; + FAR struct ug2864ambag01_dev_s *priv = + (FAR struct ug2864ambag01_dev_s *)dev; DEBUGASSERT(priv); lcdinfo("power: %s\n", priv->on ? "ON" : "OFF"); return priv->on ? CONFIG_LCD_MAXPOWER : 0; } -/************************************************************************************** +/**************************************************************************** * Name: ug2864ambag01_setpower * * Description: - * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On + * Enable/disable LCD panel power + * (0: full off - CONFIG_LCD_MAXPOWER: full on). On * backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int ug2864ambag01_setpower(struct lcd_dev_s *dev, int power) { @@ -904,13 +933,13 @@ static int ug2864ambag01_setpower(struct lcd_dev_s *dev, int power) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ug2864ambag01_getcontrast * * Description: * Get the current contrast setting (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int ug2864ambag01_getcontrast(struct lcd_dev_s *dev) { @@ -921,15 +950,16 @@ static int ug2864ambag01_getcontrast(struct lcd_dev_s *dev) return priv->contrast; } -/************************************************************************************** +/**************************************************************************** * Name: ug2864ambag01_setcontrast * * Description: * Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ -static int ug2864ambag01_setcontrast(struct lcd_dev_s *dev, unsigned int contrast) +static int ug2864ambag01_setcontrast(struct lcd_dev_s *dev, + unsigned int contrast) { struct ug2864ambag01_dev_s *priv = (struct ug2864ambag01_dev_s *)dev; unsigned int scaled; @@ -978,11 +1008,11 @@ static int ug2864ambag01_setcontrast(struct lcd_dev_s *dev, unsigned int contras return OK; } -/************************************************************************************** +/**************************************************************************** * Public Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: ug2864ambag01_initialize * * Description: @@ -993,7 +1023,8 @@ static int ug2864ambag01_setcontrast(struct lcd_dev_s *dev, unsigned int contras * Input Parameters: * * spi - A reference to the SPI driver instance. - * devno - A value in the range of 0 through CONFIG_UG2864AMBAG01_NINTERFACES-1. + * devno - A value in the range of 0 through + * CONFIG_UG2864AMBAG01_NINTERFACES-1. * This allows support for multiple OLED devices. * * Returned Value: @@ -1001,9 +1032,10 @@ static int ug2864ambag01_setcontrast(struct lcd_dev_s *dev, unsigned int contras * On success, this function returns a reference to the LCD object for * the specified OLED. NULL is returned on any failure. * - **************************************************************************************/ + ****************************************************************************/ -FAR struct lcd_dev_s *ug2864ambag01_initialize(FAR struct spi_dev_s *spi, unsigned int devno) +FAR struct lcd_dev_s *ug2864ambag01_initialize(FAR struct spi_dev_s *spi, + unsigned int devno) { FAR struct ug2864ambag01_dev_s *priv = &g_oleddev; @@ -1062,12 +1094,13 @@ FAR struct lcd_dev_s *ug2864ambag01_initialize(FAR struct spi_dev_s *spi, unsign return &priv->dev; } -/************************************************************************************** +/**************************************************************************** * Name: ug2864ambag01_fill * * Description: - * This non-standard method can be used to clear the entire display by writing one - * color to the display. This is much faster than writing a series of runs. + * This non-standard method can be used to clear the entire display by + * writing one color to the display. + * This is much faster than writing a series of runs. * * Input Parameters: * priv - Reference to private driver structure @@ -1075,7 +1108,7 @@ FAR struct lcd_dev_s *ug2864ambag01_initialize(FAR struct spi_dev_s *spi, unsign * Assumptions: * Caller has selected the OLED section. * - **************************************************************************************/ + ****************************************************************************/ void ug2864ambag01_fill(FAR struct lcd_dev_s *dev, uint8_t color) { diff --git a/drivers/lcd/ug-9664hswag01.c b/drivers/lcd/ug-9664hswag01.c index 1a011f241e3..957327085f1 100644 --- a/drivers/lcd/ug-9664hswag01.c +++ b/drivers/lcd/ug-9664hswag01.c @@ -1,4 +1,4 @@ -/************************************************************************************** +/**************************************************************************** * drivers/lcd/ug-9664hswag01.c * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,18 +16,19 @@ * License for the specific language governing permissions and limitations * under the License. * - **************************************************************************************/ + ****************************************************************************/ -/* Driver for the Univision UG-9664HSWAG01 Display with the Solomon Systech SSD1305 LCD - * controller. +/* Driver for the Univision UG-9664HSWAG01 Display with the Solomon Systech + * SSD1305 LCD controller. * - * Reference: "Product Specification, OEL Display Module, UG-9664HSWAG01", Univision - * Technology Inc., SAS1-6020-B, January 3, 2008. + * Reference: + * "Product Specification, OEL Display Module, UG-9664HSWAG01", Univision + * Technology Inc., SAS1-6020-B, January 3, 2008. */ -/************************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************************/ + ****************************************************************************/ #include @@ -45,11 +46,12 @@ #include "ssd1305.h" -/************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **************************************************************************************/ + ****************************************************************************/ + +/* Configuration ************************************************************/ -/* Configuration **********************************************************************/ /* UG-9664HSWAG01 Configuration Settings: * * CONFIG_UG9664HSWAG01_SPIMODE - Controls the SPI mode @@ -63,7 +65,8 @@ * * Required LCD driver settings: * CONFIG_LCD_UG9664HSWAG01 - Enable UG-9664HSWAG01 support - * CONFIG_LCD_MAXCONTRAST should be 255, but any value >0 and <=255 will be accepted. + * CONFIG_LCD_MAXCONTRAST should be 255, but any value >0 and <=255 + * will be accepted. * CONFIG_LCD_MAXPOWER should be 2: 0=off, 1=dim, 2=normal * * Required SPI driver settings: @@ -72,8 +75,8 @@ /* Verify that all configuration requirements have been met */ -/* The UG-9664HSWAG01 spec says that is supports SPI mode 0,0 only. However, sometimes - * you need to tinker with these things. +/* The UG-9664HSWAG01 spec says that is supports SPI mode 0,0 only. + * However, sometimes you need to tinker with these things. */ #ifndef CONFIG_UG9664HSWAG01_SPIMODE @@ -86,8 +89,8 @@ # define CONFIG_UG9664HSWAG01_FREQUENCY 3500000 #endif -/* CONFIG_UG9664HSWAG01_NINTERFACES determines the number of physical interfaces - * that will be supported. +/* CONFIG_UG9664HSWAG01_NINTERFACES determines the number of physical + * interfaces that will be supported. */ #ifndef CONFIG_UG9664HSWAG01_NINTERFACES @@ -142,7 +145,8 @@ # error "CONFIG_SPI_CMDDATA must be defined in your NuttX configuration" #endif -/* Color Properties *******************************************************************/ +/* Color Properties *********************************************************/ + /* The SSD1305 display controller can handle a resolution of 132x64. The OLED * on the base board is 96x64. */ @@ -192,9 +196,9 @@ #define LS_BIT (1 << 0) #define MS_BIT (1 << 7) -/************************************************************************************** +/**************************************************************************** * Private Type Definition - **************************************************************************************/ + ****************************************************************************/ /* This structure describes the state of this driver */ @@ -210,17 +214,17 @@ struct ug_dev_s uint8_t contrast; uint8_t powered; - /* The SSD1305 does not support reading from the display memory in SPI mode. - * Since there is 1 BPP and access is byte-by-byte, it is necessary to keep - * a shadow copy of the framebuffer memory. + /* The SSD1305 does not support reading from the display memory in SPI + * mode.Since there is 1 BPP and access is byte-by-byte, it is + * necessary to keep a shadow copy of the framebuffer memory. */ uint8_t fb[UG_FBSIZE]; }; -/************************************************************************************** +/**************************************************************************** * Private Function Protototypes - **************************************************************************************/ + ****************************************************************************/ /* SPI helpers */ @@ -229,16 +233,19 @@ static void ug_deselect(FAR struct spi_dev_s *spi); /* LCD Data Transfer Methods */ -static int ug_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, +static int ug_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, size_t npixels); -static int ug_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, +static int ug_getrun(fb_coord_t row, fb_coord_t col, + FAR uint8_t *buffer, size_t npixels); /* LCD Configuration */ static int ug_getvideoinfo(FAR struct lcd_dev_s *dev, FAR struct fb_videoinfo_s *vinfo); -static int ug_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, +static int ug_getplaneinfo(FAR struct lcd_dev_s *dev, + unsigned int planeno, FAR struct lcd_planeinfo_s *pinfo); /* LCD RGB Mapping */ @@ -264,9 +271,9 @@ static int ug_setcontrast(struct lcd_dev_s *dev, unsigned int contrast); static inline void up_clear(FAR struct ug_dev_s *priv); -/************************************************************************************** +/**************************************************************************** * Private Data - **************************************************************************************/ + ****************************************************************************/ /* This is working memory allocated by the LCD driver for each LCD device * and for each color plane. This memory will hold one raster line of data. @@ -279,7 +286,7 @@ static inline void up_clear(FAR struct ug_dev_s *priv); * if there are multiple LCD devices, they must each have unique run buffers. */ -static uint8_t g_runbuffer[UG_XSTRIDE+1]; +static uint8_t g_runbuffer[UG_XSTRIDE + 1]; /* This structure describes the overall LCD video controller */ @@ -313,6 +320,7 @@ static struct ug_dev_s g_ugdev = .getplaneinfo = ug_getplaneinfo, /* LCD RGB Mapping -- Not supported */ + /* Cursor Controls -- Not supported */ /* LCD Specific Controls */ @@ -324,18 +332,17 @@ static struct ug_dev_s g_ugdev = }, }; -/************************************************************************************** +/**************************************************************************** * Private Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: ug_powerstring * * Description: * Convert the power setting to a string. * - **************************************************************************************/ - + ****************************************************************************/ static inline FAR const char *ug_powerstring(uint8_t power) { @@ -357,7 +364,7 @@ static inline FAR const char *ug_powerstring(uint8_t power) } } -/************************************************************************************** +/**************************************************************************** * Name: ug_select * * Description: @@ -371,12 +378,12 @@ static inline FAR const char *ug_powerstring(uint8_t power) * * Assumptions: * - **************************************************************************************/ + ****************************************************************************/ static void ug_select(FAR struct spi_dev_s *spi) { - /* Select UG-9664HSWAG01 chip (locking the SPI bus in case there are multiple - * devices competing for the SPI bus + /* Select UG-9664HSWAG01 chip (locking the SPI bus in case there are + * multiple devices competing for the SPI bus */ SPI_LOCK(spi, true); @@ -394,7 +401,7 @@ static void ug_select(FAR struct spi_dev_s *spi) #endif } -/************************************************************************************** +/**************************************************************************** * Name: ug_deselect * * Description: @@ -408,7 +415,7 @@ static void ug_select(FAR struct spi_dev_s *spi) * * Assumptions: * - **************************************************************************************/ + ****************************************************************************/ static void ug_deselect(FAR struct spi_dev_s *spi) { @@ -418,7 +425,7 @@ static void ug_deselect(FAR struct spi_dev_s *spi) SPI_LOCK(spi, false); } -/************************************************************************************** +/**************************************************************************** * Name: ug_putrun * * Description: @@ -430,12 +437,15 @@ static void ug_deselect(FAR struct spi_dev_s *spi) * npixels - The number of pixels to write to the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ -static int ug_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, - size_t npixels) +static int ug_putrun(fb_coord_t row, fb_coord_t col, + FAR const uint8_t *buffer, + size_t npixels) { - /* Because of this line of code, we will only be able to support a single UG device */ + /* Because of this line of code, we will only be able to support a single + * UG device + */ FAR struct ug_dev_s *priv = &g_ugdev; FAR uint8_t *fbptr; @@ -471,7 +481,7 @@ static int ug_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, */ #ifdef UG_LCD_REVERSEY - row = (UG_YRES-1) - row; + row = (UG_YRES - 1) - row; #endif /* If the column is switched then the start of the run is the mirror of @@ -488,7 +498,7 @@ static int ug_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, */ #ifdef UG_LCD_REVERSEX - col = (UG_XRES-1) - col; + col = (UG_XRES - 1) - col; col -= (pixlen - 1); #endif @@ -599,7 +609,7 @@ static int ug_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, /* Set the starting position for the run */ - SPI_SEND(priv->spi, SSD1305_SETPAGESTART+page); /* Set the page start */ + SPI_SEND(priv->spi, SSD1305_SETPAGESTART + page); /* Set the page start */ SPI_SEND(priv->spi, SSD1305_SETCOLL + (devcol & 0x0f)); /* Set the low column */ SPI_SEND(priv->spi, SSD1305_SETCOLH + (devcol >> 4)); /* Set the high column */ @@ -617,7 +627,7 @@ static int ug_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ug_getrun * * Description: @@ -629,12 +639,14 @@ static int ug_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer, * npixels - The number of pixels to read from the LCD * (range: 0 < npixels <= xres-col) * - **************************************************************************************/ + ****************************************************************************/ static int ug_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, size_t npixels) { - /* Because of this line of code, we will only be able to support a single UG device */ + /* Because of this line of code, we will only be able to support a single + * UG device + */ FAR struct ug_dev_s *priv = &g_ugdev; FAR uint8_t *fbptr; @@ -668,7 +680,7 @@ static int ug_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, */ #ifdef UG_LCD_REVERSEY - row = (UG_YRES-1) - row; + row = (UG_YRES - 1) - row; #endif /* If the column is switched then the start of the run is the mirror of @@ -685,10 +697,11 @@ static int ug_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, */ #ifdef UG_LCD_REVERSEX - col = (UG_XRES-1) - col; + col = (UG_XRES - 1) - col; #endif /* Then transfer the display data from the shadow frame buffer memory */ + /* Get the page number. The range of 64 lines is divided up into eight * pages of 8 lines each. */ @@ -775,31 +788,32 @@ static int ug_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ug_getvideoinfo * * Description: * Get information about the LCD video controller configuration. * - **************************************************************************************/ + ****************************************************************************/ static int ug_getvideoinfo(FAR struct lcd_dev_s *dev, FAR struct fb_videoinfo_s *vinfo) { DEBUGASSERT(dev && vinfo); ginfo("fmt: %d xres: %d yres: %d nplanes: %d\n", - g_videoinfo.fmt, g_videoinfo.xres, g_videoinfo.yres, g_videoinfo.nplanes); + g_videoinfo.fmt, g_videoinfo.xres, + g_videoinfo.yres, g_videoinfo.nplanes); memcpy(vinfo, &g_videoinfo, sizeof(struct fb_videoinfo_s)); return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ug_getplaneinfo * * Description: * Get information about the configuration of each LCD color plane. * - **************************************************************************************/ + ****************************************************************************/ static int ug_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, FAR struct lcd_planeinfo_s *pinfo) @@ -810,14 +824,15 @@ static int ug_getplaneinfo(FAR struct lcd_dev_s *dev, unsigned int planeno, return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ug_getpower * * Description: - * Get the LCD panel power status (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Get the LCD panel power status + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int ug_getpower(struct lcd_dev_s *dev) { @@ -827,14 +842,15 @@ static int ug_getpower(struct lcd_dev_s *dev) return priv->powered; } -/************************************************************************************** +/**************************************************************************** * Name: ug_setpower * * Description: - * Enable/disable LCD panel power (0: full off - CONFIG_LCD_MAXPOWER: full on). On - * backlit LCDs, this setting may correspond to the backlight setting. + * Enable/disable LCD panel power + * (0: full off - CONFIG_LCD_MAXPOWER: full on). + * On backlit LCDs, this setting may correspond to the backlight setting. * - **************************************************************************************/ + ****************************************************************************/ static int ug_setpower(struct lcd_dev_s *dev, int power) { @@ -871,6 +887,7 @@ static int ug_setpower(struct lcd_dev_s *dev, int power) SPI_SEND(priv->spi, SSD1305_DISPON); /* Display on, normal mode */ power = UG_POWER_ON; } + SPI_SEND(priv->spi, SSD1305_DISPRAM); /* Resume to RAM content display */ /* Restore power to the device */ @@ -878,18 +895,19 @@ static int ug_setpower(struct lcd_dev_s *dev, int power) ug_power(0, true); priv->powered = power; } + ug_deselect(priv->spi); return OK; } -/************************************************************************************** +/**************************************************************************** * Name: ug_getcontrast * * Description: * Get the current contrast setting (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int ug_getcontrast(struct lcd_dev_s *dev) { @@ -898,13 +916,13 @@ static int ug_getcontrast(struct lcd_dev_s *dev) return (int)priv->contrast; } -/************************************************************************************** +/**************************************************************************** * Name: ug_setcontrast * * Description: * Set LCD panel contrast (0-CONFIG_LCD_MAXCONTRAST). * - **************************************************************************************/ + ****************************************************************************/ static int ug_setcontrast(struct lcd_dev_s *dev, unsigned int contrast) { @@ -938,13 +956,13 @@ static int ug_setcontrast(struct lcd_dev_s *dev, unsigned int contrast) return OK; } -/************************************************************************************** +/**************************************************************************** * Name: up_clear * * Description: * Clear the display. * - **************************************************************************************/ + ****************************************************************************/ static inline void up_clear(FAR struct ug_dev_s *priv) { @@ -970,7 +988,7 @@ static inline void up_clear(FAR struct ug_dev_s *priv) /* Set the starting position for the run */ - SPI_SEND(priv->spi, SSD1305_SETPAGESTART+i); + SPI_SEND(priv->spi, SSD1305_SETPAGESTART + i); SPI_SEND(priv->spi, SSD1305_SETCOLL + (UG_XOFFSET & 0x0f)); SPI_SEND(priv->spi, SSD1305_SETCOLH + (UG_XOFFSET >> 4)); @@ -978,9 +996,9 @@ static inline void up_clear(FAR struct ug_dev_s *priv) SPI_CMDDATA(spi, SPIDEV_DISPLAY(0), false); - /* Then transfer all 96 columns of data */ + /* Then transfer all 96 columns of data */ - SPI_SNDBLOCK(priv->spi, &priv->fb[page * UG_XRES], UG_XRES); + SPI_SNDBLOCK(priv->spi, &priv->fb[page * UG_XRES], UG_XRES); } /* Unlock and de-select the device */ @@ -988,11 +1006,11 @@ static inline void up_clear(FAR struct ug_dev_s *priv) ug_deselect(spi); } -/************************************************************************************** +/**************************************************************************** * Public Functions - **************************************************************************************/ + ****************************************************************************/ -/************************************************************************************** +/**************************************************************************** * Name: ug_initialize * * Description: @@ -1003,17 +1021,19 @@ static inline void up_clear(FAR struct ug_dev_s *priv) * Input Parameters: * * spi - A reference to the SPI driver instance. - * devno - A value in the range of 0 through CONFIG_UG9664HSWAG01_NINTERFACES-1. + * devno - A value in the range of 0 through + * CONFIG_UG9664HSWAG01_NINTERFACES-1. * This allows support for multiple OLED devices. * * Returned Value: * - * On success, this function returns a reference to the LCD object for the specified - * OLED. NULL is returned on any failure. + * On success, this function returns a reference to the LCD object for + * the specified OLED. NULL is returned on any failure. * - **************************************************************************************/ + ****************************************************************************/ -FAR struct lcd_dev_s *ug_initialize(FAR struct spi_dev_s *spi, unsigned int devno) +FAR struct lcd_dev_s *ug_initialize(FAR struct spi_dev_s *spi, + unsigned int devno) { /* Configure and enable LCD */ @@ -1042,7 +1062,7 @@ FAR struct lcd_dev_s *ug_initialize(FAR struct spi_dev_s *spi, unsigned int devn SPI_SEND(spi, SSD1305_SETCOLL + 2); /* Set low column address */ SPI_SEND(spi, SSD1305_SETCOLH + 2); /* Set high column address */ - SPI_SEND(spi, SSD1305_SETSTARTLINE+0); /* Display start set */ + SPI_SEND(spi, SSD1305_SETSTARTLINE + 0); /* Display start set */ SPI_SEND(spi, SSD1305_SCROLL_STOP); /* Stop horizontal scroll */ SPI_SEND(spi, SSD1305_SETCONTRAST); /* Set contrast control register */ SPI_SEND(spi, 0x32); /* Data 1: Set 1 of 256 contrast steps */ @@ -1050,7 +1070,9 @@ FAR struct lcd_dev_s *ug_initialize(FAR struct spi_dev_s *spi, unsigned int devn SPI_SEND(spi, 0x80); /* Data 1: Set 1 of 256 contrast steps */ SPI_SEND(spi, SSD1305_MAPCOL131); /* Set segment re-map */ SPI_SEND(spi, SSD1305_DISPNORMAL); /* Set normal display */ -//(void)SPI_SEND(spi, SSD1305_DISPINVERTED); /* Set inverse display */ + + /* (void)SPI_SEND(spi, SSD1305_DISPINVERTED); */ /* Set inverse display */ + SPI_SEND(spi, SSD1305_SETMUX); /* Set multiplex ratio */ SPI_SEND(spi, 0x3f); /* Data 1: MUX ratio -1: 15-63 */ SPI_SEND(spi, SSD1305_SETOFFSET); /* Set display offset */ @@ -1069,7 +1091,7 @@ FAR struct lcd_dev_s *ug_initialize(FAR struct spi_dev_s *spi, unsigned int devn SPI_SEND(spi, SSD1305_SETCOMCONFIG); /* Set COM configuration */ SPI_SEND(spi, SSD1305_COMCONFIG_ALT); /* Data 1, Bit 4: 1=Alternative COM pin configuration */ SPI_SEND(spi, SSD1305_SETVCOMHDESEL); /* Set VCOMH deselect level */ - SPI_SEND(spi, SSD1305_VCOMH_x7p7); /* Data 1: ~0.77 x Vcc */ + SPI_SEND(spi, SSD1305_VCOMH_X7P7); /* Data 1: ~0.77 x Vcc */ SPI_SEND(spi, SSD1305_SETLUT); /* Set look up table for area color */ SPI_SEND(spi, 0x3f); /* Data 1: Pulse width: 31-63 */ SPI_SEND(spi, 0x3f); /* Data 2: Color A: 31-63 */ diff --git a/drivers/mmcsd/mmcsd.h b/drivers/mmcsd/mmcsd.h index cf831c49771..bbfb006da2a 100644 --- a/drivers/mmcsd/mmcsd.h +++ b/drivers/mmcsd/mmcsd.h @@ -60,7 +60,7 @@ ****************************************************************************/ /**************************************************************************** - * Public Functions + * Public Functions Definitions ****************************************************************************/ #undef EXTERN diff --git a/drivers/mmcsd/mmcsd_csd.h b/drivers/mmcsd/mmcsd_csd.h index 767d4563dfd..1e7a1131b07 100644 --- a/drivers/mmcsd/mmcsd_csd.h +++ b/drivers/mmcsd/mmcsd_csd.h @@ -76,7 +76,7 @@ #define MMCSD_CSD_CCC(csd) ((csd[2] >> 4) & 0x0fff) - /* READ_BL_LEN 80-83 = Max. read data block length */ +/* READ_BL_LEN 80-83 = Max. read data block length */ #define MMCSD_CSD_READBLLEN(csd) (csd[2] & 0x0f) @@ -132,7 +132,7 @@ #define MMC_CSD_SECTORSIZE(csd) ((csd[5] >> 10) & 0x1f) -/* ER_GRP_SIZE 37-41 = Erase group size (MMC)*/ +/* ER_GRP_SIZE 37-41 = Erase group size (MMC) */ #define MMC_CSD_ERGRPSIZE(csd) ((csd[5] >> 5) & 0x1f) @@ -240,7 +240,7 @@ #define MMCSD_CSD_CCC(csd) (((uint16_t)csd[4] << 4) | ((uint16_t)csd[5] >> 4)) #define SD20_CSD_CCC(csd) MMCSD_CSD_CCC(csd) - /* READ_BL_LEN 80-83 = Max. read data block length */ +/* READ_BL_LEN 80-83 = Max. read data block length */ #define MMCSD_CSD_READBLLEN(csd) (csd[5] & 0x0f) #define SD20_CSD_READBLLEN(csd) (9) @@ -309,7 +309,7 @@ #define MMC_CSD_SECTORSIZE(csd) ((csd[10] >> 2) & 0x1f) -/* ER_GRP_SIZE 37-41 = Erase group size (MMC)*/ +/* ER_GRP_SIZE 37-41 = Erase group size (MMC) */ #define MMC_CSD_ERGRPSIZE(csd) (((csd[10] & 3) << 3) | (csd[11] > 5)) @@ -391,13 +391,14 @@ ****************************************************************************/ /**************************************************************************** - * Public Functions + * Public Functions Definitions ****************************************************************************/ #undef EXTERN #if defined(__cplusplus) #define EXTERN extern "C" -extern "C" { +extern "C" +{ #else #define EXTERN extern #endif diff --git a/drivers/mmcsd/mmcsd_debug.c b/drivers/mmcsd/mmcsd_debug.c index 9234684e146..cfdded91313 100644 --- a/drivers/mmcsd/mmcsd_debug.c +++ b/drivers/mmcsd/mmcsd_debug.c @@ -91,9 +91,11 @@ void mmcsd_dmpcsd(FAR const uint8_t *csd, uint8_t cardtype) sd2 ? SD20_CSD_NSAC(csd) : MMCSD_CSD_NSAC(csd)); finfo(" TRAN_SPEED:\n"); finfo(" TIME_VALUE: 0x%02x\n", - sd2 ? SD20_CSD_TRANSPEED_TIMEVALUE(csd) : MMCSD_CSD_TRANSPEED_TIMEVALUE(csd)); + sd2 ? SD20_CSD_TRANSPEED_TIMEVALUE(csd) : + MMCSD_CSD_TRANSPEED_TIMEVALUE(csd)); finfo(" RATE_UNIT: 0x%02x\n", - sd2 ? SD20_CSD_TRANSPEED_TRANSFERRATEUNIT(csd) : MMCSD_CSD_TRANSPEED_TRANSFERRATEUNIT(csd)); + sd2 ? SD20_CSD_TRANSPEED_TRANSFERRATEUNIT(csd) : + MMCSD_CSD_TRANSPEED_TRANSFERRATEUNIT(csd)); finfo(" CCC: 0x%03x\n", sd2 ? SD20_CSD_CCC(csd) : MMCSD_CSD_CCC(csd)); finfo(" READ_BL_LEN: %d\n", @@ -101,9 +103,11 @@ void mmcsd_dmpcsd(FAR const uint8_t *csd, uint8_t cardtype) finfo(" READ_BL_PARTIAL: %d\n", sd2 ? SD20_CSD_READBLPARTIAL(csd) : MMCSD_CSD_READBLPARTIAL(csd)); finfo(" WRITE_BLK_MISALIGN: %d\n", - sd2 ? SD20_CSD_WRITEBLKMISALIGN(csd) : MMCSD_CSD_WRITEBLKMISALIGN(csd)); + sd2 ? SD20_CSD_WRITEBLKMISALIGN(csd) : + MMCSD_CSD_WRITEBLKMISALIGN(csd)); finfo(" READ_BLK_MISALIGN: %d\n", - sd2 ? SD20_CSD_READBLKMISALIGN(csd) : MMCSD_CSD_READBLKMISALIGN(csd)); + sd2 ? SD20_CSD_READBLKMISALIGN(csd) : + MMCSD_CSD_READBLKMISALIGN(csd)); finfo(" DSR_IMP: %d\n", sd2 ? SD20_CSD_DSRIMP(csd) : MMCSD_CSD_DSRIMP(csd)); finfo(" C_SIZE: %d\n", @@ -134,6 +138,7 @@ void mmcsd_dmpcsd(FAR const uint8_t *csd, uint8_t cardtype) finfo(" SD WP_GRP_SIZE: %d\n", sd2 ? SD_CSD_WPGRPSIZE(csd) : SD_CSD_WPGRPSIZE(csd)); } + finfo(" WP_GRP_EN: %d\n", sd2 ? SD20_WPGRPEN(csd) : MMCSD_WPGRPEN(csd)); finfo(" R2W_FACTOR: %d\n", @@ -147,7 +152,8 @@ void mmcsd_dmpcsd(FAR const uint8_t *csd, uint8_t cardtype) finfo(" COPY: %d\n", sd2 ? SD20_CSD_COPY(csd) : MMCSD_CSD_COPY(csd)); finfo(" PERM_WRITE_PROTECT: %d\n", - sd2 ? SD20_CSD_PERMWRITEPROTECT(csd) : MMCSD_CSD_PERMWRITEPROTECT(csd)); + sd2 ? SD20_CSD_PERMWRITEPROTECT(csd) : + MMCSD_CSD_PERMWRITEPROTECT(csd)); finfo(" TMP_WRITE_PROTECT: %d\n", sd2 ?SD20_CSD_TMPWRITEPROTECT(csd) : MMCSD_CSD_TMPWRITEPROTECT(csd)); finfo(" FILE_FORMAT: %d\n", @@ -157,6 +163,7 @@ void mmcsd_dmpcsd(FAR const uint8_t *csd, uint8_t cardtype) finfo(" MMC ECC: %d\n", sd2 ? MMC_CSD_ECC(csd) : MMC_CSD_ECC(csd)); } + finfo(" CRC: %02x\n", sd2 ? SD20_CSD_CRC(csd) : MMCSD_CSD_CRC(csd)); } diff --git a/drivers/mmcsd/mmcsd_sdio.h b/drivers/mmcsd/mmcsd_sdio.h index 5a879591c12..181b1940aef 100644 --- a/drivers/mmcsd/mmcsd_sdio.h +++ b/drivers/mmcsd/mmcsd_sdio.h @@ -1,4 +1,4 @@ -/******************************************************************************************** +/**************************************************************************** * drivers/mmcsd/mmcsd_sdio.h * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,21 +16,21 @@ * License for the specific language governing permissions and limitations * under the License. * - ********************************************************************************************/ + ****************************************************************************/ #ifndef __DRIVERS_MMCSD_MMCSD_SDIO_H #define __DRIVERS_MMCSD_MMCSD_SDIO_H -/******************************************************************************************** +/**************************************************************************** * Included Files - ********************************************************************************************/ + ****************************************************************************/ #include #include -/******************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - ********************************************************************************************/ + ****************************************************************************/ /* CMD8 Argument: * [31:12]: Reserved (shall be set to '0') @@ -42,6 +42,7 @@ #define MMCSD_CMD8VOLTAGE_SHIFT (8) /* Bits 8-11: Supply voltage */ #define MMCSD_CMD8VOLTAGE_MASK ((uint32_t)0x0f << MMCSD_CMD8VOLTAGE_SHIFT) # define MMCSD_CMD8VOLTAGE_27 ((uint32_t)0x01 << MMCSD_CMD8VOLTAGE_SHIFT) /* 2.7-3.6V */ + #define MMCSD_CMD8ECHO_SHIFT (0) /* Bits 0-7: Check pattern */ #define MMCSD_CMD8ECHO_MASK ((uint32_t)0xff << MMCSD_CMD8ECHO_SHIFT) # define MMCSD_CMD8CHECKPATTERN ((uint32_t)0xaa << MMCSD_CMD8ECHO_SHIFT) @@ -87,17 +88,22 @@ #define MMCSD_R1_ERASERESET ((uint32_t)1 << 13) /* Reset sequence cleared */ #define MMCSD_R1_STATE_SHIFT (9) /* Current card state */ #define MMCSD_R1_STATE_MASK ((uint32_t)15 << MMCSD_R1_STATE_SHIFT) - /* Card identification mode states */ + +/* Card identification mode states */ + # define MMCSD_R1_STATE_IDLE ((uint32_t)0 << MMCSD_R1_STATE_SHIFT) /* 0=Idle state */ # define MMCSD_R1_STATE_READY ((uint32_t)1 << MMCSD_R1_STATE_SHIFT) /* 1=Ready state */ # define MMCSD_R1_STATE_IDENT ((uint32_t)2 << MMCSD_R1_STATE_SHIFT) /* 2=Identification state */ - /* Data transfer states */ + +/* Data transfer states */ + # define MMCSD_R1_STATE_STBY ((uint32_t)3 << MMCSD_R1_STATE_SHIFT) /* 3=Standby state */ # define MMCSD_R1_STATE_TRAN ((uint32_t)4 << MMCSD_R1_STATE_SHIFT) /* 4=Transfer state */ # define MMCSD_R1_STATE_DATA ((uint32_t)5 << MMCSD_R1_STATE_SHIFT) /* 5=Sending data state */ # define MMCSD_R1_STATE_RCV ((uint32_t)6 << MMCSD_R1_STATE_SHIFT) /* 6=Receiving data state */ # define MMCSD_R1_STATE_PRG ((uint32_t)7 << MMCSD_R1_STATE_SHIFT) /* 7=Programming state */ # define MMCSD_R1_STATE_DIS ((uint32_t)8 << MMCSD_R1_STATE_SHIFT) /* 8=Disconnect state */ + #define MMCSD_R1_READYFORDATA ((uint32_t)1 << 8) /* Buffer empty */ #define MMCSD_R1_APPCMD ((uint32_t)1 << 5) /* Next CMD is ACMD */ #define MMCSD_R1_AKESEQERROR ((uint32_t)1 << 3) /* Authentication error */ @@ -146,17 +152,22 @@ #define MMCSD_R6_ERROR ((uint32_t)1 << 13) /* General error */ #define MMCSD_R6_STATE_SHIFT (9) /* Current card state */ #define MMCSD_R6_STATE_MASK ((uint32_t)15 << MMCSD_R6_STATE_SHIFT) - /* Card identification mode states */ + +/* Card identification mode states */ + # define MMCSD_R6_STATE_IDLE ((uint32_t)0 << MMCSD_R6_STATE_SHIFT) /* 0=Idle state */ # define MMCSD_R6_STATE_READY ((uint32_t)1 << MMCSD_R6_STATE_SHIFT) /* 1=Ready state */ # define MMCSD_R6_STATE_IDENT ((uint32_t)2 << MMCSD_R6_STATE_SHIFT) /* 2=Identification state */ - /* Data transfer states */ + +/* Data transfer states */ + # define MMCSD_R6_STATE_STBY ((uint32_t)3 << MMCSD_R6_STATE_SHIFT) /* 3=Standby state */ # define MMCSD_R6_STATE_TRAN ((uint32_t)4 << MMCSD_R6_STATE_SHIFT) /* 4=Transfer state */ # define MMCSD_R6_STATE_DATA (5(uint32_t) << MMCSD_R6_STATE_SHIFT) /* 5=Sending data state */ # define MMCSD_R6_STATE_RCV ((uint32_t)6 << MMCSD_R6_STATE_SHIFT) /* 6=Receiving data state */ # define MMCSD_R6_STATE_PRG ((uint32_t)7 << MMCSD_R6_STATE_SHIFT) /* 7=Programming state */ -# define MMCSD_R6_STATE_DIS ((uint32_t) << MMCSD_R6_STATE_SHIFT) /* 8=Disconnect state */ +# define MMCSD_R6_STATE_DIS ((uint32_t) << MMCSD_R6_STATE_SHIFT) /* 8=Disconnect state */ + #define MMCSD_R6_ERRORMASK ((uint32_t)0x0000e000) /* Error mask */ /* SD Configuration Register (SCR) encoding */ @@ -173,13 +184,14 @@ #define MMCSD_R7VOLTAGE_SHIFT (8) /* Bits 8-11: Voltage accepted */ #define MMCSD_R7VOLTAGE_MASK ((uint32_t)0x0f << MMCSD_R7VOLTAGE_SHIFT) # define MMCSD_R7VOLTAGE_27 ((uint32_t)0x01 << MMCSD_R7VOLTAGE_SHIFT) /* 2.7-3.6V */ + #define MMCSD_R7ECHO_SHIFT (0) /* Bits 0-7: Echoed check pattern */ #define MMCSD_R7ECHO_MASK ((uint32_t)0xff << MMCSD_R7ECHO_SHIFT) # define MMCSD_R7CHECKPATTERN ((uint32_t)0xaa << MMCSD_R7ECHO_SHIFT) -/******************************************************************************************** +/**************************************************************************** * Public Types - ********************************************************************************************/ + ****************************************************************************/ /* Decoded Card Identification (CID) register */ @@ -269,6 +281,7 @@ struct mmcsd_csd_s struct { /* 73:70 (reserved) */ + uint32_t csize; /* 69:48 Device size */ /* 47:47 (reserved) */ uint8_t sderblen; /* 46:46 Erase single block enable (SD) */ @@ -303,9 +316,9 @@ struct mmcsd_scr_s uint32_t mfgdata; /* 31:0 Reserved for manufacturing data */ }; -/******************************************************************************************** +/**************************************************************************** * Public Data - ********************************************************************************************/ + ****************************************************************************/ #undef EXTERN #if defined(__cplusplus) @@ -316,9 +329,9 @@ extern "C" #define EXTERN extern #endif -/******************************************************************************************** - * Public Functions - ********************************************************************************************/ +/**************************************************************************** + * Public Functions Definitions + ****************************************************************************/ #undef EXTERN #if defined(__cplusplus) diff --git a/drivers/mmcsd/mmcsd_spi.h b/drivers/mmcsd/mmcsd_spi.h index 8d20c701f30..4732a78d790 100644 --- a/drivers/mmcsd/mmcsd_spi.h +++ b/drivers/mmcsd/mmcsd_spi.h @@ -31,7 +31,7 @@ * Pre-processor Definitions ****************************************************************************/ -/* SPI *******************************************************************/ +/* SPI **********************************************************************/ /* SPI Command Set */ @@ -110,7 +110,9 @@ #define MMCSD_SPIR7_VERSION_MASK ((uint32_t)0x0f << MMCSD_SPIR7_VERSION_SHIFT) #define MMCSD_SPIR7_VOLTAGE_SHIFT (8) /* Bits 8-11: Voltage accepted */ #define MMCSD_SPIR7_VOLTAGE_MASK ((uint32_t)0x0f << MMCSD_SPIR7_VOLTAGE_SHIFT) + #define MMCSD_SPIR7_VOLTAGE_27 ((uint32_t)0x01 << MMCSD_SPIR7_VOLTAGE_SHIFT) /* 2.7-3.6V */ + #define MMCSD_SPIR7_ECHO_SHIFT (0) /* Bits 0-7: Echoed check pattern */ #define MMCSD_SPIR7_ECHO_MASK ((uint32_t)0xff << MMCSD_SPIR7_ECHO_SHIFT) @@ -154,13 +156,14 @@ ****************************************************************************/ /**************************************************************************** - * Public Functions + * Public Functions Definitions ****************************************************************************/ #undef EXTERN #if defined(__cplusplus) #define EXTERN extern "C" -extern "C" { +extern "C" +{ #else #define EXTERN extern #endif diff --git a/drivers/net/enc28j60.h b/drivers/net/enc28j60.h index 78c60063ce0..1206a70fc0d 100644 --- a/drivers/net/enc28j60.h +++ b/drivers/net/enc28j60.h @@ -123,6 +123,7 @@ # define ECON1_BSEL_BANK1 (1 << ECON1_BSEL_SHIFT) /* Bank 1 */ # define ECON1_BSEL_BANK2 (2 << ECON1_BSEL_SHIFT) /* Bank 2 */ # define ECON1_BSEL_BANK3 (3 << ECON1_BSEL_SHIFT) /* Bank 3 */ + #define ECON1_RXEN (1 << 2) /* Bit 2: Receive Enable */ #define ECON1_TXRTS (1 << 3) /* Bit 3: Transmit Request to Send */ #define ECON1_CSUMEN (1 << 4) /* Bit 4: DMA Checksum Enable */ @@ -131,7 +132,9 @@ #define ECON1_TXRST (1 << 7) /* Bit 7: Transmit Logic Reset */ /* Ethernet Control 2 Register */ + /* Bits 0-2: Reserved */ + #define ECON2_VRPS (1 << 3) /* Bit 3: Voltage Regulator Power Save Enable */ /* Bit 4: Reserved */ #define ECON2_PWRSV (1 << 5) /* Bit 5: Power Save Enable */ @@ -190,6 +193,7 @@ #define ENC_EDMACSH REGADDR(0x17, 0, 0) /* DMA Checksum High Byte (EDMACS<15:8>) */ /* 0x18-0x1a: Reserved */ /* 0x1b-0x1f: EIE, EIR, ESTAT, ECON2, ECON1 */ + /* Bank 1 Control Register Addresses */ #define ENC_EHT0 REGADDR(0x00, 1, 0) /* Hash Table Byte 0 (EHT<7:0>) */ @@ -388,6 +392,7 @@ #define PHIR_PLNKIF (1 << 4) /* Bit 4: PHY Link Change Interrupt */ /* PHLCON Register Bit Definitions */ + /* Bit 0: Reserved */ #define PHLCON_STRCH (1 << 1) /* Bit 1: LED Pulse Stretching Enable */ #define PHLCON_LFRQ0 (1 << 2) /* Bit 2: LED Pulse Stretch Time Configuration */ diff --git a/drivers/pipes/pipe_common.h b/drivers/pipes/pipe_common.h index fb2cf7b7b60..06fe21e8319 100644 --- a/drivers/pipes/pipe_common.h +++ b/drivers/pipes/pipe_common.h @@ -92,7 +92,6 @@ #define PIPE_UNLINK(f) do { (f) |= PIPE_FLAG_UNLINKED; } while (0) #define PIPE_IS_UNLINKED(f) (((f) & PIPE_FLAG_UNLINKED) != 0) - /**************************************************************************** * Public Types ****************************************************************************/ @@ -108,8 +107,8 @@ typedef uint8_t pipe_ndx_t; /* 8-bit index */ #endif /* This structure represents the state of one pipe. A reference to this - * structure is retained in the i_private field of the inode whenthe pipe/fifo - * device is registered. + * structure is retained in the i_private field of the inode whenthe + * pipe/fifo device is registered. */ struct pipe_dev_s diff --git a/drivers/power/battery_gauge.c b/drivers/power/battery_gauge.c index 21952ab5a12..6393086fcc2 100644 --- a/drivers/power/battery_gauge.c +++ b/drivers/power/battery_gauge.c @@ -57,12 +57,14 @@ static int bat_gauge_open(FAR struct file *filep); static int bat_gauge_close(FAR struct file *filep); -static ssize_t bat_gauge_read(FAR struct file *filep, FAR char *buffer, - size_t buflen); -static ssize_t bat_gauge_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen); +static ssize_t bat_gauge_read(FAR struct file *filep, + FAR char *buffer, + size_t buflen); +static ssize_t bat_gauge_write(FAR struct file *filep, + FAR const char *buffer, + size_t buflen); static int bat_gauge_ioctl(FAR struct file *filep, int cmd, - unsigned long arg); + unsigned long arg); /**************************************************************************** * Private Data @@ -125,8 +127,9 @@ static ssize_t bat_gauge_read(FAR struct file *filep, FAR char *buffer, * Name: bat_gauge_write ****************************************************************************/ -static ssize_t bat_gauge_write(FAR struct file *filep, FAR const char *buffer, - size_t buflen) +static ssize_t bat_gauge_write(FAR struct file *filep, + FAR const char *buffer, + size_t buflen) { /* Return nothing written */ @@ -137,7 +140,9 @@ static ssize_t bat_gauge_write(FAR struct file *filep, FAR const char *buffer, * Name: bat_gauge_ioctl ****************************************************************************/ -static int bat_gauge_ioctl(FAR struct file *filep, int cmd, unsigned long arg) +static int bat_gauge_ioctl(FAR struct file *filep, + int cmd, + unsigned long arg) { FAR struct inode *inode = filep->f_inode; FAR struct battery_gauge_dev_s *dev = inode->i_private; diff --git a/drivers/sensors/adxl345.h b/drivers/sensors/adxl345.h index 8b61010a12d..85e9f7ee637 100644 --- a/drivers/sensors/adxl345.h +++ b/drivers/sensors/adxl345.h @@ -1,4 +1,4 @@ -/******************************************************************************************** +/**************************************************************************** * drivers/sensors/adxl345.h * * Copyright (C) 2014 Alan Carvalho de Assis @@ -33,14 +33,14 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ********************************************************************************************/ + ****************************************************************************/ #ifndef __DRIVERS_SENSORS_ADXL345_H #define __DRIVERS_SENSORS_ADXL345_H -/******************************************************************************************** +/**************************************************************************** * Included Files - ********************************************************************************************/ + ****************************************************************************/ #include @@ -52,17 +52,18 @@ #if defined(CONFIG_SENSORS_ADXL345) -/******************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - ********************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_ADXL345_I2C # error "Only the ADXL345 SPI interface is supported by this driver" #endif -/* Driver support ***************************************************************************/ -/* This format is used to construct the /dev/accel[n] device driver path. It defined here - * so that it will be used consistently in all places. +/* Driver support ***********************************************************/ + +/* This format is used to construct the /dev/accel[n] device driver path. + * It defined here so that it will be used consistently in all places. */ #define DEV_FORMAT "/dev/accel%d" @@ -72,9 +73,10 @@ #define ADXL345_STAT_INITIALIZED 1 /* Device has been initialized */ -/******************************************************************************************** +/**************************************************************************** * Public Types - ********************************************************************************************/ + ****************************************************************************/ + /* This defines type of events */ enum adxl345_event @@ -139,50 +141,52 @@ struct adxl345_dev_s struct adxl345_sample_s sample; /* Last sampled accelerometer data */ }; -/******************************************************************************************** +/**************************************************************************** * Public Function Prototypes - ********************************************************************************************/ + ****************************************************************************/ -/******************************************************************************************** +/**************************************************************************** * Name: adxl345_getreg8 * * Description: * Read from an 8-bit ADXL345 register * - ********************************************************************************************/ + ****************************************************************************/ uint8_t adxl345_getreg8(FAR struct adxl345_dev_s *priv, uint8_t regaddr); -/******************************************************************************************** +/**************************************************************************** * Name: adxl345_putreg8 * * Description: * Write a value to an 8-bit ADXL345 register * - ********************************************************************************************/ + ****************************************************************************/ -void adxl345_putreg8(FAR struct adxl345_dev_s *priv, uint8_t regaddr, uint8_t regval); +void adxl345_putreg8(FAR struct adxl345_dev_s *priv, + uint8_t regaddr, uint8_t regval); -/******************************************************************************************** +/**************************************************************************** * Name: adxl345_getreg16 * * Description: * Read 16-bits of data from an ADXL345 register * - ********************************************************************************************/ + ****************************************************************************/ uint16_t adxl345_getreg16(FAR struct adxl345_dev_s *priv, uint8_t regaddr); -/******************************************************************************************** +/**************************************************************************** * Name: adxl345_accworker * * Description: - * Handle accelerometer interrupt events (this function actually executes in the context of - * the worker thread). + * Handle accelerometer interrupt events + * (this function actually executes in the context of the worker thread). * - ********************************************************************************************/ + ****************************************************************************/ -void adxl345_accworker(FAR struct adxl345_dev_s *priv, uint8_t intsta) weak_function; +void adxl345_accworker(FAR struct adxl345_dev_s *priv, + uint8_t intsta) weak_function; #endif /* CONFIG_SENSORS_ADXL345 */ #endif /* __DRIVERS_SENSORS_ADXL345_H */ diff --git a/drivers/sensors/qencoder.c b/drivers/sensors/qencoder.c index 6d45769a993..bd5cc51575c 100644 --- a/drivers/sensors/qencoder.c +++ b/drivers/sensors/qencoder.c @@ -110,13 +110,13 @@ static const struct file_operations g_qeops = * Private Functions ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Name: qe_open * * Description: * This function is called whenever the QEncoder device is opened. * - ************************************************************************************/ + ****************************************************************************/ static int qe_open(FAR struct file *filep) { @@ -179,13 +179,13 @@ errout: return ret; } -/************************************************************************************ +/**************************************************************************** * Name: qe_close * * Description: * This function is called when the QEncoder device is closed. * - ************************************************************************************/ + ****************************************************************************/ static int qe_close(FAR struct file *filep) { @@ -234,43 +234,48 @@ errout: return ret; } -/************************************************************************************ +/**************************************************************************** * Name: qe_read * * Description: * A dummy read method. This is provided only to satisfy the VFS layer. * - ************************************************************************************/ + ****************************************************************************/ -static ssize_t qe_read(FAR struct file *filep, FAR char *buffer, size_t buflen) +static ssize_t qe_read(FAR struct file *filep, + FAR char *buffer, + size_t buflen) { /* Return zero -- usually meaning end-of-file */ return 0; } -/************************************************************************************ +/**************************************************************************** * Name: qe_write * * Description: * A dummy write method. This is provided only to satisfy the VFS layer. * - ************************************************************************************/ + ****************************************************************************/ -static ssize_t qe_write(FAR struct file *filep, FAR const char *buffer, size_t buflen) +static ssize_t qe_write(FAR struct file *filep, + FAR const char *buffer, + size_t buflen) { /* Return a failure */ return -EPERM; } -/************************************************************************************ +/**************************************************************************** * Name: qe_ioctl * * Description: - * The standard ioctl method. This is where ALL of the QEncoder work is done. + * The standard ioctl method. + * This is where ALL of the QEncoder work is done. * - ************************************************************************************/ + ****************************************************************************/ static int qe_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { @@ -320,7 +325,9 @@ static int qe_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } break; - /* Any unrecognized IOCTL commands might be platform-specific ioctl commands */ + /* Any unrecognized IOCTL commands might be platform-specific ioctl + * commands + */ default: { @@ -366,14 +373,17 @@ int qe_register(FAR const char *devpath, FAR struct qe_lowerhalf_s *lower) /* Allocate the upper-half data structure */ - upper = (FAR struct qe_upperhalf_s *)kmm_zalloc(sizeof(struct qe_upperhalf_s)); + upper = (FAR struct qe_upperhalf_s *) + kmm_zalloc(sizeof(struct qe_upperhalf_s)); if (!upper) { snerr("ERROR: Allocation failed\n"); return -ENOMEM; } - /* Initialize the QEncoder device structure (it was already zeroed by kmm_zalloc()) */ + /* Initialize the QEncoder device structure + * (it was already zeroed by kmm_zalloc()) + */ nxsem_init(&upper->exclsem, 0, 1); upper->lower = lower; diff --git a/drivers/sensors/xen1210.h b/drivers/sensors/xen1210.h index 5035ce8f4b5..af9d4752d14 100644 --- a/drivers/sensors/xen1210.h +++ b/drivers/sensors/xen1210.h @@ -1,4 +1,4 @@ -/******************************************************************************************** +/**************************************************************************** * drivers/sensors/xen1210.h * * Copyright (C) 2014 Alan Carvalho de Assis @@ -31,14 +31,14 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ********************************************************************************************/ + ****************************************************************************/ #ifndef __DRIVERS_SENSORS_XEN1210_H #define __DRIVERS_SENSORS_XEN1210_H -/******************************************************************************************** +/**************************************************************************** * Included Files - ********************************************************************************************/ + ****************************************************************************/ #include @@ -50,13 +50,14 @@ #if defined(CONFIG_SENSORS_XEN1210) -/******************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - ********************************************************************************************/ + ****************************************************************************/ -/* Driver support ***************************************************************************/ -/* This format is used to construct the /dev/mag[n] device driver path. It is defined here - * so that it will be used consistently in all places. +/* Driver support ***********************************************************/ + +/* This format is used to construct the /dev/mag[n] device driver path. + * It is defined here so that it will be used consistently in all places. */ #define DEV_FORMAT "/dev/mag%d" @@ -66,9 +67,9 @@ #define XEN1210_STAT_INITIALIZED 1 /* Device has been initialized */ -/******************************************************************************************** +/**************************************************************************** * Public Types - ********************************************************************************************/ + ****************************************************************************/ /* This structure describes the results of one XEN1210 sample */ @@ -100,27 +101,27 @@ struct xen1210_dev_s struct xen1210_sample_s sample; /* Last sampled accelerometer data */ }; -/******************************************************************************************** +/**************************************************************************** * Public Function Prototypes - ********************************************************************************************/ + ****************************************************************************/ -/******************************************************************************************** +/**************************************************************************** * Name: xen1210_getdata * * Description: * Read 24-bit from XEN1210 buffer, read three times (3 sensors) * - ********************************************************************************************/ + ****************************************************************************/ void xen1210_getdata(FAR struct xen1210_dev_s *priv); -/******************************************************************************************** +/**************************************************************************** * Name: xen1210_putdata * * Description: * Write 24-bit to XEN1210 buffer, write three times (3 sensors) * - ********************************************************************************************/ + ****************************************************************************/ void xen1210_putdata(FAR struct xen1210_dev_s *priv, uint32_t regval); diff --git a/drivers/serial/serial.c b/drivers/serial/serial.c index 91787ef2473..ea64a7c07ed 100644 --- a/drivers/serial/serial.c +++ b/drivers/serial/serial.c @@ -1,4 +1,4 @@ -/************************************************************************************ +/**************************************************************************** * drivers/serial/serial.c * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,11 +16,11 @@ * License for the specific language governing permissions and limitations * under the License. * - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Included Files - ************************************************************************************/ + ****************************************************************************/ #include @@ -44,9 +44,9 @@ #include #include -/************************************************************************************ +/**************************************************************************** * Pre-processor Definitions - ************************************************************************************/ + ****************************************************************************/ /* Check watermark levels */ @@ -68,21 +68,23 @@ #define POLL_DELAY_USEC 1000 -/************************************************************************************ +/**************************************************************************** * Private Types - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Private Function Prototypes - ************************************************************************************/ + ****************************************************************************/ static int uart_takesem(FAR sem_t *sem, bool errout); static void uart_pollnotify(FAR uart_dev_t *dev, pollevent_t eventset); /* Write support */ -static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, bool oktoblock); -static inline ssize_t uart_irqwrite(FAR uart_dev_t *dev, FAR const char *buffer, +static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, + bool oktoblock); +static inline ssize_t uart_irqwrite(FAR uart_dev_t *dev, + FAR const char *buffer, size_t buflen); static int uart_tcdrain(FAR uart_dev_t *dev, clock_t timeout); @@ -90,15 +92,19 @@ static int uart_tcdrain(FAR uart_dev_t *dev, clock_t timeout); static int uart_open(FAR struct file *filep); static int uart_close(FAR struct file *filep); -static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen); -static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, +static ssize_t uart_read(FAR struct file *filep, + FAR char *buffer, size_t buflen); +static ssize_t uart_write(FAR struct file *filep, + FAR const char *buffer, size_t buflen); -static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg); -static int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup); +static int uart_ioctl(FAR struct file *filep, + int cmd, unsigned long arg); +static int uart_poll(FAR struct file *filep, + FAR struct pollfd *fds, bool setup); -/************************************************************************************ +/**************************************************************************** * Private Data - ************************************************************************************/ + ****************************************************************************/ static const struct file_operations g_serialops = { @@ -114,13 +120,13 @@ static const struct file_operations g_serialops = #endif }; -/************************************************************************************ +/**************************************************************************** * Private Functions - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Name: uart_takesem - ************************************************************************************/ + ****************************************************************************/ static int uart_takesem(FAR sem_t *sem, bool errout) { @@ -134,15 +140,15 @@ static int uart_takesem(FAR sem_t *sem, bool errout) } } -/************************************************************************************ +/**************************************************************************** * Name: uart_givesem - ************************************************************************************/ + ****************************************************************************/ #define uart_givesem(sem) (void)nxsem_post(sem) -/************************************************************************************ +/**************************************************************************** * Name: uart_pollnotify - ************************************************************************************/ + ****************************************************************************/ static void uart_pollnotify(FAR uart_dev_t *dev, pollevent_t eventset) { @@ -183,9 +189,9 @@ static void uart_pollnotify(FAR uart_dev_t *dev, pollevent_t eventset) } } -/************************************************************************************ +/**************************************************************************** * Name: uart_putxmitchar - ************************************************************************************/ + ****************************************************************************/ static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, bool oktoblock) { @@ -197,8 +203,9 @@ static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, bool oktoblock) irqstate_t flags2 = enter_critical_section(); #endif - /* Increment to see what the next head pointer will be. We need to use the "next" - * head pointer to determine when the circular buffer would overrun + /* Increment to see what the next head pointer will be. + * We need to use the "next" head pointer to determine when the circular + * buffer would overrun */ nexthead = dev->xmit.head + 1; @@ -303,8 +310,8 @@ static int uart_putxmitchar(FAR uart_dev_t *dev, int ch, bool oktoblock) if (ret < 0) { - /* A signal received while waiting for the xmit buffer to become - * non-full will abort the transfer. + /* A signal received while waiting for the xmit buffer to + * become non-full will abort the transfer. */ ret = -EINTR; @@ -338,9 +345,9 @@ err_out: return ret; } -/************************************************************************************ +/**************************************************************************** * Name: uart_putc - ************************************************************************************/ + ****************************************************************************/ static inline void uart_putc(FAR uart_dev_t *dev, int ch) { @@ -351,11 +358,12 @@ static inline void uart_putc(FAR uart_dev_t *dev, int ch) uart_send(dev, ch); } -/************************************************************************************ +/**************************************************************************** * Name: uart_irqwrite - ************************************************************************************/ + ****************************************************************************/ -static inline ssize_t uart_irqwrite(FAR uart_dev_t *dev, FAR const char *buffer, +static inline ssize_t uart_irqwrite(FAR uart_dev_t *dev, + FAR const char *buffer, size_t buflen) { ssize_t ret = buflen; @@ -403,24 +411,25 @@ static inline ssize_t uart_irqwrite(FAR uart_dev_t *dev, FAR const char *buffer, return ret; } -/************************************************************************************ +/**************************************************************************** * Name: uart_tcdrain * * Description: - * Block further TX input. Wait until all data has been transferred from the TX - * buffer and until the hardware TX FIFOs are empty. + * Block further TX input. + * Wait until all data has been transferred from the TX buffer and + * until the hardware TX FIFOs are empty. * - ************************************************************************************/ + ****************************************************************************/ static int uart_tcdrain(FAR uart_dev_t *dev, clock_t timeout) { int ret; - /* Get exclusive access to the to dev->tmit. We cannot permit new data to be - * written while we are trying to flush the old data. + /* Get exclusive access to the to dev->tmit. We cannot permit new data to + * be written while we are trying to flush the old data. * - * A signal received while waiting for access to the xmit.head will abort the - * operation with EINTR. + * A signal received while waiting for access to the xmit.head will abort + * the operation with EINTR. */ ret = (ssize_t)uart_takesem(&dev->xmit.sem, true); @@ -521,13 +530,13 @@ static int uart_tcdrain(FAR uart_dev_t *dev, clock_t timeout) return ret; } -/************************************************************************************ +/**************************************************************************** * Name: uart_open * * Description: * This routine is called whenever a serial port is opened. * - ************************************************************************************/ + ****************************************************************************/ static int uart_open(FAR struct file *filep) { @@ -580,7 +589,9 @@ static int uart_open(FAR struct file *filep) { irqstate_t flags = enter_critical_section(); - /* If this is the console, then the UART has already been initialized. */ + /* If this is the console, then the UART has already been + * initialized. + */ if (!dev->isconsole) { @@ -629,14 +640,14 @@ errout_with_sem: return ret; } -/************************************************************************************ +/**************************************************************************** * Name: uart_close * * Description: * This routine is called when the serial port gets closed. * It waits for the last remaining data to be sent. * - ************************************************************************************/ + ****************************************************************************/ static int uart_close(FAR struct file *filep) { @@ -645,9 +656,11 @@ static int uart_close(FAR struct file *filep) irqstate_t flags; /* Get exclusive access to the close semaphore (to synchronize open/close - * operations. NOTE: that we do not let this wait be interrupted by a signal. - * Technically, we should, but almost no one every checks the return value from - * close() so we avoid a potential memory leak by ignoring signals in this case. + * operations. + * NOTE: that we do not let this wait be interrupted by a signal. + * Technically, we should, but almost no one every checks the return value + * from close() so we avoid a potential memory leak by ignoring signals in + * this case. */ uart_takesem(&dev->closesem, false); @@ -700,11 +713,12 @@ static int uart_close(FAR struct file *filep) return OK; } -/************************************************************************************ +/**************************************************************************** * Name: uart_read - ************************************************************************************/ + ****************************************************************************/ -static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen) +static ssize_t uart_read(FAR struct file *filep, + FAR char *buffer, size_t buflen) { FAR struct inode *inode = filep->f_inode; FAR uart_dev_t *dev = inode->i_private; @@ -724,9 +738,9 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen ret = uart_takesem(&rxbuf->sem, true); if (ret < 0) { - /* A signal received while waiting for access to the recv.tail will avort - * the transfer. After the transfer has started, we are committed and - * signals will be ignored. + /* A signal received while waiting for access to the recv.tail will + * abort the transfer. After the transfer has started, we are + * committed and signals will be ignored. */ return ret; @@ -975,16 +989,18 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen if (ret < 0) #endif { - /* POSIX requires that we return after a signal is received. - * If some bytes were read, we need to return the number of bytes - * read; if no bytes were read, we need to return -1 with the - * errno set correctly. + /* POSIX requires that we return after a signal is + * received. + * If some bytes were read, we need to return the + * number of bytes read; if no bytes were read, we + * need to return -1 with the errno set correctly. */ if (recvd == 0) { - /* No bytes were read, return -EINTR (the VFS layer will - * set the errno value appropriately. + /* No bytes were read, return -EINTR + * (the VFS layer will set the errno value + * appropriately). */ #ifdef CONFIG_SERIAL_REMOVABLE @@ -1043,7 +1059,8 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen /* Is the level now below the watermark level that we need to report? */ - watermark = (CONFIG_SERIAL_IFLOWCONTROL_LOWER_WATERMARK * rxbuf->size) / 100; + watermark = (CONFIG_SERIAL_IFLOWCONTROL_LOWER_WATERMARK * + rxbuf->size) / 100; if (nbuffered <= watermark) { /* Let the lower level driver know that the watermark level has been @@ -1068,9 +1085,9 @@ static ssize_t uart_read(FAR struct file *filep, FAR char *buffer, size_t buflen return recvd; } -/************************************************************************************ +/**************************************************************************** * Name: uart_write - ************************************************************************************/ + ****************************************************************************/ static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, size_t buflen) @@ -1082,9 +1099,9 @@ static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, int ret; char ch; - /* We may receive serial writes through this path from interrupt handlers and - * from debug output in the IDLE task! In these cases, we will need to do things - * a little differently. + /* We may receive serial writes through this path from interrupt handlers + * and from debug output in the IDLE task! In these cases, we will need to + * do things a little differently. */ if (up_interrupt_context() || sched_idletask()) @@ -1115,8 +1132,8 @@ static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, if (ret < 0) { /* A signal received while waiting for access to the xmit.head will - * abort the transfer. After the transfer has started, we are committed - * and signals will be ignored. + * abort the transfer. After the transfer has started, we are + * committed and signals will be ignored. */ return ret; @@ -1247,9 +1264,9 @@ static ssize_t uart_write(FAR struct file *filep, FAR const char *buffer, return nwritten; } -/************************************************************************************ +/**************************************************************************** * Name: uart_ioctl - ************************************************************************************/ + ****************************************************************************/ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { @@ -1297,7 +1314,9 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } break; - /* Get the number of bytes that have been written to the TX buffer. */ + /* Get the number of bytes that have been written to the TX + * buffer. + */ case FIONWRITE: { @@ -1337,7 +1356,8 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } else { - count = dev->xmit.size - (dev->xmit.head - dev->xmit.tail) - 1; + count = dev->xmit.size - + (dev->xmit.head - dev->xmit.tail) - 1; } leave_critical_section(flags); @@ -1450,11 +1470,12 @@ static int uart_ioctl(FAR struct file *filep, int cmd, unsigned long arg) return ret; } -/************************************************************************************ +/**************************************************************************** * Name: uart_poll - ************************************************************************************/ + ****************************************************************************/ -static int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup) +static int uart_poll(FAR struct file *filep, + FAR struct pollfd *fds, bool setup) { FAR struct inode *inode = filep->f_inode; FAR uart_dev_t *dev = inode->i_private; @@ -1514,9 +1535,9 @@ static int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup) /* Should we immediately notify on any of the requested events? * First, check if the xmit buffer is full. * - * Get exclusive access to the xmit buffer indices. NOTE: that we do not - * let this wait be interrupted by a signal (we probably should, but that - * would be a little awkward). + * Get exclusive access to the xmit buffer indices. + * NOTE: that we do not let this wait be interrupted by a signal + * (we probably should, but that would be a little awkward). */ eventset = 0; @@ -1537,9 +1558,9 @@ static int uart_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup) /* Check if the receive buffer is empty. * - * Get exclusive access to the recv buffer indices. NOTE: that we do not - * let this wait be interrupted by a signal (we probably should, but that - * would be a little awkward). + * Get exclusive access to the recv buffer indices. + * NOTE: that we do not let this wait be interrupted by a signal + * (we probably should, but that would be a little awkward). */ uart_takesem(&dev->recv.sem, false); @@ -1589,17 +1610,17 @@ errout: return ret; } -/************************************************************************************ +/**************************************************************************** * Public Functions - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Name: uart_register * * Description: * Register serial console and serial ports. * - ************************************************************************************/ + ****************************************************************************/ int uart_register(FAR const char *path, FAR uart_dev_t *dev) { @@ -1633,8 +1654,8 @@ int uart_register(FAR const char *path, FAR uart_dev_t *dev) nxsem_init(&dev->recvsem, 0, 0); nxsem_init(&dev->pollsem, 0, 1); - /* The recvsem and xmitsem are used for signaling and, hence, should not have - * priority inheritance enabled. + /* The recvsem and xmitsem are used for signaling and, hence, should + * not have priority inheritance enabled. */ nxsem_set_protocol(&dev->xmitsem, SEM_PRIO_NONE); @@ -1646,15 +1667,15 @@ int uart_register(FAR const char *path, FAR uart_dev_t *dev) return register_driver(path, &g_serialops, 0666, dev); } -/************************************************************************************ +/**************************************************************************** * Name: uart_datareceived * * Description: - * This function is called from uart_recvchars when new serial data is place in - * the driver's circular buffer. This function will wake-up any stalled read() - * operations that are waiting for incoming data. + * This function is called from uart_recvchars when new serial data is + * place in the driver's circular buffer. This function will wake-up any + * stalled read() operations that are waiting for incoming data. * - ************************************************************************************/ + ****************************************************************************/ void uart_datareceived(FAR uart_dev_t *dev) { @@ -1683,16 +1704,16 @@ void uart_datareceived(FAR uart_dev_t *dev) #endif } -/************************************************************************************ +/**************************************************************************** * Name: uart_datasent * * Description: - * This function is called from uart_xmitchars after serial data has been sent, - * freeing up some space in the driver's circular buffer. This function will - * wake-up any stalled write() operations that was waiting for space to buffer - * outgoing data. + * This function is called from uart_xmitchars after serial data has been + * sent, freeing up some space in the driver's circular buffer. This + * function will wake-up any stalled write() operations that was waiting + * for space to buffer outgoing data. * - ************************************************************************************/ + ****************************************************************************/ void uart_datasent(FAR uart_dev_t *dev) { @@ -1711,17 +1732,19 @@ void uart_datasent(FAR uart_dev_t *dev) } } -/************************************************************************************ +/**************************************************************************** * Name: uart_connected * * Description: - * Serial devices (like USB serial) can be removed. In that case, the "upper - * half" serial driver must be informed that there is no longer a valid serial - * channel associated with the driver. + * Serial devices (like USB serial) can be removed. + * In that case, the "upper half" serial driver must be informed that there + * is no longer a valid serial channel associated with the driver. * - * In this case, the driver will terminate all pending transfers wint ENOTCONN and - * will refuse all further transactions while the "lower half" is disconnected. - * The driver will continue to be registered, but will be in an unusable state. + * In this case, the driver will terminate all pending transfers wint + * ENOTCONN and will refuse all further transactions while the "lower half" + * is disconnected. + * The driver will continue to be registered, but will be in an unusable + * state. * * Conversely, the "upper half" serial driver needs to know when the serial * device is reconnected so that it can resume normal operations. @@ -1729,7 +1752,7 @@ void uart_datasent(FAR uart_dev_t *dev) * Assumptions/Limitations: * This function may be called from an interrupt handler. * - ************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_SERIAL_REMOVABLE void uart_connected(FAR uart_dev_t *dev, bool connected) @@ -1777,14 +1800,15 @@ void uart_connected(FAR uart_dev_t *dev, bool connected) } #endif -/************************************************************************************ +/**************************************************************************** * Name: uart_reset_sem * * Description: - * This function is called when need reset uart semaphore, this may used in kill - * one process, but this process was reading/writing with the semaphore. + * This function is called when need reset uart semaphore, this may used in + * kill one process, but this process was reading/writing with the + * semaphore. * - ************************************************************************************/ + ****************************************************************************/ void uart_reset_sem(FAR uart_dev_t *dev) { diff --git a/drivers/syslog/syslog_chardev.c b/drivers/syslog/syslog_chardev.c index 60f3281ba72..16abf8fb6b1 100644 --- a/drivers/syslog/syslog_chardev.c +++ b/drivers/syslog/syslog_chardev.c @@ -50,15 +50,15 @@ static ssize_t syslog_chardev_write(FAR struct file *filep, static const struct file_operations syslog_fops = { - NULL, /* open */ - NULL, /* close */ - NULL, /* read */ + NULL, /* open */ + NULL, /* close */ + NULL, /* read */ syslog_chardev_write, /* write */ - NULL, /* seek */ - NULL, /* ioctl */ - NULL /* poll */ + NULL, /* seek */ + NULL, /* ioctl */ + NULL /* poll */ #ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS - , NULL /* unlink */ + , NULL /* unlink */ #endif }; diff --git a/drivers/syslog/syslog_device.c b/drivers/syslog/syslog_device.c index 391f375be5e..36f1290dd8b 100644 --- a/drivers/syslog/syslog_device.c +++ b/drivers/syslog/syslog_device.c @@ -244,8 +244,8 @@ static int syslog_dev_outputready(void) { /* Try again to initialize the device. We may do this repeatedly * because the log device might be something that was not ready - * the first time that syslog_dev_initialize() was called (such as a - * USB serial device that has not yet been connected or a file in + * the first time that syslog_dev_initialize() was called (such as + * a USB serial device that has not yet been connected or a file in * an NFS mounted file system that has not yet been mounted). */ @@ -515,7 +515,8 @@ ssize_t syslog_dev_write(FAR const char *buffer, size_t buflen) writelen = (size_t)((uintptr_t)endptr - (uintptr_t)buffer); if (writelen > 0) { - nwritten = file_write(&g_syslog_dev.sl_file, buffer, writelen); + nwritten = file_write(&g_syslog_dev.sl_file, + buffer, writelen); if (nwritten < 0) { ret = (int)nwritten; diff --git a/drivers/syslog/syslog_force.c b/drivers/syslog/syslog_force.c index 38807d91962..e9d6d6359ca 100644 --- a/drivers/syslog/syslog_force.c +++ b/drivers/syslog/syslog_force.c @@ -55,7 +55,8 @@ int syslog_force(int ch) { - DEBUGASSERT(g_syslog_channel != NULL && g_syslog_channel->sc_force != NULL); + DEBUGASSERT(g_syslog_channel != NULL && + g_syslog_channel->sc_force != NULL); #ifdef CONFIG_SYSLOG_INTBUFFER /* Flush any characters that may have been added to the interrupt diff --git a/drivers/syslog/syslog_intbuffer.c b/drivers/syslog/syslog_intbuffer.c index 3471bd3bf43..eb686bb9be6 100644 --- a/drivers/syslog/syslog_intbuffer.c +++ b/drivers/syslog/syslog_intbuffer.c @@ -43,7 +43,8 @@ /* Extend the size of the interrupt buffer so that a "[truncated]\n" * indication can be append to the end. * - * The usable capacity of the interrupt buffer is (CONFIG_SYSLOG_INTBUFSIZE - 1). + * The usable capacity of the interrupt buffer is + * (CONFIG_SYSLOG_INTBUFSIZE - 1). */ #define SYSLOG_BUFOVERRUN_MESSAGE "[truncated]\n" @@ -78,7 +79,8 @@ struct g_syslog_intbuffer_s ****************************************************************************/ static struct g_syslog_intbuffer_s g_syslog_intbuffer; -static const char g_overrun_msg[SYSLOG_BUFOVERRUN_SIZE] = SYSLOG_BUFOVERRUN_MESSAGE; +static const char g_overrun_msg[SYSLOG_BUFOVERRUN_SIZE] = + SYSLOG_BUFOVERRUN_MESSAGE; /**************************************************************************** * Private Data @@ -227,16 +229,16 @@ int syslog_add_intbuffer(int ch) } else if (inuse < USABLE_INTBUFSIZE) { - /* Copy one character */ + /* Copy one character */ - g_syslog_intbuffer.si_buffer[inndx] = (uint8_t)ch; + g_syslog_intbuffer.si_buffer[inndx] = (uint8_t)ch; - /* Increment the IN index, handling wrap-around */ + /* Increment the IN index, handling wrap-around */ - if (++inndx >= SYSLOG_INTBUFSIZE) - { - inndx -= SYSLOG_INTBUFSIZE; - } + if (++inndx >= SYSLOG_INTBUFSIZE) + { + inndx -= SYSLOG_INTBUFSIZE; + } g_syslog_intbuffer.si_inndx = (uint16_t)inndx; ret = OK; diff --git a/drivers/syslog/syslog_putc.c b/drivers/syslog/syslog_putc.c index 312916cc155..1078aa2e759 100644 --- a/drivers/syslog/syslog_putc.c +++ b/drivers/syslog/syslog_putc.c @@ -64,8 +64,9 @@ int syslog_putc(int ch) #if defined(CONFIG_SYSLOG_INTBUFFER) if (up_interrupt_context()) { - /* Buffer the character in the interrupt buffer. The interrupt buffer - * will be flushed before the next normal, non-interrupt SYSLOG output. + /* Buffer the character in the interrupt buffer. + * The interrupt buffer will be flushed before the next normal, + * non-interrupt SYSLOG output. */ return syslog_add_intbuffer(ch); @@ -73,7 +74,8 @@ int syslog_putc(int ch) else #endif { - /* Force the character to the SYSLOG device immediately (if possible). + /* Force the character to the SYSLOG device immediately + * (if possible). * This means that the interrupt data may not be in synchronization * with output data that may have been buffered by sc_putc(). */ diff --git a/drivers/syslog/syslog_stream.c b/drivers/syslog/syslog_stream.c index 3d5a374e935..a44bd5b9473 100644 --- a/drivers/syslog/syslog_stream.c +++ b/drivers/syslog/syslog_stream.c @@ -84,7 +84,8 @@ static int syslogstream_flush(FAR struct lib_syslogstream_s *stream) ****************************************************************************/ #ifdef CONFIG_SYSLOG_BUFFER -static void syslogstream_addchar(FAR struct lib_syslogstream_s *stream, int ch) +static void syslogstream_addchar(FAR struct lib_syslogstream_s *stream, + int ch) { FAR struct iob_s *iob = stream->iob; diff --git a/drivers/timers/ds3231.c b/drivers/timers/ds3231.c index ff0a469617c..329f925334f 100644 --- a/drivers/timers/ds3231.c +++ b/drivers/timers/ds3231.c @@ -1,4 +1,4 @@ -/************************************************************************************ +/**************************************************************************** * drivers/timers/ds3231.c * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,11 +16,11 @@ * License for the specific language governing permissions and limitations * under the License. * - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Included Files - ************************************************************************************/ + ****************************************************************************/ #include @@ -37,11 +37,11 @@ #ifdef CONFIG_RTC_DSXXXX -/************************************************************************************ +/**************************************************************************** * Pre-processor Definitions - ************************************************************************************/ + ****************************************************************************/ -/* Configuration ********************************************************************/ +/* Configuration ************************************************************/ /* This RTC implementation supports only date/time RTC hardware */ @@ -64,12 +64,12 @@ #define DS3231_I2C_ADDRESS 0x68 -/************************************************************************************ +/**************************************************************************** * Private Types - ************************************************************************************/ + ****************************************************************************/ -/* This structure describes the state of the DS3231 chip. Only a single RTC is - * supported. +/* This structure describes the state of the DS3231 chip. + * Only a single RTC is supported. */ struct ds3231_dev_s @@ -77,27 +77,27 @@ struct ds3231_dev_s FAR struct i2c_master_s *i2c; /* Contained reference to the I2C bus driver */ }; -/************************************************************************************ +/**************************************************************************** * Public Data - ************************************************************************************/ + ****************************************************************************/ /* g_rtc_enabled is set true after the RTC has successfully initialized */ volatile bool g_rtc_enabled = false; -/************************************************************************************ +/**************************************************************************** * Private Data - ************************************************************************************/ + ****************************************************************************/ /* The state of the DS3231 chip. Only a single RTC is supported */ static struct ds3231_dev_s g_ds3231; -/************************************************************************************ +/**************************************************************************** * Private Functions - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Name: rtc_dumptime * * Description: @@ -109,7 +109,7 @@ static struct ds3231_dev_s g_ds3231; * Returned Value: * None * - ************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_DEBUG_RTC_INFO static void rtc_dumptime(FAR struct tm *tp, FAR const char *msg) @@ -129,7 +129,7 @@ static void rtc_dumptime(FAR struct tm *tp, FAR const char *msg) # define rtc_dumptime(tp, msg) #endif -/************************************************************************************ +/**************************************************************************** * Name: rtc_bin2bcd * * Description: @@ -141,7 +141,7 @@ static void rtc_dumptime(FAR struct tm *tp, FAR const char *msg) * Returned Value: * The value in BCD representation * - ************************************************************************************/ + ****************************************************************************/ static uint8_t rtc_bin2bcd(int value) { @@ -156,7 +156,7 @@ static uint8_t rtc_bin2bcd(int value) return (msbcd << 4) | value; } -/************************************************************************************ +/**************************************************************************** * Name: rtc_bcd2bin * * Description: @@ -168,7 +168,7 @@ static uint8_t rtc_bin2bcd(int value) * Returned Value: * The value in binary representation * - ************************************************************************************/ + ****************************************************************************/ static int rtc_bcd2bin(uint8_t value) { @@ -176,23 +176,25 @@ static int rtc_bcd2bin(uint8_t value) return tens + (value & 0x0f); } -/************************************************************************************ +/**************************************************************************** * Public Functions - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Name: dsxxxx_rtc_initialize * * Description: - * Initialize the hardware RTC per the selected configuration. This function is - * called once during the OS initialization sequence by board-specific logic. + * Initialize the hardware RTC per the selected configuration. + * This function is called once during the OS initialization sequence by + * board-specific logic. * - * After dsxxxx_rtc_initialize() is called, the OS function clock_synchronize() - * should also be called to synchronize the system timer to a hardware RTC. That - * operation is normally performed automatically by the system during clock - * initialization. However, when an external RTC is used, the board logic will - * need to explicitly re-synchronize the system timer to the RTC when the RTC - * becomes available. + * After dsxxxx_rtc_initialize() is called, the OS function + * clock_synchronize() should also be called to synchronize the system + * timer to a hardware RTC. That operation is normally performed + * automatically by the system during clock initialization. However, when + * an external RTC is used, the board logic will need to explicitly + * re-synchronize the system timer to the RTC when the RTC becomes + * available. * * Input Parameters: * None @@ -200,7 +202,7 @@ static int rtc_bcd2bin(uint8_t value) * Returned Value: * Zero (OK) on success; a negated errno on failure * - ************************************************************************************/ + ****************************************************************************/ int dsxxxx_rtc_initialize(FAR struct i2c_master_s *i2c) { @@ -211,20 +213,21 @@ int dsxxxx_rtc_initialize(FAR struct i2c_master_s *i2c) return OK; } -/************************************************************************************ +/**************************************************************************** * Name: up_rtc_getdatetime * * Description: * Get the current date and time from the date/time RTC. This interface * is only supported by the date/time RTC hardware implementation. - * It is used to replace the system timer. It is only used by the RTOS during - * initialization to set up the system time when CONFIG_RTC and CONFIG_RTC_DATETIME - * are selected (and CONFIG_RTC_HIRES is not). + * It is used to replace the system timer. It is only used by the RTOS + * during initialization to set up the system time when CONFIG_RTC and + * CONFIG_RTC_DATETIME are selected (and CONFIG_RTC_HIRES is not). * - * NOTE: Some date/time RTC hardware is capability of sub-second accuracy. That - * sub-second accuracy is lost in this interface. However, since the system time - * is reinitialized on each power-up/reset, there will be no timing inaccuracy in - * the long run. + * NOTE: + * Some date/time RTC hardware is capability of sub-second accuracy. + * That sub-second accuracy is lost in this interface. However, since the + * system time is reinitialized on each power-up/reset, there will be no + * timing inaccuracy in the long run. * * Input Parameters: * tp - The location to return the high resolution time value. @@ -232,7 +235,7 @@ int dsxxxx_rtc_initialize(FAR struct i2c_master_s *i2c) * Returned Value: * Zero (OK) on success; a negated errno on failure * - ************************************************************************************/ + ****************************************************************************/ int up_rtc_getdatetime(FAR struct tm *tp) { @@ -243,8 +246,9 @@ int up_rtc_getdatetime(FAR struct tm *tp) int tmp; int ret; - /* If this function is called before the RTC has been initialized (and it will be), - * then just return the data/time of the epoch, 12:00 am, Jan 1, 1970. + /* If this function is called before the RTC has been initialized + * (and it will be), then just return the data/time of the epoch, + * 12:00 am, Jan 1, 1970. */ if (!g_rtc_enabled) @@ -297,7 +301,8 @@ int up_rtc_getdatetime(FAR struct tm *tp) msg[3].length = 1; /* Perform the transfer. The transfer may be performed repeatedly of the - * seconds values decreases, meaning that that was a rollover in the seconds. + * seconds values decreases, meaning that that was a rollover in the + * seconds. */ do @@ -352,8 +357,8 @@ int up_rtc_getdatetime(FAR struct tm *tp) tp->tm_year = tmp + 100; } #else - /* No century indicator. The RTC will hold years since 1968 (a leap year like - * 2000) + /* No century indicator. + * The RTC will hold years since 1968 (a leap year like 2000) */ tp->tm_year = tmp + 68; @@ -363,12 +368,12 @@ int up_rtc_getdatetime(FAR struct tm *tp) return OK; } -/************************************************************************************ +/**************************************************************************** * Name: up_rtc_settime * * Description: - * Set the RTC to the provided time. All RTC implementations must be able to - * set their time based on a standard timespec. + * Set the RTC to the provided time. All RTC implementations must be able + * to set their time based on a standard timespec. * * Input Parameters: * tp - the time to use @@ -376,7 +381,7 @@ int up_rtc_getdatetime(FAR struct tm *tp) * Returned Value: * Zero (OK) on success; a negated errno on failure * - ************************************************************************************/ + ****************************************************************************/ int up_rtc_settime(FAR const struct timespec *tp) { @@ -389,8 +394,8 @@ int up_rtc_settime(FAR const struct timespec *tp) uint8_t year; int ret; - /* If this function is called before the RTC has been initialized then just return - * an error. + /* If this function is called before the RTC has been initialized then just + * return an error. */ if (!g_rtc_enabled) diff --git a/drivers/timers/ds3231.h b/drivers/timers/ds3231.h index 3013af12471..1da501f1eb7 100644 --- a/drivers/timers/ds3231.h +++ b/drivers/timers/ds3231.h @@ -152,6 +152,7 @@ # define DS1307_CR_RS_4KHZ (1 << DS1307_CR_RS_SHIFT) /* 4.096kHz */ # define DS1307_CR_RS_8KHZ (2 << DS1307_CR_RS_SHIFT) /* 8.192kHz */ # define DS1307_CR_RS_32KHZ (3 << DS1307_CR_RS_SHIFT) /* 32.768kHz */ + # define DS1307_CR_SQWE (1 << 4) /* Bit 4: Square wave enable */ # define DS1307_CR_OUT (1 << 7) /* Bit 7: Output control */ # define DS1307_RAM_BASER 0x08 /* 0x08-0x3f: 56x8 RAM */ @@ -290,6 +291,7 @@ # define DS323X_CR_RS_1KHZ (1 << DS323X_CR_RS_SHIFT) /* 1.024kHz */ # define DS323X_CR_RS_4KHZ (2 << DS323X_CR_RS_SHIFT) /* 4.096kHz */ # define DS323X_CR_RS_8KHZ (3 << DS323X_CR_RS_SHIFT) /* 8.192kHz */ + # define DS323X_CR_CONV (1 << 5) /* Bit 5: Convert temperature */ # define DS323X_CR_BBSQW (1 << 6) /* Bit 6: Battery backed square wave enable */ # define DS323X_CR_EOSC (1 << 7) /* Bit 7: Enable oscillator */ diff --git a/drivers/timers/pcf85263.c b/drivers/timers/pcf85263.c index 57a88def1ef..e28685669a7 100644 --- a/drivers/timers/pcf85263.c +++ b/drivers/timers/pcf85263.c @@ -1,4 +1,4 @@ -/************************************************************************************ +/**************************************************************************** * drivers/timers/pcf85263.c * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -16,11 +16,11 @@ * License for the specific language governing permissions and limitations * under the License. * - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Included Files - ************************************************************************************/ + ****************************************************************************/ #include @@ -37,11 +37,11 @@ #ifdef CONFIG_RTC_PCF85263 -/************************************************************************************ +/**************************************************************************** * Pre-processor Definitions - ************************************************************************************/ + ****************************************************************************/ -/* Configuration ********************************************************************/ +/* Configuration ************************************************************/ /* This RTC implementation supports only date/time RTC hardware */ @@ -64,12 +64,12 @@ #define PCF85263_I2C_ADDRESS 0x51 -/************************************************************************************ +/**************************************************************************** * Private Types - ************************************************************************************/ + ****************************************************************************/ -/* This structure describes the state of the PCF85263 chip. Only a single RTC is - * supported. +/* This structure describes the state of the PCF85263 chip. + * Only a single RTC is supported. */ struct pcf85263_dev_s @@ -77,27 +77,27 @@ struct pcf85263_dev_s FAR struct i2c_master_s *i2c; /* Contained reference to the I2C bus driver */ }; -/************************************************************************************ +/**************************************************************************** * Public Data - ************************************************************************************/ + ****************************************************************************/ /* g_rtc_enabled is set true after the RTC has successfully initialized */ volatile bool g_rtc_enabled = false; -/************************************************************************************ +/**************************************************************************** * Private Data - ************************************************************************************/ + ****************************************************************************/ /* The state of the PCF85263 chip. Only a single RTC is supported */ static struct pcf85263_dev_s g_pcf85263; -/************************************************************************************ +/**************************************************************************** * Private Functions - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Name: rtc_dumptime * * Description: @@ -109,7 +109,7 @@ static struct pcf85263_dev_s g_pcf85263; * Returned Value: * None * - ************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_DEBUG_RTC_INFO static void rtc_dumptime(FAR struct tm *tp, FAR const char *msg) @@ -129,7 +129,7 @@ static void rtc_dumptime(FAR struct tm *tp, FAR const char *msg) # define rtc_dumptime(tp, msg) #endif -/************************************************************************************ +/**************************************************************************** * Name: rtc_bin2bcd * * Description: @@ -141,7 +141,7 @@ static void rtc_dumptime(FAR struct tm *tp, FAR const char *msg) * Returned Value: * The value in BCD representation * - ************************************************************************************/ + ****************************************************************************/ static uint8_t rtc_bin2bcd(int value) { @@ -156,7 +156,7 @@ static uint8_t rtc_bin2bcd(int value) return (msbcd << 4) | value; } -/************************************************************************************ +/**************************************************************************** * Name: rtc_bcd2bin * * Description: @@ -168,7 +168,7 @@ static uint8_t rtc_bin2bcd(int value) * Returned Value: * The value in binary representation * - ************************************************************************************/ + ****************************************************************************/ static int rtc_bcd2bin(uint8_t value) { @@ -176,22 +176,24 @@ static int rtc_bcd2bin(uint8_t value) return tens + (value & 0x0f); } -/************************************************************************************ +/**************************************************************************** * Public Functions - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Name: pcf85263_rtc_initialize * * Description: - * Initialize the hardware RTC per the selected configuration. This function is - * called once during the OS initialization sequence by board-specific logic. + * Initialize the hardware RTC per the selected configuration. + * This function is called once during the OS initialization sequence by + * board-specific logic. * - * After pcf85263_rtc_initialize() is called, the OS function clock_synchronize() - * should also be called to synchronize the system timer to a hardware RTC. That - * operation is normally performed automatically by the system during clock - * initialization. However, when an external RTC is used, the board logic will - * need to explicitly re-synchronize the system timer to the RTC when the RTC + * After pcf85263_rtc_initialize() is called, the OS function + * clock_synchronize() should also be called to synchronize the system + * timer to a hardware RTC. That operation is normally performed + * automatically by the system during clock initialization. + * However, when an external RTC is used, the board logic will need to + * explicitly re-synchronize the system timer to the RTC when the RTC * becomes available. * * Input Parameters: @@ -200,7 +202,7 @@ static int rtc_bcd2bin(uint8_t value) * Returned Value: * Zero (OK) on success; a negated errno on failure * - ************************************************************************************/ + ****************************************************************************/ int pcf85263_rtc_initialize(FAR struct i2c_master_s *i2c) { @@ -211,20 +213,21 @@ int pcf85263_rtc_initialize(FAR struct i2c_master_s *i2c) return OK; } -/************************************************************************************ +/**************************************************************************** * Name: up_rtc_getdatetime * * Description: - * Get the current date and time from the date/time RTC. This interface - * is only supported by the date/time RTC hardware implementation. - * It is used to replace the system timer. It is only used by the RTOS during - * initialization to set up the system time when CONFIG_RTC and CONFIG_RTC_DATETIME - * are selected (and CONFIG_RTC_HIRES is not). + * Get the current date and time from the date/time RTC. + * This interface is only supported by the date/time RTC hardware + * implementation. + * It is used to replace the system timer. It is only used by the RTOS + * during initialization to set up the system time when CONFIG_RTC and + * CONFIG_RTC_DATETIME are selected (and CONFIG_RTC_HIRES is not). * - * NOTE: Some date/time RTC hardware is capability of sub-second accuracy. That - * sub-second accuracy is lost in this interface. However, since the system time - * is reinitialized on each power-up/reset, there will be no timing inaccuracy in - * the long run. + * NOTE: Some date/time RTC hardware is capability of sub-second accuracy. + * That sub-second accuracy is lost in this interface. However, since the + * system time is reinitialized on each power-up/reset, there will be no + * timing inaccuracy in the long run. * * Input Parameters: * tp - The location to return the high resolution time value. @@ -232,7 +235,7 @@ int pcf85263_rtc_initialize(FAR struct i2c_master_s *i2c) * Returned Value: * Zero (OK) on success; a negated errno on failure * - ************************************************************************************/ + ****************************************************************************/ int up_rtc_getdatetime(FAR struct tm *tp) { @@ -242,8 +245,9 @@ int up_rtc_getdatetime(FAR struct tm *tp) uint8_t seconds; int ret; - /* If this function is called before the RTC has been initialized (and it will be), - * then just return the data/time of the epoch, 12:00 am, Jan 1, 1970. + /* If this function is called before the RTC has been initialized + * (and it will be), then just return the data/time of the epoch, + * 12:00 am, Jan 1, 1970. */ if (!g_rtc_enabled) @@ -296,7 +300,8 @@ int up_rtc_getdatetime(FAR struct tm *tp) msg[3].length = 1; /* Perform the transfer. The transfer may be performed repeatedly of the - * seconds values decreases, meaning that that was a rollover in the seconds. + * seconds values decreases, meaning that that was a rollover in the + * seconds. */ do @@ -337,8 +342,8 @@ int up_rtc_getdatetime(FAR struct tm *tp) tp->tm_mon = rtc_bcd2bin(buffer[5] & PCF85263_RTC_MONTHS_MASK) - 1; - /* Return the years since 1900. The RTC will hold years since 1968 (a leap year - * like 2000). + /* Return the years since 1900. The RTC will hold years since 1968 + * (a leap year like 2000). */ tp->tm_year = rtc_bcd2bin(buffer[6]) + 68; @@ -347,12 +352,12 @@ int up_rtc_getdatetime(FAR struct tm *tp) return OK; } -/************************************************************************************ +/**************************************************************************** * Name: up_rtc_settime * * Description: - * Set the RTC to the provided time. All RTC implementations must be able to - * set their time based on a standard timespec. + * Set the RTC to the provided time. All RTC implementations must be able + * to set their time based on a standard timespec. * * Input Parameters: * tp - the time to use @@ -360,7 +365,7 @@ int up_rtc_getdatetime(FAR struct tm *tp) * Returned Value: * Zero (OK) on success; a negated errno on failure * - ************************************************************************************/ + ****************************************************************************/ int up_rtc_settime(FAR const struct timespec *tp) { @@ -372,8 +377,8 @@ int up_rtc_settime(FAR const struct timespec *tp) uint8_t seconds; int ret; - /* If this function is called before the RTC has been initialized then just return - * an error. + /* If this function is called before the RTC has been initialized then just + * return an error. */ if (!g_rtc_enabled) diff --git a/drivers/timers/pcf85263.h b/drivers/timers/pcf85263.h index 8599162c026..ccdf6fd9eb7 100644 --- a/drivers/timers/pcf85263.h +++ b/drivers/timers/pcf85263.h @@ -180,6 +180,7 @@ # define PCF85263_RTC_TSR_TSR1M_NONE (0 << PCF85263_RTC_TSR_TSR1M_SHIFT) /* No timestamp */ # define PCF85263_RTC_TSR_TSR1M_FE (1 << PCF85263_RTC_TSR_TSR1M_SHIFT) /* Record First TS pin Event */ # define PCF85263_RTC_TSR_TSR1M_LE (2 << PCF85263_RTC_TSR_TSR1M_SHIFT) /* Record Last TS pin Event */ + # define PCF85263_RTC_TSR_TSR2M_SHIFT (2) /* Bit 2-4: Timestamp register 2 mode */ # define PCF85263_RTC_TSR_TSR2M_MASK (7 << PCF85263_RTC_TSR_TSR2M_SHIFT) # define PCF85263_RTC_TSR_TSR2M_NONE (0 << PCF85263_RTC_TSR_TSR2M_SHIFT) /* No timestamp */ @@ -188,6 +189,7 @@ # define PCF85263_RTC_TSR_TSR2M_LV (3 << PCF85263_RTC_TSR_TSR2M_SHIFT) /* Record Last time switch to VDD event */ # define PCF85263_RTC_TSR_TSR2M_FE (4 << PCF85263_RTC_TSR_TSR2M_SHIFT) /* Record First TS pin Event */ # define PCF85263_RTC_TSR_TSR2M_LE (5 << PCF85263_RTC_TSR_TSR2M_SHIFT) /* Record Last TS pin Event */ + # define PCF85263_RTC_TSR_TSR3M_SHIFT (6) /* Bit 6-7: Timestamp register 3 mode */ # define PCF85263_RTC_TSR_TSR3M_MASK (3 << PCF85263_RTC_TSR_TSR3M_SHIFT) # define PCF85263_RTC_TSR_TSR3M_NONE (0 << PCF85263_RTC_TSR_TSR3M_SHIFT) /* No timestamp */ @@ -303,6 +305,7 @@ # define PCF85263_STW_TSR_TSR1M_NONE (0 << PCF85263_STW_TSR_TSR1M_SHIFT) /* No timestamp */ # define PCF85263_STW_TSR_TSR1M_FE (1 << PCF85263_STW_TSR_TSR1M_SHIFT) /* Record First TS pin Event */ # define PCF85263_STW_TSR_TSR1M_LE (2 << PCF85263_STW_TSR_TSR1M_SHIFT) /* Record Last TS pin Event */ + # define PCF85263_STW_TSR_TSR2M_SHIFT (2) /* Bit 2-4: Timestamp register 2 mode */ # define PCF85263_STW_TSR_TSR2M_MASK (7 << PCF85263_STW_TSR_TSR2M_SHIFT) # define PCF85263_STW_TSR_TSR2M_NONE (0 << PCF85263_STW_TSR_TSR2M_SHIFT) /* No timestamp */ @@ -311,6 +314,7 @@ # define PCF85263_STW_TSR_TSR2M_LV (3 << PCF85263_STW_TSR_TSR2M_SHIFT) /* Record Last time switch to VDD event */ # define PCF85263_STW_TSR_TSR2M_FE (4 << PCF85263_STW_TSR_TSR2M_SHIFT) /* Record First TS pin Event */ # define PCF85263_STW_TSR_TSR2M_LE (5 << PCF85263_STW_TSR_TSR2M_SHIFT) /* Record Last TS pin Event */ + # define PCF85263_STW_TSR_TSR3M_SHIFT (6) /* Bit 6-7: Timestamp register 3 mode */ # define PCF85263_STW_TSR_TSR3M_MASK (3 << PCF85263_STW_TSR_TSR3M_SHIFT) # define PCF85263_STW_TSR_TSR3M_NONE (0 << PCF85263_STW_TSR_TSR3M_SHIFT) /* No timestamp */ @@ -331,11 +335,13 @@ # define PCF85263_CTL_OSC_CL_7PF (0 << PCF85263_CTL_OSC_CL_SHIFT) /* 7.0 pF */ # define PCF85263_CTL_OSC_CL_6PF (1 << PCF85263_CTL_OSC_CL_SHIFT) /* 6.0 pF */ # define PCF85263_CTL_OSC_CL_12p5PF (2 << PCF85263_CTL_OSC_CL_SHIFT) /* 12.5 pF */ + # define PCF85263_CTL_OSC_OSCD_SHIFT (2) /* Bits 1-2: Oscillator driver bits */ # define PCF85263_CTL_OSC_OSCD_MASK (3 << PCF85263_CTL_OSC_OSCD_SHIFT) # define PCF85263_CTL_OSC_OSCD_NORMAL (0 << PCF85263_CTL_OSC_OSCD_SHIFT) /* Normal drive; RS(max): 100 kohm */ # define PCF85263_CTL_OSC_OSCD_LOW (1 << PCF85263_CTL_OSC_OSCD_SHIFT) /* Low drive; RS(max): 60 kohm; reduced IDD */ # define PCF85263_CTL_OSC_OSCD_HIGH (2 << PCF85263_CTL_OSC_OSCD_SHIFT) /* High drive; RS(max): 500 kohm; increased IDD */ + # define PCF85263_CTL_OSC_LOWJ (1 << 4) /* Bit 4: Low jitter mode */ # define PCF85263_CTL_OSC_12_24 (1 << 5) /* Bit 5: 12-/24-hour mode */ # define PCF85263_CTL_OSC_OFFM (1 << 6) /* Bit 6: Offset calibration mode */ @@ -349,6 +355,7 @@ # define PCF85263_CTL_BATTERY_BSM_VBAT (1 << PCF85263_CTL_BATTERY_BSM_SHIFT) /* Switching at the VBAT level */ # define PCF85263_CTL_BATTERY_BSM_MAX (2 << PCF85263_CTL_BATTERY_BSM_SHIFT) /* Switching at the higher level of Vth or VBAT */ # define PCF85263_CTL_BATTERY_BSM_MIN (3 << PCF85263_CTL_BATTERY_BSM_SHIFT) /* Switching at the lower level of Vth or VBAT */ + # define PCF85263_CTL_BATTERY_BSRR (1 << 3) /* Bit 3: Battery switch refresh rate */ # define PCF85263_CTL_BATTERY_BSOFF (1 << 4) /* Bit 4: Battery switch on/off */ @@ -359,12 +366,14 @@ # define PCF85263_CTL_INTAPM_BAT (1 << PCF85263_CTL_INTAPM_SHIFT) /* Battery mode indication */ # define PCF85263_CTL_INTAPM_INTA (2 << PCF85263_CTL_INTAPM_SHIFT) /* INTA output */ # define PCF85263_CTL_INTAPM_HIZ (3 << PCF85263_CTL_INTAPM_SHIFT) /* Hi-Z */ + # define PCF85263_CTL_TSPM_SHIFT (2) /* Bits 2-3: TS pin I/O control */ # define PCF85263_CTL_TSPM_MASK (3 << PCF85263_CTL_TSPM_SHIFT) # define PCF85263_CTL_TSPM_DISABLED (0 << PCF85263_CTL_TSPM_SHIFT) /* Disabled; input can be left floating */ # define PCF85263_CTL_TSPM_INTB (1 << PCF85263_CTL_TSPM_SHIFT) /* INTB output; push-pull */ # define PCF85263_CTL_TSPM_CLK (2 << PCF85263_CTL_TSPM_SHIFT) /* CLK output; push-pull */ # define PCF85263_CTL_TSPM_INPUT (3 << PCF85263_CTL_TSPM_SHIFT) /* Input mode */ + # define PCF85263_CTL_TSIM (1 << 4) /* Bit 4: TS pin input mode */ # define PCF85263_CTL_TSL (1 << 5) /* Bit 5: TS pin input sense */ # define PCF85263_CTL_TSPULL (1 << 6) /* Bit 6: TS pin pull-up resistor value */ @@ -372,6 +381,7 @@ #define PCF85263_CTL_FUNCTION 0x28 /* Function control register */ # define PCF85263_CTL_FUNC_COF_SHIFT (0) /* Bits 0-2: Clock output frequency */ + # define PCF85263_CTL_FUNC_COF_MASK (7 << PCF85263_CTL_FUNC_COF_SHIFT) /* CLK pin TS pin INTA pin */ # define PCF85263_CTL_FUNC_COF_32KHZ (0 << PCF85263_CTL_FUNC_COF_SHIFT) /* 32768 32768 32768 */ # define PCF85263_CTL_FUNC_COF_16KHZ (1 << PCF85263_CTL_FUNC_COF_SHIFT) /* 16384 16384 16384 */ @@ -381,6 +391,7 @@ # define PCF85263_CTL_FUNC_COF_1KHZ (5 << PCF85263_CTL_FUNC_COF_SHIFT) /* 1024 1024 1024 */ # define PCF85263_CTL_FUNC_COF_1HZ (6 << PCF85263_CTL_FUNC_COF_SHIFT) /* 1 1 1 */ # define PCF85263_CTL_FUNC_COF_LOW (7 << PCF85263_CTL_FUNC_COF_SHIFT) /* static LOW static LOW Hi-Z */ + # define PCF85263_CTL_FUNC_STOPM (1 << 3) /* Bit 3: STOP mode */ # define PCF85263_CTL_FUNC_RTCM (1 << 4) /* Bit 4: RTC mode */ # define PCF85263_CTL_FUNC_PI_SHIFT (5) /* Bits 5-6: Periodic interrupt */ @@ -389,6 +400,7 @@ # define PCF85263_CTL_FUNC_PI_SEC (1 << PCF85263_CTL_FUNC_PI_SHIFT) /* Once per second */ # define PCF85263_CTL_FUNC_PI_MIN (2 << PCF85263_CTL_FUNC_PI_SHIFT) /* Once per minute */ # define PCF85263_CTL_FUNC_PI_HOUR (3 << PCF85263_CTL_FUNC_PI_SHIFT) /* Once per hour */ + # define PCF85263_CTL_FUNC_100TH (1 << 7) /* Bit 7: 100th seconds mode */ #define PCF85263_CTL_INTA_ENABLE 0x29 /* Interrupt A control bits */ @@ -435,6 +447,7 @@ # define PCF85263_CTL_WDS_1SEC (1 << PCF85263_CTL_WDS_SHIFT) /* 1 second (1 Hz) */ # define PCF85263_CTL_WDS_250MSEC (2 << PCF85263_CTL_WDS_SHIFT) /* 1â„4 second (4 Hz) */ # define PCF85263_CTL_WDS_67MSEC (3 << PCF85263_CTL_WDS_SHIFT) /* 1â„16 second (16 Hz) */ + # define PCF85263_CTL_WDR_SHIFT (2) /* Bits 2-6: Watchdog register bits */ # define PCF85263_CTL_WDR_MASK (31 << PCF85263_CTL_WDR_SHIFT) # define PCF85263_CTL_WDR(n) ((uint9_t)(n) << PCF85263_CTL_WDR_SHIFT) diff --git a/drivers/usbdev/cdcacm.h b/drivers/usbdev/cdcacm.h index ecc43f407a4..3c423abbac4 100644 --- a/drivers/usbdev/cdcacm.h +++ b/drivers/usbdev/cdcacm.h @@ -63,8 +63,8 @@ # endif #endif -/* Interface IDs. If the serial driver is built as a component of a composite - * device, then the interface IDs may need to be offset. +/* Interface IDs. If the serial driver is built as a component of a + * composite device, then the interface IDs may need to be offset. */ #ifndef CONFIG_CDCACM_COMPOSITE @@ -145,7 +145,7 @@ #define CDCACM_LASTSTRID CDCACM_DATAIFSTRID #define CDCACM_NSTRIDS (CDCACM_LASTSTRID - CDCACM_STRBASE) -/* Endpoint configuration ****************************************************/ +/* Endpoint configuration ***************************************************/ #define CDCACM_MKEPINTIN(desc) (USB_DIR_IN | (desc)->epno[CDCACM_EP_INTIN_IDX]) #define CDCACM_EPINTIN_ATTR (USB_EP_ATTR_XFER_INT) diff --git a/drivers/usbdev/cdcacm_desc.c b/drivers/usbdev/cdcacm_desc.c index 75696fd467d..1ec1fb404a5 100644 --- a/drivers/usbdev/cdcacm_desc.c +++ b/drivers/usbdev/cdcacm_desc.c @@ -42,7 +42,7 @@ * Private Data ****************************************************************************/ -/* USB descriptor templates these will be copied and modified **************/ +/* USB descriptor templates these will be copied and modified ***************/ /* Device Descriptor. If the USB serial device is configured as part of * composite device, then the device descriptor will be provided by the @@ -358,8 +358,9 @@ int16_t cdcacm_mkcfgdesc(FAR uint8_t *buf, #if !defined(CONFIG_CDCACM_COMPOSITE) if (buf != NULL) { - /* Configuration descriptor. If the USB serial device is configured as part of - * composite device, then the configuration descriptor will be provided by the + /* Configuration descriptor. + * If the USB serial device is configured as part of composite device, + * then the configuration descriptor will be provided by the * composite device logic. */ @@ -451,7 +452,8 @@ int16_t cdcacm_mkcfgdesc(FAR uint8_t *buf, if (buf != NULL) { - FAR struct cdc_hdr_funcdesc_s *dest = (FAR struct cdc_hdr_funcdesc_s *)buf; + FAR struct cdc_hdr_funcdesc_s *dest = + (FAR struct cdc_hdr_funcdesc_s *)buf; dest->size = SIZEOF_HDR_FUNCDESC; /* Descriptor length */ dest->type = USB_DESC_TYPE_CSINTERFACE; /* Descriptor type */ @@ -468,7 +470,8 @@ int16_t cdcacm_mkcfgdesc(FAR uint8_t *buf, if (buf != NULL) { - FAR struct cdc_acm_funcdesc_s *dest = (FAR struct cdc_acm_funcdesc_s *)buf; + FAR struct cdc_acm_funcdesc_s *dest = + (FAR struct cdc_acm_funcdesc_s *)buf; dest->size = SIZEOF_ACM_FUNCDESC; /* Descriptor length */ dest->type = USB_DESC_TYPE_CSINTERFACE; /* Descriptor type */ @@ -487,7 +490,8 @@ int16_t cdcacm_mkcfgdesc(FAR uint8_t *buf, if (buf != NULL) { - FAR struct cdc_union_funcdesc_s *dest = (FAR struct cdc_union_funcdesc_s *)buf; + FAR struct cdc_union_funcdesc_s *dest = + (FAR struct cdc_union_funcdesc_s *)buf; dest->size = SIZEOF_UNION_FUNCDESC(1); /* Descriptor length */ dest->type = USB_DESC_TYPE_CSINTERFACE; /* Descriptor type */ diff --git a/drivers/usbdev/composite.c b/drivers/usbdev/composite.c index fc3c632a986..053dc363693 100644 --- a/drivers/usbdev/composite.c +++ b/drivers/usbdev/composite.c @@ -78,7 +78,7 @@ static struct usbdev_req_s *composite_allocreq(FAR struct usbdev_ep_s *ep, static void composite_freereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req); -/* USB class device ********************************************************/ +/* USB class device *********************************************************/ static int composite_bind(FAR struct usbdevclass_driver_s *driver, FAR struct usbdev_s *dev); @@ -214,7 +214,8 @@ static int composite_msftdescriptor(FAR struct composite_dev_s *priv, memset(func, 0, sizeof(*func)); func->firstif = priv->device[i].compdesc.devinfo.ifnobase; func->nifs = priv->device[i].compdesc.devinfo.ninterfaces; - memcpy(func->compatible_id, priv->device[i].compdesc.msft_compatible_id, + memcpy(func->compatible_id, + priv->device[i].compdesc.msft_compatible_id, sizeof(func->compatible_id)); memcpy(func->sub_id, priv->device[i].compdesc.msft_sub_id, sizeof(func->sub_id)); @@ -248,8 +249,8 @@ static int composite_msftdescriptor(FAR struct composite_dev_s *priv, /* Extended properties are per-interface, pass the request to * subdevice. NOTE: The documentation in OS_Desc_Ext_Prop.docx seems * a bit incorrect here, the interface is in ctrl->value low byte. - * Also WinUSB driver has limitation that index[0] will not be correct if - * trying to read descriptors using e.g. libusb xusb.exe. + * Also WinUSB driver has limitation that index[0] will not be correct + * if trying to read descriptors using e.g. libusb xusb.exe. */ uint8_t interface = ctrl->value[0]; @@ -533,8 +534,9 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver, { case USB_REQ_GETDESCRIPTOR: { - /* The value field specifies the descriptor type in the MS byte and the - * descriptor index in the LS byte (order is little endian) + /* The value field specifies the descriptor type in the MS byte + * and the descriptor index in the LS byte + * (order is little endian) */ switch (ctrl->value[1]) @@ -590,8 +592,8 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver, static const uint8_t msft_response[16] = { - 'M', 0, 'S', 0, 'F', 0, 'T', 0, '1', 0, '0', 0, '0', 0, - 0xff, 0 + 'M', 0, 'S', 0, 'F', 0, 'T', 0, '1', 0, '0', 0, + '0', 0, 0xff, 0 }; buf->len = 18; @@ -606,12 +608,16 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver, for (i = 0; i < priv->ndevices; i++) { - if (strid > priv->device[i].compdesc.devinfo.strbase && - strid <= priv->device[i].compdesc.devinfo.strbase + - priv->device[i].compdesc.devinfo.nstrings) + if (strid > + priv->device[i].compdesc.devinfo.strbase && + strid <= + priv->device[i].compdesc.devinfo.strbase + + priv->device[i].compdesc.devinfo.nstrings) { - ret = priv->device[i].compdesc.mkstrdesc(strid - - priv->device[i].compdesc.devinfo.strbase, buf); + ret = priv->device[i].compdesc.mkstrdesc( + strid - + priv->device[i].compdesc.devinfo.strbase, + buf); break; } } @@ -621,8 +627,9 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver, default: { - usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_GETUNKNOWNDESC), - value); + usbtrace( + TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_GETUNKNOWNDESC), + value); } break; } @@ -635,7 +642,9 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver, { int i; - /* Save the configuration and inform the constituent classes */ + /* Save the configuration and inform the constituent + * classes + */ for (i = 0; i < priv->ndevices; i++) { @@ -705,8 +714,8 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver, * Non-Standard Class Requests **********************************************************************/ - /* Class implementations should handle their own interface and endpoint - * requests. + /* Class implementations should handle their own interface and + * endpoint requests. */ ret = composite_classsetup(priv, dev, ctrl, dataout, outlen); @@ -730,7 +739,8 @@ static int composite_setup(FAR struct usbdevclass_driver_s *driver, ret = EP_SUBMIT(dev->ep0, ctrlreq); if (ret < 0) { - usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_EPRESPQ), (uint16_t)-ret); + usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_EPRESPQ), + (uint16_t)-ret); ctrlreq->result = OK; composite_ep0incomplete(dev->ep0, ctrlreq); } @@ -963,8 +973,8 @@ FAR void *composite_initialize(uint8_t ndevices, ret = priv->device[i].compdesc.classobject(priv->device[i].compdesc.minor, - &priv->device[i].compdesc.devinfo, - &priv->device[i].dev); + &priv->device[i].compdesc.devinfo, + &priv->device[i].dev); if (ret < 0) { usbtrace(TRACE_CLSERROR(USBCOMPOSITE_TRACEERR_CLASSOBJECT), @@ -1015,7 +1025,8 @@ errout_with_alloc: * class objects for each of the members of the composite. * * Input Parameters: - * handle - The handle returned by a previous call to composite_initialize(). + * handle - The handle returned by a previous call to + * composite_initialize(). * * Returned Value: * None @@ -1024,7 +1035,8 @@ errout_with_alloc: void composite_uninitialize(FAR void *handle) { - FAR struct composite_alloc_s *alloc = (FAR struct composite_alloc_s *)handle; + FAR struct composite_alloc_s *alloc = + (FAR struct composite_alloc_s *)handle; FAR struct composite_dev_s *priv; int i; diff --git a/drivers/usbdev/composite.h b/drivers/usbdev/composite.h index f39044345db..bfee6715659 100644 --- a/drivers/usbdev/composite.h +++ b/drivers/usbdev/composite.h @@ -41,6 +41,7 @@ ****************************************************************************/ /* Configuration ************************************************************/ + /* Packet sizes */ #ifndef CONFIG_COMPOSITE_EP0MAXPACKET @@ -96,6 +97,7 @@ #define NUM_DEVICES_TO_HANDLE (4) /* Descriptors **************************************************************/ + /* These settings are not modifiable via the NuttX configuration */ #define COMPOSITE_CONFIGIDNONE (0) /* Config ID = 0 means to return to address mode */ diff --git a/drivers/usbdev/composite_desc.c b/drivers/usbdev/composite_desc.c index 61b9941e49e..fc2c6366408 100644 --- a/drivers/usbdev/composite_desc.c +++ b/drivers/usbdev/composite_desc.c @@ -192,10 +192,12 @@ FAR const struct usb_devdesc_s *composite_getdevdesc(void) ****************************************************************************/ #ifdef CONFIG_USBDEV_DUALSPEED -int16_t composite_mkcfgdesc(FAR struct composite_dev_s *priv, FAR uint8_t *buf, +int16_t composite_mkcfgdesc(FAR struct composite_dev_s *priv, + FAR uint8_t *buf, uint8_t speed, uint8_t type) #else -int16_t composite_mkcfgdesc(FAR struct composite_dev_s *priv, FAR uint8_t *buf) +int16_t composite_mkcfgdesc(FAR struct composite_dev_s *priv, + FAR uint8_t *buf) #endif { FAR struct usb_cfgdesc_s *cfgdesc = (FAR struct usb_cfgdesc_s *)buf; @@ -223,7 +225,9 @@ int16_t composite_mkcfgdesc(FAR struct composite_dev_s *priv, FAR uint8_t *buf) COMPOSITE_REMOTEWAKEUP; cfgdesc->mxpower = (CONFIG_USBDEV_MAXPOWER + 1) / 2; /* Max power (mA/2) */ - /* increment the size and buf to point right behind the information filled in */ + /* increment the size and buf to point right behind the information + * filled in + */ total = USB_SIZEOF_CFGDESC; buf += USB_SIZEOF_CFGDESC; @@ -234,13 +238,13 @@ int16_t composite_mkcfgdesc(FAR struct composite_dev_s *priv, FAR uint8_t *buf) { #ifdef CONFIG_USBDEV_DUALSPEED len = priv->device[i].compdesc.mkconfdesc(buf, - &priv->device[i].compdesc.devinfo, - speed, type); + &priv->device[i].compdesc.devinfo, + speed, type); total += len; buf += len; #else len = priv->device[i].compdesc.mkconfdesc(buf, - &priv->device[i].compdesc.devinfo); + &priv->device[i].compdesc.devinfo); total += len; buf += len; #endif diff --git a/drivers/usbdev/pl2303.c b/drivers/usbdev/pl2303.c index 2278e03efae..f95a29c91ae 100644 --- a/drivers/usbdev/pl2303.c +++ b/drivers/usbdev/pl2303.c @@ -1,4 +1,4 @@ -/****************************************************************************************** +/**************************************************************************** * drivers/usbdev/pl2303.c * * Licensed to the Apache Software Foundation (ASF) under one or more @@ -18,11 +18,11 @@ * * This logic emulates the Prolific PL2303 serial/USB converter * - ******************************************************************************************/ + ****************************************************************************/ -/****************************************************************************************** +/**************************************************************************** * Included Files - ******************************************************************************************/ + ****************************************************************************/ #include @@ -45,11 +45,11 @@ #include #include -/****************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - ******************************************************************************************/ + ****************************************************************************/ -/* Configuration **************************************************************************/ +/* Configuration ************************************************************/ /* Number of requests in the write queue */ @@ -140,7 +140,7 @@ # define CONFIG_USBDEV_MAXPOWER 100 #endif -/* Descriptors ****************************************************************************/ +/* Descriptors **************************************************************/ /* These settings are not modifiable via the NuttX configuration */ @@ -181,7 +181,7 @@ #define PL2303_MXDESCLEN (64) #define PL2303_MAXSTRLEN (PL2303_MXDESCLEN-2) -/* Vendor specific control requests *******************************************************/ +/* Vendor specific control requests *****************************************/ #define PL2303_CONTROL_TYPE (0x20) #define PL2303_SETLINEREQUEST (0x20) /* OUT, Recipient interface */ @@ -194,7 +194,7 @@ #define PL2303_RWREQUEST_TYPE (0x40) #define PL2303_RWREQUEST (0x01) /* IN/OUT, Recipient device */ -/* Misc Macros ****************************************************************************/ +/* Misc Macros **************************************************************/ /* min/max macros */ @@ -206,7 +206,7 @@ # define max(a,b) ((a)>(b)?(a):(b)) #endif -/* Trace values ***************************************************************************/ +/* Trace values *************************************************************/ #define PL2303_CLASSAPI_SETUP TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_SETUP) #define PL2303_CLASSAPI_SHUTDOWN TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_SHUTDOWN) @@ -221,9 +221,9 @@ #define PL2303_CLASSAPI_TXREADY TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_TXREADY) #define PL2303_CLASSAPI_TXEMPTY TRACE_EVENT(TRACE_CLASSAPI_ID, USBSER_TRACECLASSAPI_TXEMPTY) -/****************************************************************************************** +/**************************************************************************** * Private Types - ******************************************************************************************/ + ****************************************************************************/ /* Container to support a list of requests */ @@ -283,11 +283,11 @@ struct pl2303_alloc_s struct pl2303_driver_s drvr; }; -/****************************************************************************************** +/**************************************************************************** * Private Function Prototypes - ******************************************************************************************/ + ****************************************************************************/ -/* Transfer helpers ***********************************************************************/ +/* Transfer helpers *********************************************************/ static uint16_t usbclass_fillrequest(FAR struct pl2303_dev_s *priv, uint8_t *reqbuf, uint16_t reqlen); @@ -295,14 +295,14 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv); static inline int usbclass_recvpacket(FAR struct pl2303_dev_s *priv, uint8_t *reqbuf, uint16_t reqlen); -/* Request helpers ************************************************************************/ +/* Request helpers **********************************************************/ static struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep, uint16_t len); static void usbclass_freereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req); -/* Configuration **************************************************************************/ +/* Configuration ************************************************************/ static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc); #ifdef CONFIG_USBDEV_DUALSPEED @@ -316,7 +316,7 @@ static void usbclass_resetconfig(FAR struct pl2303_dev_s *priv); static int usbclass_setconfig(FAR struct pl2303_dev_s *priv, uint8_t config); -/* Completion event handlers **************************************************************/ +/* Completion event handlers ************************************************/ static void usbclass_ep0incomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req); @@ -325,7 +325,7 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep, static void usbclass_wrcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req); -/* USB class device ***********************************************************************/ +/* USB class device *********************************************************/ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver, FAR struct usbdev_s *dev); @@ -344,7 +344,7 @@ static void usbclass_resume(FAR struct usbdevclass_driver_s *driver, FAR struct usbdev_s *dev); #endif -/* Serial port ****************************************************************************/ +/* Serial port **************************************************************/ static int usbser_setup(FAR struct uart_dev_s *dev); static void usbser_shutdown(FAR struct uart_dev_s *dev); @@ -354,11 +354,11 @@ static void usbser_rxint(FAR struct uart_dev_s *dev, bool enable); static void usbser_txint(FAR struct uart_dev_s *dev, bool enable); static bool usbser_txempty(FAR struct uart_dev_s *dev); -/****************************************************************************************** +/**************************************************************************** * Private Data - ******************************************************************************************/ + ****************************************************************************/ -/* USB class device ***********************************************************************/ +/* USB class device *********************************************************/ static const struct usbdevclass_driverops_s g_driverops = { @@ -375,7 +375,7 @@ static const struct usbdevclass_driverops_s g_driverops = #endif }; -/* Serial port ****************************************************************************/ +/* Serial port **************************************************************/ static const struct uart_ops_s g_uartops = { @@ -396,7 +396,7 @@ static const struct uart_ops_s g_uartops = usbser_txempty /* txempty */ }; -/* USB descriptor templates these will be copied and modified *****************************/ +/* USB descriptor templates these will be copied and modified ***************/ static const struct usb_devdesc_s g_devdesc = { @@ -492,27 +492,30 @@ static const struct usb_qualdesc_s g_qualdesc = }; #endif -/****************************************************************************************** +/**************************************************************************** * Private Functions - ******************************************************************************************/ + ****************************************************************************/ -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_fillrequest * * Description: - * If there is data to send it is copied to the given buffer. Called either - * to initiate the first write operation, or from the completion interrupt handler - * service consecutive write operations. + * If there is data to send it is copied to the given buffer. Called either + * to initiate the first write operation, or from the completion interrupt + * handler service consecutive write operations. * - * NOTE: The USB serial driver does not use the serial drivers uart_xmitchars() - * API. That logic is essentially duplicated here because unlike UART hardware, - * we need to be able to handle writes not byte-by-byte, but packet-by-packet. - * Unfortunately, that decision also exposes some internals of the serial driver - * in the following. + * NOTE: + * The USB serial driver does not use the serial drivers uart_xmitchars() + * API. That logic is essentially duplicated here because unlike UART + * hardware, we need to be able to handle writes not byte-by-byte, but + * packet-by-packet. + * Unfortunately, that decision also exposes some internals of the serial + * driver in the following. * - ******************************************************************************************/ + ****************************************************************************/ -static uint16_t usbclass_fillrequest(FAR struct pl2303_dev_s *priv, uint8_t *reqbuf, +static uint16_t usbclass_fillrequest(FAR struct pl2303_dev_s *priv, + uint8_t *reqbuf, uint16_t reqlen) { FAR uart_dev_t *serdev = &priv->serdev; @@ -524,7 +527,9 @@ static uint16_t usbclass_fillrequest(FAR struct pl2303_dev_s *priv, uint8_t *req flags = enter_critical_section(); - /* Transfer bytes while we have bytes available and there is room in the request */ + /* Transfer bytes while we have bytes available and there is room in the + * request + */ while (xmit->head != xmit->tail && nbytes < reqlen) { @@ -561,16 +566,16 @@ static uint16_t usbclass_fillrequest(FAR struct pl2303_dev_s *priv, uint8_t *req return nbytes; } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_sndpacket * * Description: - * This function obtains write requests, transfers the TX data into the request, - * and submits the requests to the USB controller. This continues until either - * (1) there are no further packets available, or (2) there is not further data - * to send. + * This function obtains write requests, transfers the TX data into the + * request, and submits the requests to the USB controller. This continues + * until either (1) there are no further packets available, or (2) there is + * not further data to send. * - ******************************************************************************************/ + ****************************************************************************/ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv) { @@ -596,9 +601,9 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv) ep = priv->epbulkin; - /* Loop until either (1) we run out or write requests, or (2) usbclass_fillrequest() - * is unable to fill the request with data (i.e., until there is no more data - * to be sent). + /* Loop until either (1) we run out or write requests, or (2) + * usbclass_fillrequest() is unable to fill the request with data + * (i.e., until there is no more data to be sent). */ uinfo("head=%d tail=%d nwrq=%d empty=%d\n", @@ -634,7 +639,8 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv) ret = EP_SUBMIT(ep, req); if (ret != OK) { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_SUBMITFAIL), (uint16_t)-ret); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_SUBMITFAIL), + (uint16_t) - ret); break; } } @@ -648,18 +654,18 @@ static int usbclass_sndpacket(FAR struct pl2303_dev_s *priv) return ret; } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_recvpacket * * Description: - * A normal completion event was received by the read completion handler at the - * interrupt level (with interrupts disabled). This function handles the USB packet - * and provides the received data to the uart RX buffer. + * A normal completion event was received by the read completion handler at + * the interrupt level (with interrupts disabled). This function handles + * the USB packet and provides the received data to the uart RX buffer. * * Assumptions: * Called from the USB interrupt handler with interrupts disabled. * - ******************************************************************************************/ + ****************************************************************************/ static inline int usbclass_recvpacket(FAR struct pl2303_dev_s *priv, uint8_t *reqbuf, uint16_t reqlen) @@ -670,11 +676,12 @@ static inline int usbclass_recvpacket(FAR struct pl2303_dev_s *priv, uint16_t nexthead; uint16_t nbytes = 0; - /* Get the next head index. During the time that RX interrupts are disabled, the - * the serial driver will be extracting data from the circular buffer and modifying - * recv.tail. During this time, we should avoid modifying recv.head; Instead we will - * use a shadow copy of the index. When interrupts are restored, the real recv.head - * will be updated with this index. + /* Get the next head index. During the time that RX interrupts are + * disabled, the the serial driver will be extracting data from the + * circular buffer and modifying recv.tail. During this time, we should + * avoid modifying recv.head; Instead we will use a shadow copy of the + * index. When interrupts are restored, the real recv.head will be updated + * with this index. */ if (priv->rxenabled) @@ -686,9 +693,9 @@ static inline int usbclass_recvpacket(FAR struct pl2303_dev_s *priv, currhead = priv->rxhead; } - /* Pre-calculate the head index and check for wrap around. We need to do this - * so that we can determine if the circular buffer will overrun BEFORE we - * overrun the buffer! + /* Pre-calculate the head index and check for wrap around. We need to do + * this so that we can determine if the circular buffer will overrun BEFORE + * we overrun the buffer! */ nexthead = currhead + 1; @@ -697,9 +704,10 @@ static inline int usbclass_recvpacket(FAR struct pl2303_dev_s *priv, nexthead = 0; } - /* Then copy data into the RX buffer until either: (1) all of the data has been - * copied, or (2) the RX buffer is full. NOTE: If the RX buffer becomes full, - * then we have overrun the serial driver and data will be lost. + /* Then copy data into the RX buffer until either: (1) all of the data has + * been copied, or (2) the RX buffer is full. + * NOTE: If the RX buffer becomes full, then we have overrun the serial + * driver and data will be lost. */ while (nexthead != recv->tail && nbytes < reqlen) @@ -757,13 +765,13 @@ static inline int usbclass_recvpacket(FAR struct pl2303_dev_s *priv, return OK; } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_allocreq * * Description: * Allocate a request instance along with its buffer * - ******************************************************************************************/ + ****************************************************************************/ static struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep, uint16_t len) @@ -785,13 +793,13 @@ static struct usbdev_req_s *usbclass_allocreq(FAR struct usbdev_ep_s *ep, return req; } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_freereq * * Description: * Free a request instance along with its buffer * - ******************************************************************************************/ + ****************************************************************************/ static void usbclass_freereq(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req) @@ -807,13 +815,13 @@ static void usbclass_freereq(FAR struct usbdev_ep_s *ep, } } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_mkstrdesc * * Description: * Construct a string descriptor * - ******************************************************************************************/ + ****************************************************************************/ static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc) { @@ -876,18 +884,19 @@ static int usbclass_mkstrdesc(uint8_t id, struct usb_strdesc_s *strdesc) return strdesc->len; } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_mkepbulkdesc * * Description: * Construct the endpoint descriptor * - ******************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_USBDEV_DUALSPEED -static inline void usbclass_mkepbulkdesc(const FAR struct usb_epdesc_s *indesc, - uint16_t mxpacket, - FAR struct usb_epdesc_s *outdesc) +static inline void usbclass_mkepbulkdesc( + const FAR struct usb_epdesc_s *indesc, + uint16_t mxpacket, + FAR struct usb_epdesc_s *outdesc) { /* Copy the canned descriptor */ @@ -900,13 +909,13 @@ static inline void usbclass_mkepbulkdesc(const FAR struct usb_epdesc_s *indesc, } #endif -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_mkcfgdesc * * Description: * Construct the configuration descriptor * - ******************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_USBDEV_DUALSPEED static int16_t usbclass_mkcfgdesc(uint8_t *buf, uint8_t speed, uint8_t type) @@ -964,9 +973,11 @@ static int16_t usbclass_mkcfgdesc(uint8_t *buf) bulkmxpacket = 64; } - usbclass_mkepbulkdesc(&g_epbulkoutdesc, bulkmxpacket, (FAR struct usb_epdesc_s *)buf); + usbclass_mkepbulkdesc(&g_epbulkoutdesc, bulkmxpacket, + (FAR struct usb_epdesc_s *)buf); buf += USB_SIZEOF_EPDESC; - usbclass_mkepbulkdesc(&g_epbulkindesc, bulkmxpacket, (FAR struct usb_epdesc_s *)buf); + usbclass_mkepbulkdesc(&g_epbulkindesc, bulkmxpacket, + (FAR struct usb_epdesc_s *)buf); #else memcpy(buf, &g_epbulkoutdesc, USB_SIZEOF_EPDESC); buf += USB_SIZEOF_EPDESC; @@ -980,13 +991,13 @@ static int16_t usbclass_mkcfgdesc(uint8_t *buf) return totallen; } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_resetconfig * * Description: * Mark the device as not configured and disable all endpoints. * - ******************************************************************************************/ + ****************************************************************************/ static void usbclass_resetconfig(FAR struct pl2303_dev_s *priv) { @@ -1016,14 +1027,14 @@ static void usbclass_resetconfig(FAR struct pl2303_dev_s *priv) } } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_setconfig * * Description: * Set the device configuration by allocating and configuring endpoints and * by allocating and queue read and write requests. * - ******************************************************************************************/ + ****************************************************************************/ static int usbclass_setconfig(FAR struct pl2303_dev_s *priv, uint8_t config) { @@ -1157,31 +1168,32 @@ errout: return ret; } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_ep0incomplete * * Description: * Handle completion of EP0 control operations * - ******************************************************************************************/ + ****************************************************************************/ static void usbclass_ep0incomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req) { if (req->result || req->xfrd != req->len) { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_REQRESULT), (uint16_t)-req->result); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_REQRESULT), + (uint16_t)-req->result); } } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_rdcomplete * * Description: * Handle completion of read request on the bulk OUT endpoint. This * is handled like the receipt of serial data on the "UART" * - ******************************************************************************************/ + ****************************************************************************/ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req) @@ -1221,7 +1233,8 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep, return; default: /* Some other error occurred */ - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDUNEXPECTED), (uint16_t)-req->result); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDUNEXPECTED), + (uint16_t)-req->result); break; }; @@ -1231,20 +1244,21 @@ static void usbclass_rdcomplete(FAR struct usbdev_ep_s *ep, ret = EP_SUBMIT(ep, req); if (ret != OK) { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), (uint16_t)-req->result); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_RDSUBMIT), + (uint16_t)-req->result); } leave_critical_section(flags); } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_wrcomplete * * Description: * Handle completion of write request. This function probably executes * in the context of an interrupt handler. * - ******************************************************************************************/ + ****************************************************************************/ static void usbclass_wrcomplete(FAR struct usbdev_ep_s *ep, FAR struct usbdev_req_s *req) @@ -1291,27 +1305,29 @@ static void usbclass_wrcomplete(FAR struct usbdev_ep_s *ep, break; default: /* Some other error occurred */ - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRUNEXPECTED), (uint16_t)-req->result); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_WRUNEXPECTED), + (uint16_t)-req->result); break; } } -/****************************************************************************************** +/**************************************************************************** * USB Class Driver Methods - ******************************************************************************************/ + ****************************************************************************/ -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_bind * * Description: * Invoked when the driver is bound to a USB device driver * - ******************************************************************************************/ + ****************************************************************************/ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver, FAR struct usbdev_s *dev) { - FAR struct pl2303_dev_s *priv = ((FAR struct pl2303_driver_s *)driver)->dev; + FAR struct pl2303_dev_s *priv = + ((FAR struct pl2303_driver_s *)driver)->dev; FAR struct pl2303_req_s *reqcontainer; irqstate_t flags; uint16_t reqlen; @@ -1353,7 +1369,8 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver, /* Pre-allocate the IN interrupt endpoint */ - priv->epintin = DEV_ALLOCEP(dev, PL2303_EPINTIN_ADDR, true, USB_EP_ATTR_XFER_INT); + priv->epintin = DEV_ALLOCEP(dev, PL2303_EPINTIN_ADDR, + true, USB_EP_ATTR_XFER_INT); if (!priv->epintin) { usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPINTINALLOCFAIL), 0); @@ -1365,7 +1382,8 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver, /* Pre-allocate the IN bulk endpoint */ - priv->epbulkin = DEV_ALLOCEP(dev, PL2303_EPINBULK_ADDR, true, USB_EP_ATTR_XFER_BULK); + priv->epbulkin = DEV_ALLOCEP(dev, PL2303_EPINBULK_ADDR, + true, USB_EP_ATTR_XFER_BULK); if (!priv->epbulkin) { usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKINALLOCFAIL), 0); @@ -1377,7 +1395,8 @@ static int usbclass_bind(FAR struct usbdevclass_driver_s *driver, /* Pre-allocate the OUT bulk endpoint */ - priv->epbulkout = DEV_ALLOCEP(dev, PL2303_EPOUTBULK_ADDR, false, USB_EP_ATTR_XFER_BULK); + priv->epbulkout = DEV_ALLOCEP(dev, PL2303_EPOUTBULK_ADDR, + false, USB_EP_ATTR_XFER_BULK); if (!priv->epbulkout) { usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_EPBULKOUTALLOCFAIL), 0); @@ -1465,13 +1484,13 @@ errout: return ret; } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_unbind * * Description: * Invoked when the driver is unbound from a USB device driver * - ******************************************************************************************/ + ****************************************************************************/ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver, FAR struct usbdev_s *dev) @@ -1590,14 +1609,14 @@ static void usbclass_unbind(FAR struct usbdevclass_driver_s *driver, priv->serdev.xmit.tail = 0; } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_setup * * Description: * Invoked for ep0 control requests. This function probably executes * in the context of an interrupt handler. * - ******************************************************************************************/ + ****************************************************************************/ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver, FAR struct usbdev_s *dev, @@ -1653,8 +1672,9 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver, { case USB_REQ_GETDESCRIPTOR: { - /* The value field specifies the descriptor type in the MS byte and the - * descriptor index in the LS byte (order is little endian) + /* The value field specifies the descriptor type in the MS byte + * and the descriptor index in the LS byte + * (order is little endian) */ switch (ctrl->value[1]) @@ -1680,7 +1700,8 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver, case USB_DESC_TYPE_CONFIG: { #ifdef CONFIG_USBDEV_DUALSPEED - ret = usbclass_mkcfgdesc(ctrlreq->buf, dev->speed, ctrl->req); + ret = usbclass_mkcfgdesc(ctrlreq->buf, + dev->speed, ctrl->req); #else ret = usbclass_mkcfgdesc(ctrlreq->buf); #endif @@ -1698,7 +1719,8 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver, default: { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_GETUNKNOWNDESC), value); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_GETUNKNOWNDESC), + value); } break; } @@ -1759,7 +1781,8 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver, break; default: - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDSTDREQ), ctrl->req); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDSTDREQ), + ctrl->req); break; } } @@ -1769,7 +1792,8 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver, case PL2303_CONTROL_TYPE: { - if ((ctrl->type & USB_REQ_RECIPIENT_MASK) == USB_REQ_RECIPIENT_INTERFACE) + if ((ctrl->type & USB_REQ_RECIPIENT_MASK) == + USB_REQ_RECIPIENT_INTERFACE) { switch (ctrl->req) { @@ -1795,7 +1819,8 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver, break; default: - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDCLASSREQ), ctrl->type); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDCLASSREQ), + ctrl->type); break; } } @@ -1804,7 +1829,8 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver, case PL2303_RWREQUEST_TYPE: { - if ((ctrl->type & USB_REQ_RECIPIENT_MASK) == USB_REQ_RECIPIENT_DEVICE) + if ((ctrl->type & USB_REQ_RECIPIENT_MASK) == + USB_REQ_RECIPIENT_DEVICE) { if (ctrl->req == PL2303_RWREQUEST) { @@ -1843,7 +1869,8 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver, } else { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDCLASSREQ), ctrl->type); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UNSUPPORTEDCLASSREQ), + ctrl->type); } } } @@ -1874,7 +1901,7 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver, return ret; } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_disconnect * * Description: @@ -1882,7 +1909,7 @@ static int usbclass_setup(FAR struct usbdevclass_driver_s *driver, * disconnected. This function is probably called from the context of an * interrupt handler. * - ******************************************************************************************/ + ****************************************************************************/ static void usbclass_disconnect(FAR struct usbdevclass_driver_s *driver, FAR struct usbdev_s *dev) @@ -1939,13 +1966,13 @@ static void usbclass_disconnect(FAR struct usbdevclass_driver_s *driver, DEV_CONNECT(dev); } -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_suspend * * Description: * Handle the USB suspend event. * - ******************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_SERIAL_REMOVABLE static void usbclass_suspend(FAR struct usbdevclass_driver_s *driver, @@ -1973,13 +2000,13 @@ static void usbclass_suspend(FAR struct usbdevclass_driver_s *driver, } #endif -/****************************************************************************************** +/**************************************************************************** * Name: usbclass_resume * * Description: * Handle the USB resume event. * - ******************************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_SERIAL_REMOVABLE static void usbclass_resume(FAR struct usbdevclass_driver_s *driver, @@ -2012,17 +2039,17 @@ static void usbclass_resume(FAR struct usbdevclass_driver_s *driver, } #endif -/****************************************************************************************** +/**************************************************************************** * Serial Device Methods - ******************************************************************************************/ + ****************************************************************************/ -/****************************************************************************************** +/**************************************************************************** * Name: usbser_setup * * Description: * This method is called the first time that the serial port is opened. * - ******************************************************************************************/ + ****************************************************************************/ static int usbser_setup(FAR struct uart_dev_s *dev) { @@ -2055,7 +2082,7 @@ static int usbser_setup(FAR struct uart_dev_s *dev) return OK; } -/****************************************************************************************** +/**************************************************************************** * Name: usbser_shutdown * * Description: @@ -2065,7 +2092,7 @@ static int usbser_setup(FAR struct uart_dev_s *dev) * usbser_txempty() until that function returns true before calling this * function. * - ******************************************************************************************/ + ****************************************************************************/ static void usbser_shutdown(FAR struct uart_dev_s *dev) { @@ -2081,13 +2108,13 @@ static void usbser_shutdown(FAR struct uart_dev_s *dev) #endif } -/****************************************************************************************** +/**************************************************************************** * Name: usbser_attach * * Description: * Does not apply to the USB serial class device * - ******************************************************************************************/ + ****************************************************************************/ static int usbser_attach(FAR struct uart_dev_s *dev) { @@ -2095,20 +2122,20 @@ static int usbser_attach(FAR struct uart_dev_s *dev) return OK; } -/****************************************************************************************** +/**************************************************************************** * Name: usbser_detach * * Description: * Does not apply to the USB serial class device * - ******************************************************************************************/ + ****************************************************************************/ static void usbser_detach(FAR struct uart_dev_s *dev) { usbtrace(PL2303_CLASSAPI_DETACH, 0); } -/****************************************************************************************** +/**************************************************************************** * Name: usbser_rxint * * Description: @@ -2123,7 +2150,7 @@ static void usbser_detach(FAR struct uart_dev_s *dev) * 3. With enable==false when the port is closed (just before usbser_detach * and usbser_shutdown are called). * - ******************************************************************************************/ + ****************************************************************************/ static void usbser_rxint(FAR struct uart_dev_s *dev, bool enable) { @@ -2205,7 +2232,7 @@ static void usbser_rxint(FAR struct uart_dev_s *dev, bool enable) leave_critical_section(flags); } -/****************************************************************************************** +/**************************************************************************** * Name: usbser_txint * * Description: @@ -2217,7 +2244,7 @@ static void usbser_rxint(FAR struct uart_dev_s *dev, bool enable) * 2. With enable==true when data may be taken from the buffer. * 3. With enable==false when the TX buffer is empty * - ******************************************************************************************/ + ****************************************************************************/ static void usbser_txint(FAR struct uart_dev_s *dev, bool enable) { @@ -2252,17 +2279,17 @@ static void usbser_txint(FAR struct uart_dev_s *dev, bool enable) } } -/****************************************************************************************** +/**************************************************************************** * Name: usbser_txempty * * Description: * Return true when all data has been sent. This is called from the * serial driver when the driver is closed. It will call this API - * periodically until it reports true. NOTE that the serial driver takes all - * responsibility for flushing TX data through the hardware so we can be - * a bit sloppy about that. + * periodically until it reports true. NOTE that the serial driver takes + * all responsibility for flushing TX data through the hardware so we can + * be a bit sloppy about that. * - ******************************************************************************************/ + ****************************************************************************/ static bool usbser_txempty(FAR struct uart_dev_s *dev) { @@ -2285,17 +2312,17 @@ static bool usbser_txempty(FAR struct uart_dev_s *dev) return priv->nwrq >= CONFIG_PL2303_NWRREQS; } -/****************************************************************************************** +/**************************************************************************** * Public Functions - ******************************************************************************************/ + ****************************************************************************/ -/****************************************************************************************** +/**************************************************************************** * Name: usbdev_serialinitialize * * Description: * Register USB serial port (and USB serial console if so configured). * - ******************************************************************************************/ + ****************************************************************************/ int usbdev_serialinitialize(int minor) { @@ -2307,7 +2334,8 @@ int usbdev_serialinitialize(int minor) /* Allocate the structures needed */ - alloc = (FAR struct pl2303_alloc_s *)kmm_malloc(sizeof(struct pl2303_alloc_s)); + alloc = (FAR struct pl2303_alloc_s *) + kmm_malloc(sizeof(struct pl2303_alloc_s)); if (!alloc) { usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_ALLOCDEVSTRUCT), 0); @@ -2372,7 +2400,8 @@ int usbdev_serialinitialize(int minor) ret = uart_register("/dev/console", &priv->serdev); if (ret < 0) { - usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_CONSOLEREGISTER), (uint16_t)-ret); + usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_CONSOLEREGISTER), + (uint16_t)-ret); goto errout_with_class; } #endif diff --git a/drivers/usbdev/usbdev_strings.c b/drivers/usbdev/usbdev_strings.c index 87f4ce12335..75005b771b2 100644 --- a/drivers/usbdev/usbdev_strings.c +++ b/drivers/usbdev/usbdev_strings.c @@ -266,4 +266,8 @@ const struct trace_msg_t g_usb_trace_strings_clserror[] = TRACE_STR_END }; +/**************************************************************************** + * Public Functions + ****************************************************************************/ + #endif /* CONFIG_USBDEV_TRACE_STRINGS */ diff --git a/drivers/usbdev/usbdev_trprintf.c b/drivers/usbdev/usbdev_trprintf.c index 24dc49ae321..23da4148ed7 100644 --- a/drivers/usbdev/usbdev_trprintf.c +++ b/drivers/usbdev/usbdev_trprintf.c @@ -54,7 +54,8 @@ * Name: get_trstring * * Description: - * Search the driver string data to find the string matching the provided ID. + * Search the driver string data to find the string matching the + * provided ID. * ****************************************************************************/ @@ -380,7 +381,8 @@ void usbtrace_trprintf(trprintf_t trprintf, uint16_t event, uint16_t value) #ifdef CONFIG_USBDEV_TRACE_STRINGS trprintf("%-18s %02x: %-40s %04x\n", "Class API call", TRACE_DATA(event), - get_trstring(g_usb_trace_strings_clsapi, TRACE_DATA(event)), + get_trstring(g_usb_trace_strings_clsapi, + TRACE_DATA(event)), value); #else trprintf("%-18s %02x: %04x\n", "Class API call", @@ -392,7 +394,8 @@ void usbtrace_trprintf(trprintf_t trprintf, uint16_t event, uint16_t value) #ifdef CONFIG_USBDEV_TRACE_STRINGS trprintf("%-18s %02x: %-40s %04x\n", "Class state", TRACE_DATA(event), - get_trstring(g_usb_trace_strings_clsstate, TRACE_DATA(event)), + get_trstring(g_usb_trace_strings_clsstate, + TRACE_DATA(event)), value); #else trprintf("%-18s %02x: %04x\n", "Class state", @@ -414,7 +417,8 @@ void usbtrace_trprintf(trprintf_t trprintf, uint16_t event, uint16_t value) #ifdef CONFIG_USBDEV_TRACE_STRINGS trprintf("%-18s%3d: %-40s %04x\n", "Interrupt decode", TRACE_DATA(event), - get_trstring(g_usb_trace_strings_intdecode, TRACE_DATA(event)), + get_trstring(g_usb_trace_strings_intdecode, + TRACE_DATA(event)), value); #else trprintf("%-18s%3d: %04x\n", "Interrupt decode", @@ -491,7 +495,8 @@ void usbtrace_trprintf(trprintf_t trprintf, uint16_t event, uint16_t value) #ifdef CONFIG_USBDEV_TRACE_STRINGS trprintf("%-18s %02x: %-40s %04x\n", "Controller error", TRACE_DATA(event), - get_trstring(g_usb_trace_strings_deverror, TRACE_DATA(event)), + get_trstring(g_usb_trace_strings_deverror, + TRACE_DATA(event)), value); #else trprintf("%-18s %02x: %04x\n", "Controller error", @@ -504,7 +509,8 @@ void usbtrace_trprintf(trprintf_t trprintf, uint16_t event, uint16_t value) #ifdef CONFIG_USBDEV_TRACE_STRINGS trprintf("%-18s %02x: %-40s %04x\n", "Class error", TRACE_DATA(event), - get_trstring(g_usb_trace_strings_clserror, TRACE_DATA(event)), + get_trstring(g_usb_trace_strings_clserror, + TRACE_DATA(event)), value); #else trprintf("%-18s %02x: %04x\n", "Class error", diff --git a/drivers/usbdev/usbmsc.h b/drivers/usbdev/usbmsc.h index 34bdd17db69..9af23fbb157 100644 --- a/drivers/usbdev/usbmsc.h +++ b/drivers/usbdev/usbmsc.h @@ -482,7 +482,9 @@ EXTERN const char g_compserialstr[]; #define g_mscserialstr g_compserialstr #endif -/* Used to hand-off the state structure when the SCSI worker thread is started */ +/* Used to hand-off the state structure when the SCSI worker thread is + * started + */ EXTERN FAR struct usbmsc_dev_s *g_usbmsc_handoff; diff --git a/drivers/usbdev/usbmsc_scsi.c b/drivers/usbdev/usbmsc_scsi.c index 680947490d6..68d08400d7f 100644 --- a/drivers/usbdev/usbmsc_scsi.c +++ b/drivers/usbdev/usbmsc_scsi.c @@ -518,7 +518,9 @@ static inline int usbmsc_cmdread6(FAR struct usbmsc_dev_s *priv) { lun = priv->lun; - /* Get the Logical Block Address (LBA) from cdb[] as the starting sector */ + /* Get the Logical Block Address (LBA) from cdb[] as the starting + * sector + */ priv->sector = (uint32_t)(read6->mslba & SCSICMD_READ6_MSLBAMASK) << 16 | @@ -582,7 +584,9 @@ static inline int usbmsc_cmdwrite6(FAR struct usbmsc_dev_s *priv) { lun = priv->lun; - /* Get the Logical Block Address (LBA) from cdb[] as the starting sector */ + /* Get the Logical Block Address (LBA) from cdb[] as the starting + * sector + */ priv->sector = (uint32_t)(write6->mslba & SCSICMD_WRITE6_MSLBAMASK) << 16 | @@ -853,7 +857,9 @@ static int inline usbmsc_cmdmodesense6(FAR struct usbmsc_dev_s *priv, modesense->pcpgcode, &mdlen); if (ret == OK) { - /* Store the mode data length and return the total message size */ + /* Store the mode data length and return the total message + * size + */ mph->mdlen = mdlen + SCSIRESP_MODEPARAMETERHDR6_SIZEOF - 1; @@ -1050,7 +1056,9 @@ static inline int usbmsc_cmdread10(FAR struct usbmsc_dev_s *priv) { lun = priv->lun; - /* Get the Logical Block Address (LBA) from cdb[] as the starting sector */ + /* Get the Logical Block Address (LBA) from cdb[] as the starting + * sector + */ priv->sector = usbmsc_getbe32(read10->lba); @@ -1116,7 +1124,9 @@ static inline int usbmsc_cmdwrite10(FAR struct usbmsc_dev_s *priv) { lun = priv->lun; - /* Get the Logical Block Address (LBA) from cdb[] as the starting sector */ + /* Get the Logical Block Address (LBA) from cdb[] as the starting + * sector + */ priv->sector = usbmsc_getbe32(write10->lba); @@ -1271,7 +1281,9 @@ static inline int usbmsc_cmdsynchronizecache10(FAR struct usbmsc_dev_s *priv) priv->u.alloclen = 0; - /* Verify that we have the LUN structure and the block driver has been bound */ + /* Verify that we have the LUN structure and the block driver has been + * bound + */ if (!priv->lun->inode) { @@ -1361,7 +1373,9 @@ static int inline usbmsc_cmdmodesense10(FAR struct usbmsc_dev_s *priv, modesense->pcpgcode, &mdlen); if (ret == OK) { - /* Store the mode data length and return the total message size */ + /* Store the mode data length and return the total message + * size + */ usbmsc_putbe16(mph->mdlen, mdlen - 2); priv->nreqbytes = mdlen + SCSIRESP_MODEPARAMETERHDR10_SIZEOF; @@ -1393,7 +1407,9 @@ static inline int usbmsc_cmdread12(FAR struct usbmsc_dev_s *priv) { lun = priv->lun; - /* Get the Logical Block Address (LBA) from cdb[] as the starting sector */ + /* Get the Logical Block Address (LBA) from cdb[] as the starting + * sector + */ priv->sector = usbmsc_getbe32(read12->lba); @@ -1459,7 +1475,9 @@ static inline int usbmsc_cmdwrite12(FAR struct usbmsc_dev_s *priv) { lun = priv->lun; - /* Get the Logical Block Address (LBA) from cdb[] as the starting sector */ + /* Get the Logical Block Address (LBA) from cdb[] as the starting + * sector + */ priv->sector = usbmsc_getbe32(write12->lba); @@ -1574,7 +1592,9 @@ static int inline usbmsc_setupcmd(FAR struct usbmsc_dev_s *priv, } else if (lun) { - /* Block transfer: Calculate the total size of all sectors to be transferred */ + /* Block transfer: Calculate the total size of all sectors to be + * transferred + */ datlen = priv->u.alloclen * lun->sectorsize; } @@ -2267,7 +2287,9 @@ static int usbmsc_cmdreadstate(FAR struct usbmsc_dev_s *priv) nbytes = MIN(priv->epbulkin->maxpacket - priv->nreqbytes, priv->nsectbytes); - /* Copy the data from the sector buffer to the USB request and update counts */ + /* Copy the data from the sector buffer to the USB request and update + * counts + */ memcpy(dest, src, nbytes); priv->nreqbytes += nbytes; @@ -2401,14 +2423,18 @@ static int usbmsc_cmdwritestate(FAR struct usbmsc_dev_s *priv) while (priv->nreqbytes > 0 && priv->u.xfrlen > 0) { - /* Copy the data received in the read request into the sector I/O buffer */ + /* Copy the data received in the read request into the sector I/O + * buffer + */ src = &req->buf[xfrd - priv->nreqbytes]; dest = &priv->iobuffer[priv->nsectbytes]; nbytes = MIN(lun->sectorsize - priv->nsectbytes, priv->nreqbytes); - /* Copy the data from the sector buffer to the USB request and update counts */ + /* Copy the data from the sector buffer to the USB request and + * update counts + */ memcpy(dest, src, nbytes); priv->nsectbytes += nbytes; @@ -2869,7 +2895,9 @@ int usbmsc_scsi_main(int argc, char *argv[]) usbmsc_setconfig(priv, priv->thvalue); } - /* These events required that we send a deferred EP0 setup response */ + /* These events required that we send a deferred EP0 setup + * response + */ if ((eventset & (USBMSC_EVENT_RESET | USBMSC_EVENT_CFGCHANGE | USBMSC_EVENT_IFCHANGE)) != 0) @@ -2877,7 +2905,9 @@ int usbmsc_scsi_main(int argc, char *argv[]) usbmsc_deferredresponse(priv, false); } - /* For all of these events... terminate any transactions in progress */ + /* For all of these events... terminate any transactions in + * progress + */ priv->thstate = USBMSC_STATE_IDLE; } diff --git a/drivers/usbhost/usbhost_findclass.c b/drivers/usbhost/usbhost_findclass.c index 95aa2ceb546..16e9e9c9389 100644 --- a/drivers/usbhost/usbhost_findclass.c +++ b/drivers/usbhost/usbhost_findclass.c @@ -120,7 +120,8 @@ static bool usbhost_idmatch(const struct usbhost_id_s *classid, * ****************************************************************************/ -const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id) +const struct usbhost_registry_s *usbhost_findclass( + const struct usbhost_id_s *id) { struct usbhost_registry_s *usbclass; irqstate_t flags; @@ -146,8 +147,8 @@ const struct usbhost_registry_s *usbhost_findclass(const struct usbhost_id_s *id * protocol, then try each. */ - uinfo("Checking class:%p nids:%d\n", usbclass, usbclass->nids); - for (ndx = 0; ndx < usbclass->nids; ndx++) + uinfo("Checking class:%p nids:%d\n", usbclass, usbclass->nids); + for (ndx = 0; ndx < usbclass->nids; ndx++) { /* Did we find a matching ID? */ diff --git a/drivers/usbhost/usbhost_hub.c b/drivers/usbhost/usbhost_hub.c index c5ed3e3fec9..9c22367632a 100644 --- a/drivers/usbhost/usbhost_hub.c +++ b/drivers/usbhost/usbhost_hub.c @@ -1,4 +1,4 @@ -/************************************************************************************ +/**************************************************************************** * drivers/usbhost/usbhost_hub.c * * Copyright (C) 2015-2017 Gregory Nutt. All rights reserved. @@ -32,11 +32,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Included Files - ************************************************************************************/ + ****************************************************************************/ #include @@ -62,11 +62,11 @@ #ifdef CONFIG_USBHOST_HUB -/************************************************************************************ +/**************************************************************************** * Pre-processor Definitions - ************************************************************************************/ + ****************************************************************************/ -/* Configuration ********************************************************************/ +/* Configuration ************************************************************/ /* It is necessary to perform work on the low-priority work queue (vs. the * high priority work queue) because: @@ -110,9 +110,9 @@ #define INTIN_BUFSIZE ((USBHUB_MAX_PORTS + 8) >> 3) -/************************************************************************************ +/**************************************************************************** * Private Types - ************************************************************************************/ + ****************************************************************************/ /* This structure contains the internal, private state of the USB host * hub class. @@ -151,9 +151,9 @@ struct usbhost_hubclass_s struct usbhost_hubpriv_s hubpriv; /* Private class data */ }; -/************************************************************************************ +/**************************************************************************** * Private Function Prototypes - ************************************************************************************/ + ****************************************************************************/ /* Helpers for usbhost_connect() */ @@ -184,9 +184,9 @@ static int usbhost_connect(FAR struct usbhost_class_s *hubclass, FAR const uint8_t *configdesc, int desclen); static int usbhost_disconnected(FAR struct usbhost_class_s *hubclass); -/************************************************************************************ +/**************************************************************************** * Private Data - ************************************************************************************/ + ****************************************************************************/ /* This structure provides the registry entry ID information that will be * used to associate the USB host hub class to a connected USB hub. @@ -220,11 +220,11 @@ static struct usbhost_registry_s g_hub = g_id /* id[] */ }; -/************************************************************************************ +/**************************************************************************** * Private Functions - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Name: usbhost_hport_deactivate * * Description: @@ -236,7 +236,7 @@ static struct usbhost_registry_s g_hub = * Returned Value: * None * - ************************************************************************************/ + ****************************************************************************/ static void usbhost_hport_deactivate(FAR struct usbhost_hubport_s *hport) { @@ -265,7 +265,7 @@ static void usbhost_hport_deactivate(FAR struct usbhost_hubport_s *hport) DEBUGASSERT(ROOTHUB(hport) || hport->devclass == NULL); } -/************************************************************************************ +/**************************************************************************** * Name: usbhost_hport_activate * * Description: @@ -279,7 +279,7 @@ static void usbhost_hport_deactivate(FAR struct usbhost_hubport_s *hport) * Zero (OK) is returned on success; a negated errno value is returned * on any failure. * - ************************************************************************************/ + ****************************************************************************/ static int usbhost_hport_activate(FAR struct usbhost_hubport_s *hport) { @@ -304,7 +304,7 @@ static int usbhost_hport_activate(FAR struct usbhost_hubport_s *hport) return ret; } -/************************************************************************************ +/**************************************************************************** * Name: usbhost_cfgdesc * * Description: @@ -326,7 +326,7 @@ static int usbhost_hport_activate(FAR struct usbhost_hubport_s *hport) * Assumptions: * This function will *not* be called from an interrupt handler. * - ************************************************************************************/ + ****************************************************************************/ static inline int usbhost_cfgdesc(FAR struct usbhost_class_s *hubclass, FAR const uint8_t *configdesc, int desclen) @@ -439,12 +439,16 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_class_s *hubclass, /* Save the interrupt IN endpoint information */ - intindesc.addr = epdesc->addr & USB_EP_ADDR_NUMBER_MASK; + intindesc.addr = epdesc->addr & + USB_EP_ADDR_NUMBER_MASK; intindesc.interval = epdesc->interval; - intindesc.mxpacketsize = usbhost_getle16(epdesc->mxpacketsize); + intindesc.mxpacketsize = usbhost_getle16( + epdesc->mxpacketsize); - uinfo("Interrupt IN EP: addr=%d interval=%d mxpacketsize=%d\n", - intindesc.addr, intindesc.interval, intindesc.mxpacketsize); + uinfo("Interrupt IN EP:"); + uinfo(" addr=%d interval=%d mxpacketsize=%d\n", + intindesc.addr, intindesc.interval, + intindesc.mxpacketsize); } } } @@ -495,7 +499,7 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_class_s *hubclass, return OK; } -/************************************************************************************ +/**************************************************************************** * Name: usbhost_hubdesc * * Description: @@ -514,7 +518,7 @@ static inline int usbhost_cfgdesc(FAR struct usbhost_class_s *hubclass, * Assumptions: * This function will *not* be called from an interrupt handler. * - ************************************************************************************/ + ****************************************************************************/ static inline int usbhost_hubdesc(FAR struct usbhost_class_s *hubclass) { @@ -544,7 +548,8 @@ static inline int usbhost_hubdesc(FAR struct usbhost_class_s *hubclass) usbhost_putle16(ctrlreq->index, 0); usbhost_putle16(ctrlreq->len, USB_SIZEOF_HUBDESC); - ret = DRVR_CTRLIN(hport->drvr, hport->ep0, ctrlreq, (FAR uint8_t *)&hubdesc); + ret = DRVR_CTRLIN(hport->drvr, hport->ep0, + ctrlreq, (FAR uint8_t *)&hubdesc); if (ret < 0) { uerr("ERROR: Failed to read hub descriptor: %d\n", ret); @@ -554,9 +559,11 @@ static inline int usbhost_hubdesc(FAR struct usbhost_class_s *hubclass) priv->nports = hubdesc.nports; hubchar = usbhost_getle16(hubdesc.characteristics); - priv->lpsm = (hubchar & USBHUB_CHAR_LPSM_MASK) >> USBHUB_CHAR_LPSM_SHIFT; + priv->lpsm = (hubchar & USBHUB_CHAR_LPSM_MASK) >> + USBHUB_CHAR_LPSM_SHIFT; priv->compounddev = (hubchar & USBHUB_CHAR_COMPOUND) ? true : false; - priv->ocmode = (hubchar & USBHUB_CHAR_OCPM_MASK) >> USBHUB_CHAR_OCPM_SHIFT; + priv->ocmode = (hubchar & USBHUB_CHAR_OCPM_MASK) >> + USBHUB_CHAR_OCPM_SHIFT; priv->indicator = (hubchar & USBHUB_CHAR_PORTIND) ? true : false; priv->pwrondelay = (2 * hubdesc.pwrondelay); @@ -566,7 +573,8 @@ static inline int usbhost_hubdesc(FAR struct usbhost_class_s *hubclass) uinfo(" bDescLength: %d\n", hubdesc.len); uinfo(" bDescriptorType: 0x%02x\n", hubdesc.type); uinfo(" bNbrPorts: %d\n", hubdesc.nports); - uinfo(" wHubCharacteristics: 0x%04x\n", usbhost_getle16(hubdesc.characteristics)); + uinfo(" wHubCharacteristics: 0x%04x\n", + usbhost_getle16(hubdesc.characteristics)); uinfo(" lpsm: %d\n", priv->lpsm); uinfo(" compounddev: %s\n", priv->compounddev ? "TRUE" : "FALSE"); uinfo(" ocmode: %d\n", priv->ocmode); @@ -580,7 +588,7 @@ static inline int usbhost_hubdesc(FAR struct usbhost_class_s *hubclass) return OK; } -/************************************************************************************ +/**************************************************************************** * Name: usbhost_hubpwr * * Description: @@ -591,7 +599,8 @@ static inline int usbhost_hubdesc(FAR struct usbhost_class_s *hubclass) * have an arbitrary number of gangs of one or more ports. * * A hub indicates whether or not it supports power switching by the - * setting of the Logical Power Switching Mode field in wHubCharacteristics. + * setting of the Logical Power Switching Mode field in + * wHubCharacteristics. * If a hub supports per-port power switching, then the power to a port is * turned on when a SetPortFeature(PORT_POWER) request is received for the * port. Port power is turned off when the port is in the Powered-off or @@ -610,13 +619,13 @@ static inline int usbhost_hubdesc(FAR struct usbhost_class_s *hubclass) * on - True: enable power; false: Disable power * * Returned Value: - * On success, zero (OK) is returned. On a failure, a negated errno value is - * returned indicating the nature of the failure + * On success, zero (OK) is returned. On a failure, a negated errno value + * is returned indicating the nature of the failure * * Assumptions: * This function will *not* be called from an interrupt handler. * - ************************************************************************************/ + ****************************************************************************/ static int usbhost_hubpwr(FAR struct usbhost_hubpriv_s *priv, FAR struct usbhost_hubport_s *hport, @@ -663,7 +672,7 @@ static int usbhost_hubpwr(FAR struct usbhost_hubpriv_s *priv, return OK; } -/************************************************************************************ +/**************************************************************************** * Name: usbhost_hub_event * * Description: @@ -679,7 +688,7 @@ static int usbhost_hubpwr(FAR struct usbhost_hubpriv_s *priv, * Assumptions: * This function will *not* be called from an interrupt handler. * - ************************************************************************************/ + ****************************************************************************/ static void usbhost_hub_event(FAR void *arg) { @@ -774,7 +783,8 @@ static void usbhost_hub_event(FAR void *arg) ret = DRVR_CTRLOUT(hport->drvr, hport->ep0, ctrlreq, NULL); if (ret < 0) { - uerr("ERROR: Failed to clear port %d change mask %04x: %d\n", + uerr("ERROR:"); + uerr(" Failed to clear port %d change mask %04x: %d\n", port, mask, ret); } @@ -811,7 +821,8 @@ static void usbhost_hub_event(FAR void *arg) (FAR uint8_t *)&portstatus); if (ret < 0) { - uerr("ERROR: Failed to get port %d status: %d\n", port, ret); + uerr("ERROR: Failed to get port %d status: %d\n", + port, ret); break; } @@ -824,7 +835,8 @@ static void usbhost_hub_event(FAR void *arg) debouncestable += 25; if (debouncestable >= 100) { - uinfo("Port %d debouncestable=%d\n", port, debouncestable); + uinfo("Port %d debouncestable=%d\n", + port, debouncestable); break; } } @@ -838,7 +850,8 @@ static void usbhost_hub_event(FAR void *arg) { ctrlreq->type = USBHUB_REQ_TYPE_PORT; ctrlreq->req = USBHUB_REQ_CLEARFEATURE; - usbhost_putle16(ctrlreq->value, USBHUB_PORT_FEAT_CCONNECTION); + usbhost_putle16(ctrlreq->value, + USBHUB_PORT_FEAT_CCONNECTION); usbhost_putle16(ctrlreq->index, port); usbhost_putle16(ctrlreq->len, 0); @@ -886,7 +899,8 @@ static void usbhost_hub_event(FAR void *arg) (FAR uint8_t *)&portstatus); if (ret < 0) { - uerr("ERROR: Failed to get port %d status: %d\n", port, ret); + uerr("ERROR: Failed to get port %d status: %d\n", + port, ret); continue; } @@ -903,7 +917,8 @@ static void usbhost_hub_event(FAR void *arg) { ctrlreq->type = USBHUB_REQ_TYPE_PORT; ctrlreq->req = USBHUB_REQ_CLEARFEATURE; - usbhost_putle16(ctrlreq->value, USBHUB_PORT_FEAT_CRESET); + usbhost_putle16(ctrlreq->value, + USBHUB_PORT_FEAT_CRESET); usbhost_putle16(ctrlreq->index, port); usbhost_putle16(ctrlreq->len, 0); @@ -924,16 +939,21 @@ static void usbhost_hub_event(FAR void *arg) connport->speed = USB_SPEED_FULL; } - /* Activate the hub port by assigning it a control endpoint. */ + /* Activate the hub port by assigning it a control + * endpoint. + */ ret = usbhost_hport_activate(connport); if (ret < 0) { - uerr("ERROR: usbhost_hport_activate failed: %d\n", ret); + uerr("ERROR: usbhost_hport_activate failed: %d\n", + ret); } else { - /* Inform waiters that a new device has been connected */ + /* Inform waiters that a new device has been + * connected + */ ret = DRVR_CONNECT(connport->drvr, connport, true); if (ret < 0) @@ -973,7 +993,8 @@ static void usbhost_hub_event(FAR void *arg) } else if (change) { - uwarn("WARNING: status %04x change %04x not handled\n", status, change); + uwarn("WARNING: status %04x change %04x not handled\n", + status, change); } } @@ -998,7 +1019,8 @@ static void usbhost_hub_event(FAR void *arg) { /* Wait for the next hub event */ - ret = DRVR_ASYNCH(hport->drvr, priv->intin, (FAR uint8_t *)priv->buffer, + ret = DRVR_ASYNCH(hport->drvr, priv->intin, + (FAR uint8_t *)priv->buffer, INTIN_BUFSIZE, usbhost_callback, hubclass); if (ret < 0) { @@ -1009,7 +1031,7 @@ static void usbhost_hub_event(FAR void *arg) leave_critical_section(flags); } -/************************************************************************************ +/**************************************************************************** * Name: usbhost_disconnect_event * * Description: @@ -1028,7 +1050,7 @@ static void usbhost_hub_event(FAR void *arg) * Assumptions: * Probably called from an interrupt handler. * - ************************************************************************************/ + ****************************************************************************/ static void usbhost_disconnect_event(FAR void *arg) { @@ -1114,7 +1136,7 @@ static void usbhost_disconnect_event(FAR void *arg) leave_critical_section(flags); } -/************************************************************************************ +/**************************************************************************** * Name: usbhost_getle16 * * Description: @@ -1126,14 +1148,14 @@ static void usbhost_disconnect_event(FAR void *arg) * Returned Value: * A uint16_t representing the whole 16-bit integer value * - ************************************************************************************/ + ****************************************************************************/ static inline uint16_t usbhost_getle16(const uint8_t *val) { return (uint16_t)val[1] << 8 | (uint16_t)val[0]; } -/************************************************************************************ +/**************************************************************************** * Name: usbhost_putle16 * * Description: @@ -1146,7 +1168,7 @@ static inline uint16_t usbhost_getle16(const uint8_t *val) * Returned Value: * None * - ************************************************************************************/ + ****************************************************************************/ static void usbhost_putle16(uint8_t *dest, uint16_t val) { @@ -1154,7 +1176,7 @@ static void usbhost_putle16(uint8_t *dest, uint16_t val) dest[1] = val >> 8; } -/************************************************************************************ +/**************************************************************************** * Name: usbhost_callback * * Description: @@ -1171,7 +1193,7 @@ static void usbhost_putle16(uint8_t *dest, uint16_t val) * Assumptions: * Probably called from an interrupt handler. * - ************************************************************************************/ + ****************************************************************************/ static void usbhost_callback(FAR void *arg, ssize_t nbytes) { @@ -1235,15 +1257,16 @@ static void usbhost_callback(FAR void *arg, ssize_t nbytes) } } -/************************************************************************************ +/**************************************************************************** * struct usbhost_registry_s methods - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Name: usbhost_create * * Description: - * This function implements the create() method of struct usbhost_registry_s. + * This function implements the create() method of struct + * usbhost_registry_s. * The create() method is a callback into the class implementation. It is * used to (1) create a new instance of the USB host class state and to (2) * bind a USB host driver "session" to the class instance. Use of this @@ -1262,7 +1285,7 @@ static void usbhost_callback(FAR void *arg, ssize_t nbytes) * will fail only if the hport input parameter is NULL or if there are * insufficient resources to create another USB host class instance. * - ************************************************************************************/ + ****************************************************************************/ static FAR struct usbhost_class_s * usbhost_create(FAR struct usbhost_hubport_s *hport, @@ -1343,11 +1366,11 @@ errout_with_hub: return NULL; } -/************************************************************************************ +/**************************************************************************** * struct usbhost_class_s methods - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Name: usbhost_connect * * Description: @@ -1364,11 +1387,11 @@ errout_with_hub: * desclen - The length in bytes of the configuration descriptor. * * Returned Value: - * On success, zero (OK) is returned. On a failure, a negated errno value is - * returned indicating the nature of the failure + * On success, zero (OK) is returned. On a failure, a negated errno value + * is returned indicating the nature of the failure * - * NOTE that the class instance remains valid upon return with a failure. It is - * the responsibility of the higher level enumeration logic to call + * NOTE that the class instance remains valid upon return with a failure. + * It is the responsibility of the higher level enumeration logic to call * CLASS_DISCONNECTED to free up the class driver resources. * * Assumptions: @@ -1376,7 +1399,7 @@ errout_with_hub: * - If this function returns an error, the USB host controller driver * must call to DISCONNECTED method to recover from the error * - ************************************************************************************/ + ****************************************************************************/ static int usbhost_connect(FAR struct usbhost_class_s *hubclass, FAR const uint8_t *configdesc, int desclen) @@ -1438,7 +1461,7 @@ static int usbhost_connect(FAR struct usbhost_class_s *hubclass, return ret; } -/************************************************************************************ +/**************************************************************************** * Name: usbhost_disconnected * * Description: @@ -1458,7 +1481,7 @@ static int usbhost_connect(FAR struct usbhost_class_s *hubclass, * Assumptions: * Probably called from an interrupt handler. * - ************************************************************************************/ + ****************************************************************************/ static int usbhost_disconnected(struct usbhost_class_s *hubclass) { @@ -1494,11 +1517,11 @@ static int usbhost_disconnected(struct usbhost_class_s *hubclass) return ret; } -/************************************************************************************ +/**************************************************************************** * Public Functions - ************************************************************************************/ + ****************************************************************************/ -/************************************************************************************ +/**************************************************************************** * Name: usbhost_hub_initialize * * Description: @@ -1513,7 +1536,7 @@ static int usbhost_disconnected(struct usbhost_class_s *hubclass) * On success this function will return zero (OK); A negated errno value * will be returned on failure. * - ************************************************************************************/ + ****************************************************************************/ int usbhost_hub_initialize(void) { diff --git a/drivers/usbhost/usbhost_registry.h b/drivers/usbhost/usbhost_registry.h index b55e6adcc0b..73f072499d7 100644 --- a/drivers/usbhost/usbhost_registry.h +++ b/drivers/usbhost/usbhost_registry.h @@ -60,9 +60,9 @@ extern "C" EXTERN struct usbhost_registry_s *g_classregistry; -/************************************************************************************ +/**************************************************************************** * Public Function Prototypes - ************************************************************************************/ + ****************************************************************************/ #undef EXTERN #if defined(__cplusplus) diff --git a/drivers/wireless/bluetooth/bt_null.c b/drivers/wireless/bluetooth/bt_null.c index 0c868bc4b78..818bc7a29d2 100644 --- a/drivers/wireless/bluetooth/bt_null.c +++ b/drivers/wireless/bluetooth/bt_null.c @@ -172,7 +172,8 @@ static void btnull_format_buffersize_rsp(FAR struct bt_buf_s *buf, bufsize.status = 0; bufsize.le_max_len = BLUETOOTH_MAX_FRAMELEN; bufsize.le_max_num = 1; - memcpy(&data[ndx], &bufsize, sizeof(struct bt_hci_rp_le_read_buffer_size_s)); + memcpy(&data[ndx], &bufsize, + sizeof(struct bt_hci_rp_le_read_buffer_size_s)); ndx += sizeof(struct bt_hci_rp_le_read_buffer_size_s); buf->frame->io_len = len; diff --git a/drivers/wireless/spirit/include/spirit_aes.h b/drivers/wireless/spirit/include/spirit_aes.h index d82d3f829e0..b98309a5d79 100644 --- a/drivers/wireless/spirit/include/spirit_aes.h +++ b/drivers/wireless/spirit/include/spirit_aes.h @@ -1,6 +1,5 @@ -/******************************************************************************* +/**************************************************************************** * include/nuttx/wireless/spirit/include/spirit_aes.h - * Configuration and management of SPIRIT AES Engine. * * Copyright(c) 2015 STMicroelectronics * Author: VMA division - AMS @@ -9,30 +8,34 @@ * Adapted for NuttX by: * Author: Gregory Nutt * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - ******************************************************************************/ + ****************************************************************************/ + +/* Configuration and management of SPIRIT AES Engine. */ #ifndef __DRIVERS_WIRELESS_SPIRIT_INCLUDE_SPIRIT_AES_H #define __DRIVERS_WIRELESS_SPIRIT_INCLUDE_SPIRIT_AES_H @@ -90,23 +93,23 @@ * spirit_aes_read_dataout(spirit, outbuffer, buflen); */ -/****************************************************************************** +/**************************************************************************** * Included Files - ******************************************************************************/ + ****************************************************************************/ #include "spirit_regs.h" #include "spirit_types.h" -/****************************************************************************** +/**************************************************************************** * Public Function Prototypes - ******************************************************************************/ + ****************************************************************************/ #ifdef __cplusplus extern "C" { #endif -/****************************************************************************** +/**************************************************************************** * Name: spirit_aes_enable * * Description: @@ -120,12 +123,12 @@ extern "C" * Returned Value: * Zero (OK) on success; a negated errno value on any failure. * - ******************************************************************************/ + ****************************************************************************/ int spirit_aes_enable(FAR struct spirit_library_s *spirit, enum spirit_functional_state_e newstate); -/****************************************************************************** +/**************************************************************************** * Name: spirit_aes_write_datain * * Description: @@ -145,12 +148,12 @@ int spirit_aes_enable(FAR struct spirit_library_s *spirit, * Returned Value: * Zero (OK) on success; a negated errno value on any failure. * - ******************************************************************************/ + ****************************************************************************/ int spirit_aes_write_datain(FAR struct spirit_library_s *spirit, FAR const uint8_t *buffer, uint8_t buflen); -/****************************************************************************** +/**************************************************************************** * Name: spirit_aes_read_dataout * * Description: @@ -168,12 +171,12 @@ int spirit_aes_write_datain(FAR struct spirit_library_s *spirit, * Returned Value: * Zero (OK) on success; a negated errno value on any failure. * - ******************************************************************************/ + ****************************************************************************/ int spirit_aes_read_dataout(FAR struct spirit_library_s *spirit, FAR uint8_t *buffer, uint8_t buflen); -/****************************************************************************** +/**************************************************************************** * Name: spirit_aes_write_key * * Description: @@ -189,12 +192,12 @@ int spirit_aes_read_dataout(FAR struct spirit_library_s *spirit, * Returned Value: * Zero (OK) on success; a negated errno value on any failure. * - ******************************************************************************/ + ****************************************************************************/ int spirit_aes_write_key(FAR struct spirit_library_s *spirit, FAR const uint8_t *key); -/****************************************************************************** +/**************************************************************************** * Name: spirit_aes_read_key * * Description: @@ -203,18 +206,21 @@ int spirit_aes_write_key(FAR struct spirit_library_s *spirit, * Input Parameters: * spirit - Reference to a Spirit library state structure instance * key pointer to the buffer of 4 words (16 bytes) containing the AES key. - * The first byte of the buffer shall be the most significant byte AES_KEY_0 of the AES key. - * The last byte of the buffer shall be the less significant byte AES_KEY_15 of the AES key. + * The first byte of the buffer shall be the most significant byte + * AES_KEY_0 of the AES key. + * The last byte of the buffer shall be the less significant byte + * AES_KEY_15 of the AES key. * This parameter is an uint8_t*. * * Returned Value: * Zero (OK) on success; a negated errno value on any failure. * - ******************************************************************************/ + ****************************************************************************/ -int spirit_aes_read_key(FAR struct spirit_library_s *spirit, FAR uint8_t *key); +int spirit_aes_read_key(FAR struct spirit_library_s *spirit, + FAR uint8_t *key); -/****************************************************************************** +/**************************************************************************** * Name: spirit_aes_enc2deckey * * Description: @@ -226,11 +232,11 @@ int spirit_aes_read_key(FAR struct spirit_library_s *spirit, FAR uint8_t *key); * Returned Value: * Zero (OK) on success; a negated errno value on any failure. * - ******************************************************************************/ + ****************************************************************************/ int spirit_aes_enc2deckey(FAR struct spirit_library_s *spirit); -/****************************************************************************** +/**************************************************************************** * Name: spirit_aes_encrypt * * Description: @@ -242,11 +248,11 @@ int spirit_aes_enc2deckey(FAR struct spirit_library_s *spirit); * Returned Value: * Zero (OK) on success; a negated errno value on any failure. * - ******************************************************************************/ + ****************************************************************************/ int spirit_aes_encrypt(FAR struct spirit_library_s *spirit); -/****************************************************************************** +/**************************************************************************** * Name: spirit_aes_decrypt * * Description: @@ -258,11 +264,11 @@ int spirit_aes_encrypt(FAR struct spirit_library_s *spirit); * Returned Value: * Zero (OK) on success; a negated errno value on any failure. * - ******************************************************************************/ + ****************************************************************************/ int spirit_aes_decrypt(FAR struct spirit_library_s *spirit); -/****************************************************************************** +/**************************************************************************** * Name: spirit_aes_derivekey_decrypt * * Description: @@ -274,7 +280,7 @@ int spirit_aes_decrypt(FAR struct spirit_library_s *spirit); * Returned Value: * Zero (OK) on success; a negated errno value on any failure. * - ******************************************************************************/ + ****************************************************************************/ int spirit_aes_derivekey_decrypt(FAR struct spirit_library_s *spirit); diff --git a/drivers/wireless/spirit/include/spirit_regs.h b/drivers/wireless/spirit/include/spirit_regs.h index 338c9edbfce..3838605e4e9 100644 --- a/drivers/wireless/spirit/include/spirit_regs.h +++ b/drivers/wireless/spirit/include/spirit_regs.h @@ -1,4 +1,4 @@ -/********************************************************************************************** +/**************************************************************************** * include/nuttx/wireless/spirit/include/spirit_regs.h * This file contains all the SPIRIT registers address and masks. * @@ -9,37 +9,39 @@ * Adapted for NuttX by: * Author: Gregory Nutt * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * 3. Neither the name of STMicroelectronics nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of STMicroelectronics nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - **********************************************************************************************/ + ****************************************************************************/ #ifndef __DRIVERS_WIRELESS_SPIRIT_INCLUDE_SPIRIT_REGS_H #define __DRIVERS_WIRELESS_SPIRIT_INCLUDE_SPIRIT_REGS_H -/********************************************************************************************** +/**************************************************************************** * Pre-processor Definitions - **********************************************************************************************/ + ****************************************************************************/ /* General_Configuration_Registers */ @@ -84,8 +86,7 @@ #define ANA_FUNC_CONF1_SET_BLD_LVL_MASK ((uint8_t)0x03) /* Mask of the SET_BLD_LV field of * ANA_FUNC_CONF1 register (R/W) */ #define BLD_LVL_2_7 ((uint8_t)0x00) /* Sets the Battery Level Detector threshold - * to - 2.7V */ + * to 2.7V */ #define BLD_LVL_2_5 ((uint8_t)0x01) /* Sets the Battery Level Detector threshold * to 2.5V */ #define BLD_LVL_2_3 ((uint8_t)0x02) /* Sets the Battery Level Detector threshold @@ -105,11 +106,11 @@ * 4 EXT_REF: 1 - Reference signal from XIN pin * 0 - Reference signal from XO circuit * 3 HIGH_POWER_MODE: 1 - SET_SMPS_LEVEL word will be set to the value to - * PM_TEST register in RX state, while in TX state it - * will be fixed to 111 (which programs the SMPS output - * at max value 1.8V) - * 0 - SET_SMPS_LEVEL word will hold the value written in the - * PM_TEST register both in RX and TX state + * PM_TEST register in RX state, while in TX state + * it will be fixed to 111 (which programs the SMPS + * output at max value 1.8V) + * 0 - SET_SMPS_LEVEL word will hold the value written + * in the PM_TEST register both in RX and TX state * 2 BROWN_OUT: 1 - Brown_Out Detection enabled * 0 - Brown_Out Detection disabled * 1 BATTERY_LEVEL: 1 - Battery level detector enabled @@ -179,6 +180,7 @@ * in CUT1.0) */ /* GPIO_Registers */ + /* GPIOx_CONF_Registers */ /* GPIOx registers @@ -224,8 +226,9 @@ * 1 | 0 | Digital Output Low Power * 1 | 1 | Digital Output High Power * - * Note: The Analog mode is used only for temperature sensor indication. This is available only - * on GPIO_0 by setting the TS bit in the ANA_FUNC_CONF_0_Register. + * Note: The Analog mode is used only for temperature sensor indication. + * This is available only on GPIO_0 by setting the TS bit in the + * ANA_FUNC_CONF_0_Register. */ #define GPIO3_CONF_BASE ((uint8_t)0x02) /* GPIO_3 register address */ @@ -251,15 +254,19 @@ * of it) */ #define CONF_GPIO_OUT_TX_State ((uint8_t)0x28) /* TX state indication: ‘1’ when * Spirit1 is transiting in the TX state */ + #define CONF_GPIO_OUT_TX_FIFO_ALMOST_EMPTY ((uint8_t)0x30) /* TX FIFO Almost Empty Flag */ + #define CONF_GPIO_OUT_TX_FIFO_AMOST_FULL ((uint8_t)0x38) /* TX FIFO Almost Full Flag */ #define CONF_GPIO_OUT_RX_Data ((uint8_t)0x40) /* RX data output */ #define CONF_GPIO_OUT_RX_Clock ((uint8_t)0x48) /* RX clock output (recovered from * received data) */ #define CONF_GPIO_OUT_RX_State ((uint8_t)0x50) /* RX state indication: ‘1’ when * Spirit1 is transiting in the RX state */ + #define CONF_GPIO_OUT_RX_FIFO_ALMOST_FULL ((uint8_t)0x58) /* RX FIFO Almost Full Flag */ #define CONF_GPIO_OUT_RX_FIFO_ALMOST_EMPTY ((uint8_t)0x60) /* RX FIFO Almost Empty Flag */ + #define CONF_GPIO_OUT_Antenna_Switch ((uint8_t)0x68) /* Antenna switch used for antenna * diversity */ #define CONF_GPIO_OUT_Valid_Preamble ((uint8_t)0x70) /* Valid Preamble Detected Flag */ @@ -286,14 +293,18 @@ * Read Write * Default value: 0x00 * 7 Reserved. - * 6:5 CLOCK_TAIL[1:0]: Specifies the number of extra cylces provided before entering in STANDBY state. + * 6:5 CLOCK_TAIL[1:0]: Specifies the number of extra cylces provided + * before entering in STANDBY state. + * * CLOCK_TAIL1 | CLOCK_TAIL0 | Number of Extra Cycles * ------------------------------------------------------------ * 0 | 0 | 0 * 0 | 1 | 64 * 1 | 0 | 256 * 1 | 1 | 512 - * 4:1 XO_RATIO[3:0]: Specifies the division ratio when XO oscillator is the clock source + * 4:1 XO_RATIO[3:0]: Specifies the division ratio when XO oscillator + * is the clock source + * * XO_RATIO[3:0] | Division Ratio * ----------------------------------- * 0 | 1 @@ -312,7 +323,8 @@ * 13 | 1/96 * 14 | 1/128 * 15 | 1/256 - * 0 RCO_RATIO: Specifies the division ratio when RC oscillator is the clock source + * 0 RCO_RATIO: Specifies the division ratio when RC oscillator is the + * clock source * 0 - Division Ratio equal to 0 * 1 - Division Ratio equal to 1/128 */ @@ -372,31 +384,32 @@ * Read Write * Default value: 0x0c * - * 7:5 WCP[2:0]: Set the charge pump current according to the VCO frequency in RX mode. + * 7:5 WCP[2:0]: Set the charge pump current according to the VCO + * frequency in RX mode. * - * VCO Frequency | WCP2 | WCP1 | WCP0 | Charge Pump Current (uA) - * ------------------------------------------------------------------------------------------------------------ - * 4644-4678 | 0 | 0 | 0 | 378.4 - * 4708-4772 | 0 | 0 | 1 | 368.9 - * 4772-4836 | 0 | 1 | 0 | 359.5 - * 4836-4902 | 0 | 1 | 1 | 350 - * 4902-4966 | 1 | 0 | 0 | 340.5 - * 4966-5030 | 1 | 0 | 1 | 331.1 - * 5030-5095 | 1 | 1 | 0 | 321.6 - * 5095-5161 | 1 | 1 | 1 | 312.2 - * 5161-5232 | 0 | 0 | 0 | 378.4 - * 5232-5303 | 0 | 0 | 1 | 368.9 - * 5303-5375 | 0 | 1 | 0 | 359.5 - * 5375-5448 | 0 | 1 | 1 | 350 - * 5448-5519 | 1 | 0 | 0 | 340.5 - * 5519-5592 | 1 | 0 | 1 | 331.1 - * 5592-5663 | 1 | 1 | 0 | 321.6 - * 5663-5736 | 1 | 1 | 1 | 312.2 + * VCO Frequency | WCP2 | WCP1 | WCP0 | Charge Pump Current (uA) + * ----------------------------------------------------------------- + * 4644-4678 | 0 | 0 | 0 | 378.4 + * 4708-4772 | 0 | 0 | 1 | 368.9 + * 4772-4836 | 0 | 1 | 0 | 359.5 + * 4836-4902 | 0 | 1 | 1 | 350 + * 4902-4966 | 1 | 0 | 0 | 340.5 + * 4966-5030 | 1 | 0 | 1 | 331.1 + * 5030-5095 | 1 | 1 | 0 | 321.6 + * 5095-5161 | 1 | 1 | 1 | 312.2 + * 5161-5232 | 0 | 0 | 0 | 378.4 + * 5232-5303 | 0 | 0 | 1 | 368.9 + * 5303-5375 | 0 | 1 | 0 | 359.5 + * 5375-5448 | 0 | 1 | 1 | 350 + * 5448-5519 | 1 | 0 | 0 | 340.5 + * 5519-5592 | 1 | 0 | 1 | 331.1 + * 5592-5663 | 1 | 1 | 0 | 321.6 + * 5663-5736 | 1 | 1 | 1 | 312.2 * * * 4:0 SYNT[25:21]: highest 5 bits of the PLL programmable divider - * The valid range depends on fXO and REFDIV settings; for - * fXO=26MHz + * The valid range depends on fXO and REFDIV settings; + * for fXO=26MHz * REFDIV = 0 - SYNT[25:21] = 11...13 * REFDIV = 1 - SYNT[25:21] = 22…27 */ @@ -448,16 +461,17 @@ * Read Write * Default value: 0x51 * 7:3 SYNT[4:0]: lowest bits of the PLL programmable divider. - * 2:0 BS[2:0]: Synthesizer band select. This parameter selects the out-of-loop divide - * factor of the synthesizer according to the formula fxo/(B/2)/D*SYNT/2^18 + * 2:0 BS[2:0]: Synthesizer band select. This parameter selects the + * out-of-loop divide factor of the synthesizer according + * to the formula fxo/(B/2)/D*SYNT/2^18 * - * BS2 | BS1 | BS0 | value of B - * --------------------------------------------------------------------------- - * 0 | 0 | 1 | 6 - * 0 | 1 | 0 | 8 - * 0 | 1 | 1 | 12 - * 1 | 0 | 0 | 16 - * 1 | 0 | 1 | 32 + * BS2 | BS1 | BS0 | value of B + * -------------------------------------------------------------------- + * 0 | 0 | 1 | 6 + * 0 | 1 | 0 | 8 + * 0 | 1 | 1 | 12 + * 1 | 0 | 0 | 16 + * 1 | 0 | 1 | 32 * */ @@ -484,8 +498,9 @@ * * Read Write * Default value: 0xfc - * 7:0 CH_SPACING[7:0]: Channel spacing. From ~793Hz to ~200KHz in 793Hz steps - * (in general, frequency step is fXO/215=26MHz/215~793Hz). + * 7:0 CH_SPACING[7:0]: Channel spacing. From ~793Hz to ~200KHz in 793Hz + * steps (in general, frequency step is + * fXO/215=26MHz/215~793Hz). */ #define CHSPACE_BASE ((uint8_t)0x0c) /* Channel spacing. From ~0.8KHz to @@ -497,9 +512,10 @@ * Read Write * Default value: 0xa3 * - * 7:0 IF_OFFSET_DIG[7:0]: Intermediate frequency setting for the digital shift-to-baseband - * circuits. According to the formula: - * fIF = fXO*(IF_OFFSET_ANA+64)/(12*2^10) = fCLK*(IF_OFFSET_DIG+64)/(12*2^10) Hz. + * 7:0 IF_OFFSET_DIG[7:0]: Intermediate frequency setting for the digital + * shift-to-baseband circuits. According to the formula: + * fIF = fXO*(IF_OFFSET_ANA+64)/(12*2^10) = fCLK*(IF_OFFSET_DIG+64)/ + * (12*2^10) Hz. */ #define IF_OFFSET_DIG_BASE ((uint8_t)0x0d) /* Intermediate frequency fIF= @@ -511,9 +527,10 @@ * Read Write * Default value: 0xa3 * - * 7:0 IF_OFFSET_ANA[7:0]: Intermediate frequency setting for the digital shift-to-baseband - * circuits. According to the formula: - * fIF = fXO*(IF_OFFSET_ANA+64)/(12*2^10) = fCLK*(IF_OFFSET_DIG+64)/(12*2^10) Hz. + * 7:0 IF_OFFSET_ANA[7:0]: Intermediate frequency setting for the digital + * shift-to-baseband circuits. According to the formula: + * fIF = fXO*(IF_OFFSET_ANA+64)/(12*2^10) = fCLK*(IF_OFFSET_DIG+64)/ + * (12*2^10) Hz. */ #define IF_OFFSET_ANA_BASE ((uint8_t)0x07) /* Intermediate frequency fIF= @@ -526,11 +543,13 @@ * Default value: 0xa3 * * 7:4 Reserved. - * 3:0 FC_OFFSET[11:8]: Carrier offset. This value is the higher part of a 12-bit 2’s complement integer - * representing an offset in 99Hz(2) units added/subtracted to the + * 3:0 FC_OFFSET[11:8]: Carrier offset. This value is the higher part of a + * 12-bit 2’s complement integer representing an + * offset in 99Hz(2) units added/subtracted to the * carrier frequency set by registers SYNT3…SYNT0. - * This register can be used to set a fixed correction value - * obtained e.g. from crystal measurements. + * This register can be used to set a fixed + * correction value obtained e.g. from crystal + * measurements. */ #define FC_OFFSET1_BASE ((uint8_t)0x0e) /* [3:0] -> [11:8] Carrier offset @@ -540,10 +559,11 @@ * * Default value: 0x00 * Read Write - * 7:0 FC_OFFSET[7:0]: Carrier offset. This value is the lower part of a 12-bit 2’s - * complement integer representing an offset in 99Hz(2) units - * added/subtracted to the carrier frequency set by registers - * SYNT3…SYNT0. This register can be used to set a fixed correction + * 7:0 FC_OFFSET[7:0]: Carrier offset. This value is the lower part of a + * 12-bit 2’s complement integer representing an + * offset in 99Hz(2) units added/subtracted to the + * carrier frequency set by registers SYNT3…SYNT0. + * This register can be used to set a fixed correction * value obtained e.g. from crystal measurements. */ @@ -560,7 +580,8 @@ /* PA_POWER_x[8:1] registers * - * Default values from 8 to 1: [0x03, 0x0e, 0x1a, 0x25, 0x35, 0x40, 0x4e, 0x00] + * Default values from 8 to 1: + * [0x03, 0x0e, 0x1a, 0x25, 0x35, 0x40, 0x4e, 0x00] * Read Write * * 7 Reserved. @@ -573,7 +594,7 @@ * ramping or ASK modulation */ #define PA_POWER6_BASE ((uint8_t)0x12) /* PA Power level for 6th slot of PA * ramping or ASK modulation */ -#define PA_POWER5_BASE ((uint8_t)0x13) /* PA Power level for 5th slot of PA +#define PA_POWER5_BASE ((uint8_t)0x13) /* PA Power level for 5th slot of PA * ramping or ASK modulation */ #define PA_POWER4_BASE ((uint8_t)0x14) /* PA Power level for 4th slot of PA * ramping or ASK modulation */ @@ -589,8 +610,8 @@ * Default value:0x07 * Read Write * - * 7:6 CWC[1:0]: Output stage additional load capacitors bank (to be used to - * optimize the PA for different sub-bands). + * 7:6 CWC[1:0]: Output stage additional load capacitors bank + * (to be used to optimize the PA for different sub-bands). * * CWC1 | CWC0 | Total capacity in pF * --------------------------------------------------------- @@ -604,14 +625,15 @@ * 0 - Disable the power ramping * 4:3 PA_RAMP_STEP_WIDTH[1:0]: Step width in bit period * - * PA_RAMP_STEP_WIDTH1 | PA_RAMP_STEP_WIDTH0 | PA ramping time step - * ------------------------------------------------------------------------------------------- - * 0 | 0 | 1/8 Bit period - * 0 | 1 | 2/8 Bit period - * 1 | 0 | 3/8 Bit period - * 1 | 1 | 4/8 Bit period + * PA_RAMP_STEP_WIDTH1 | PA_RAMP_STEP_WIDTH0 | PA ramping time step + * ------------------------------------------------------------------- + * 0 | 0 | 1/8 Bit period + * 0 | 1 | 2/8 Bit period + * 1 | 0 | 3/8 Bit period + * 1 | 1 | 4/8 Bit period * - * 2:0 PA_LEVEL_MAX_INDEX[2:0]: Fixes the MAX PA LEVEL in PA ramping or ASK modulation + * 2:0 PA_LEVEL_MAX_INDEX[2:0]: Fixes the MAX PA LEVEL in PA ramping or + * ASK modulation */ #define PA_POWER0_BASE ((uint8_t)0x18) /* PA ramping settings and additional @@ -625,15 +647,18 @@ #define PA_POWER0_CWC_2_4P ((uint8_t)0x80) /* 2.4pF additional PA load capacitor */ #define PA_POWER0_CWC_3_6P ((uint8_t)0xc0) /* 3.6pF additional PA load capacitor */ #define PA_POWER0_PA_RAMP_MASK ((uint8_t)0x20) /* The PA power ramping */ + #define PA_POWER0_PA_RAMP_STEP_WIDTH_MASK ((uint8_t)0x20) /* The step width */ #define PA_POWER0_PA_RAMP_STEP_WIDTH_TB_8 ((uint8_t)0x00) /* PA ramping time step = 1/8 Bit period */ #define PA_POWER0_PA_RAMP_STEP_WIDTH_TB_4 ((uint8_t)0x08) /* PA ramping time step = 2/8 Bit period */ #define PA_POWER0_PA_RAMP_STEP_WIDTH_3TB_8 ((uint8_t)0x10) /* PA ramping time step = 3/8 Bit period */ #define PA_POWER0_PA_RAMP_STEP_WIDTH_TB_2 ((uint8_t)0x18) /* PA ramping time step = 4/8 Bit period */ + #define PA_POWER0_PA_LEVEL_MAX_INDEX ((uint8_t)0x20) /* Final level for power ramping */ #define PA_POWER0_PA_LEVEL_MAX_INDEX_0 ((uint8_t)0x00) /* */ #define PA_POWER0_PA_LEVEL_MAX_INDEX_1 ((uint8_t)0x01) /* Fixes the MAX PA LEVEL in PA ramping or * ASK modulation */ + #define PA_POWER0_PA_LEVEL_MAX_INDEX_2 ((uint8_t)0x02) /* */ #define PA_POWER0_PA_LEVEL_MAX_INDEX_3 ((uint8_t)0x03) /* _________ */ #define PA_POWER0_PA_LEVEL_MAX_INDEX_4 ((uint8_t)0x04) /* PA_LVL2 _| <--| */ @@ -654,8 +679,8 @@ * * Read Write * Default value: 0x1a - * 7 CW: 1 - CW Mode enabled - enables the generation of a continuous wave - * carrier without any modulation + * 7 CW: 1 - CW Mode enabled - enables the generation of a + * continuous wave carrier without any modulation * 0 - CW Mode disabled * * 6 BT_SEL: Select BT value for GFSK @@ -701,13 +726,15 @@ * * Read Write * Default value: 0x45 - * 7:4 FDEV_E[3:0]: Exponent of the frequency deviation (allowed values from 0 to 9) + * 7:4 FDEV_E[3:0]: Exponent of the frequency deviation + * (allowed values from 0 to 9) * * 3 CLOCK_REC_ALGO_SEL: Select PLL or DLL mode for clock recovery * 1 - DLL mode * 0 - PLL mode * - * 2:0 FDEV_M[1:0]: Mantissa of the frequency deviation (allowed values from 0 to 7) + * 2:0 FDEV_M[1:0]: Mantissa of the frequency deviation + * (allowed values from 0 to 7) */ #define FDEV0_BASE ((uint8_t)0x1c) /* Sets the Mantissa and exponent of @@ -730,21 +757,23 @@ * * Read Write * Default value: 0x23 - * 7:4 CHFLT_M[3:0]: Mantissa of the channel filter BW (allowed values from 0 to 8) + * 7:4 CHFLT_M[3:0]: Mantissa of the channel filter BW + * (allowed values from 0 to 8) * - * 3:0 CHFLT_E[3:0]: Exponent of the channel filter BW (allowed values from 0 to 9) + * 3:0 CHFLT_E[3:0]: Exponent of the channel filter BW + * (allowed values from 0 to 9) * - * M\E | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | - * -----+-------+-------+-------+-------+------+------+------+-----+-----+-----+ - * 0 | 800.1 | 450.9 | 224.7 | 112.3 | 56.1 | 28.0 | 14.0 | 7.0 | 3.5 | 1.8 | - * 1 | 795.1 | 425.9 | 212.4 | 106.2 | 53.0 | 26.5 | 13.3 | 6.6 | 3.3 | 1.7 | - * 2 | 768.4 | 403.2 | 201.1 | 100.5 | 50.2 | 25.1 | 12.6 | 6.3 | 3.1 | 1.6 | - * 3 | 736.8 | 380.8 | 190.0 | 95.0 | 47.4 | 23.7 | 11.9 | 5.9 | 3.0 | 1.5 | - * 4 | 705.1 | 362.1 | 180.7 | 90.3 | 45.1 | 22.6 | 11.3 | 5.6 | 2.8 | 1.4 | - * 5 | 670.9 | 341.7 | 170.6 | 85.3 | 42.6 | 21.3 | 10.6 | 5.3 | 2.7 | 1.3 | - * 6 | 642.3 | 325.4 | 162.4 | 81.2 | 40.6 | 20.3 | 10.1 | 5.1 | 2.5 | 1.3 | - * 7 | 586.7 | 294.5 | 147.1 | 73.5 | 36.7 | 18.4 | 9.2 | 4.6 | 2.3 | 1.2 | - * 8 | 541.4 | 270.3 | 135.0 | 67.5 | 33.7 | 16.9 | 8.4 | 4.2 | 2.1 | 1.1 | + * M\E | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | + * -----+------+------+------+------+-----+-----+-----+----+----+----+ + * 0 | 800.1| 450.9| 224.7| 112.3| 56.1| 28.0| 14.0| 7.0| 3.5| 1.8| + * 1 | 795.1| 425.9| 212.4| 106.2| 53.0| 26.5| 13.3| 6.6| 3.3| 1.7| + * 2 | 768.4| 403.2| 201.1| 100.5| 50.2| 25.1| 12.6| 6.3| 3.1| 1.6| + * 3 | 736.8| 380.8| 190.0| 95.0 | 47.4| 23.7| 11.9| 5.9| 3.0| 1.5| + * 4 | 705.1| 362.1| 180.7| 90.3 | 45.1| 22.6| 11.3| 5.6| 2.8| 1.4| + * 5 | 670.9| 341.7| 170.6| 85.3 | 42.6| 21.3| 10.6| 5.3| 2.7| 1.3| + * 6 | 642.3| 325.4| 162.4| 81.2 | 40.6| 20.3| 10.1| 5.1| 2.5| 1.3| + * 7 | 586.7| 294.5| 147.1| 73.5 | 36.7| 18.4| 9.2| 4.6| 2.3| 1.2| + * 8 | 541.4| 270.3| 135.0| 67.5 | 33.7| 16.9| 8.4| 4.2| 2.1| 1.1| */ #define CHFLT_BASE ((uint8_t)0x1d) /* RX Channel Filter Bandwidth */ @@ -856,9 +885,10 @@ * 1 - AFC Loop closed on 2nd conversion stage. * 0 - AFC Loop closed on slicer * - * 4:0 AFC PD leakage[4:0]: Peak detector leakage. This parameter sets the decay speed of - * the min/max frequency peak detector (AFC2 register), the range allowed is 0..31 (0 - - * no leakage, 31 - high leakage). The recommended value for this parameter is 4. + * 4:0 AFC PD leakage[4:0]: Peak detector leakage. This parameter sets the + * decay speed of the min/max frequency peak detector (AFC2 register), + * the range allowed is 0..31 (0 - no leakage, 31 - high leakage). + * The recommended value for this parameter is 4. */ #define AFC2_BASE ((uint8_t)0x1e) /* Automatic frequency compensation @@ -879,12 +909,14 @@ * Read Write * Default value: 0x18 * - * 7:0 AFC_FAST_PERIOD: Length of the AFC fast period. this parameter sets the length of the - * fast period in number of samples (AFC1 register), the range allowed - * is 0..255. The recommended setting for this parameter is such that - * the fast period equals the preamble length. Since the algorithm - * operates typically on 2 samples per symbol, the programmed value - * should be twice the number of preamble symbols. + * 7:0 AFC_FAST_PERIOD: Length of the AFC fast period. this parameter sets + * the length of the fast period in number of samples + * (AFC1 register), the range allowed is 0..255. The + * recommended setting for this parameter is such + * that the fast period equals the preamble length. + * Since the algorithm operates typically on 2 + * samples per symbol, the programmed value should be + * twice the number of preamble symbols. */ #define AFC1_BASE ((uint8_t)0x1f) /* Length of the AFC fast period */ @@ -932,8 +964,8 @@ * 4 START_MAX_ATTENUATION: Start with max attenuation * 1 - Enable * 0 - Disable - * 3:0 MEAS_TIME[3:0]: Measure time during which the signal peak is detected (according to - * the formula 12/fxo*2^MEAS_TIME) + * 3:0 MEAS_TIME[3:0]: Measure time during which the signal peak is + * detected (according to the formula 12/fxo*2^MEAS_TIME) */ #define AGCCTRL2_BASE ((uint8_t)0x24) /* AGC freeze strategy, AGC attenuation @@ -971,7 +1003,8 @@ * 6 AGC_MODE: Set linear-Binary AGC mode * 1 - Enable * 0 - Disable - * 5:0 HOLD_TIME[5:0]: Hold time after gain adjustment according to formula 12/fxo*HOLD_TIME + * 5:0 HOLD_TIME[5:0]: Hold time after gain adjustment according to formula + * 12/fxo*HOLD_TIME */ #define AGCCTRL0_BASE ((uint8_t)0x26) /* Enables AGC, set AGC algo between @@ -991,9 +1024,10 @@ * * Default value: 0x00 * Read Write - * 7:0 CH_NUM[7:0]: Channel number. This value is multiplied by the channel spacing and - * added to the synthesizer base frequency to generate the actual RF - * carrier frequency. + * 7:0 CH_NUM[7:0]: Channel number. This value is multiplied by the + * channel spacing and added to the synthesizer base + * frequency to generate the actual RF carrier + * frequency. */ #define CHNUM_BASE ((uint8_t)0x6c) /* Channel number. This value is @@ -1036,19 +1070,19 @@ * * 7:6 PCKT_FRMT[1:0]: format of packet * - * PCKT_FRMT1 | PCKT_FRMT0 | Format - * ---------------------------------------------------------------------- - * 0 | 0 | BASIC - * 1 | 0 | MBUS - * 1 | 1 | STACK + * PCKT_FRMT1 | PCKT_FRMT0 | Format + * -------------------------------------------------------------------- + * 0 | 0 | BASIC + * 1 | 0 | MBUS + * 1 | 1 | STACK * * 5:4 RX_MODE[1:0]: length of address 0x30 field in bytes * - * RX_MODE1 | RX_MODE0 | Rx Mode - * -------------------------------------------------------------------- - * 0 | 0 | normal - * 0 | 1 | direct through FIFO - * 1 | 0 | direct through GPIO + * RX_MODE1 | RX_MODE0 | Rx Mode + * ------------------------------------------------------------------- + * 0 | 0 | normal + * 0 | 1 | direct through FIFO + * 1 | 0 | direct through GPIO * * 3:0 LEN_WID[3:0]: length of length field in bits */ @@ -1095,12 +1129,12 @@ * * 7:5 CRC_MODE[2:0]: CRC type (0, 8, 16, 24 bits) * - * CRC_MODE2 | CRC_MODE1 | CRC_MODE0 | CRC Mode (n. bits - poly) - * ------------------------------------------------------------------------------------------------- - * 0 | 0 | 1 | 8 - 0x07 - * 0 | 1 | 0 | 16 - 0x8005 - * 0 | 1 | 1 | 16 - 0x1021 - * 1 | 0 | 0 | 24 - 0x864CBF + * CRC_MODE2 | CRC_MODE1 | CRC_MODE0 | CRC Mode (n. bits - poly) + * ----------------------------------------------------------------- + * 0 | 0 | 1 | 8 - 0x07 + * 0 | 1 | 0 | 16 - 0x8005 + * 0 | 1 | 1 | 16 - 0x1021 + * 1 | 0 | 0 | 24 - 0x864CBF * * 4 WHIT_EN[0]: Enable Whitening * 1 - Enable @@ -1108,12 +1142,12 @@ * * 3:2 TX_SOURCE[1:0]: length of sync field in bytes * - * TX_SOURCE1 | TX_SOURCE0 | Tx Mode - * -------------------------------------------------------------------- - * 0 | 0 | normal - * 0 | 1 | direct through FIFO - * 1 | 0 | direct through GPIO - * 1 | 1 | pn9 + * TX_SOURCE1 | TX_SOURCE0 | Tx Mode + * ------------------------------------------------------------------- + * 0 | 0 | normal + * 0 | 1 | direct through FIFO + * 1 | 0 | direct through GPIO + * 1 | 1 | pn9 * * 1 NOT_USED * @@ -1217,24 +1251,29 @@ * 7:0 CONTROLx_MASK[7:0]: All 0s - no filtering */ -#define PCKT_FLT_GOALS_CONTROL0_MASK_BASE ((uint8_t)0x42) - /* Packet control field #3 mask, all 0s - * -> no filtering */ -#define PCKT_FLT_GOALS_CONTROL1_MASK_BASE ((uint8_t)0x43) - /* Packet control field #2 mask, all 0s - * -> no filtering */ -#define PCKT_FLT_GOALS_CONTROL2_MASK_BASE ((uint8_t)0x44) - /* Packet control field #1 mask, all 0s - * -> no filtering */ -#define PCKT_FLT_GOALS_CONTROL3_MASK_BASE ((uint8_t)0x45) - /* Packet control field #0 mask, all 0s - * -> no filtering */ +#define PCKT_FLT_GOALS_CONTROL0_MASK_BASE ((uint8_t)0x42) /* Packet control + * field #3 mask, + * all 0s -> + * no filtering */ +#define PCKT_FLT_GOALS_CONTROL1_MASK_BASE ((uint8_t)0x43) /* Packet control + * field #2 mask, + * all 0s -> + * no filtering */ +#define PCKT_FLT_GOALS_CONTROL2_MASK_BASE ((uint8_t)0x44) /* Packet control + * field #1 mask, + * all 0s -> + * no filtering */ +#define PCKT_FLT_GOALS_CONTROL3_MASK_BASE ((uint8_t)0x45) /* Packet control + * field #0 mask, + * all 0s -> + * no filtering */ /* PCKT_FLT_GOALS_CONTROLx_FIELD registers * * Default value: 0x00 * Read Write - * 7:0 CONTROLx_FIELD[7:0]: Control field (byte x) to be used as reference + * 7:0 CONTROLx_FIELD[7:0]: Control field (byte x) to be used as + * reference */ #define PCKT_FLT_GOALS_CONTROL0_FIELD_BASE ((uint8_t)0x46) /* Control field (byte #3) */ @@ -1246,7 +1285,8 @@ * * Default value: 0x00 * Read Write - * 7:0 RX_SOURCE_MASK[7:0]: For received packet only: all 0s - no filtering + * 7:0 RX_SOURCE_MASK[7:0]: For received packet only: + * all 0s - no filtering */ #define PCKT_FLT_GOALS_SOURCE_MASK_BASE ((uint8_t)0x4a) /* Source address mask, valid @@ -1256,7 +1296,8 @@ * * Default value: 0x00 * Read Write - * 7:0 RX_SOURCE_ADDR[7:0]: RX packet source / TX packet destination fields + * 7:0 RX_SOURCE_ADDR[7:0]: RX packet source / TX packet destination + * fields */ #define PCKT_FLT_GOALS_SOURCE_ADDR_BASE ((uint8_t)0x4b) /* Source address */ @@ -1288,7 +1329,8 @@ * Default value: 0x00 * Read Write * - * 7:0 TX_SOURCE_ADDR[7:0]: TX packet source / RX packet destination fields + * 7:0 TX_SOURCE_ADDR[7:0]: TX packet source / RX packet destination + * fields */ #define PCKT_FLT_GOALS_TX_ADDR_BASE ((uint8_t)0x4e) /* Address of the destination (also @@ -1300,19 +1342,25 @@ * Read Write * * 7 Reserved. - * 6 RX_TIMEOUT_AND_OR_SELECT[0]: 1 - ‘OR’ logical function applied to CS/SQI/PQI - * values (masked by 7:5 bits in PROTOCOL register) - * 5 CONTROL_FILTERING[0]: 1 - RX packet accepted if its control fields matches - * with masked CONTROLx_FIELD registers. - * 4 SOURCE_FILTERING[0]: 1 - RX packet accepted if its source field - * matches w/ masked RX_SOURCE_ADDR register. - * 3 DEST_VS_ SOURCE _ADDR[0]: 1 - RX packet accepted if its destination - * address matches with TX_SOURCE_ADDR reg. - * 2 DEST_VS_MULTICAST_ADDR[0]: 1 - RX packet accepted if its destination - * address matches with MULTICAST register - * 1 DEST_VS_BROADCAST_ADDR[0]: 1 - RX packet accepted if its destination - * address matches with BROADCAST register. - * 0 CRC_CHECK[0]: 1 - packet discarded if CRC not valid. + * 6 RX_TIMEOUT_AND_OR_SELECT[0]: 1 - ‘OR’ logical function applied to + * CS/SQI/PQI values (masked by 7:5 + * bits in PROTOCOL register) + * 5 CONTROL_FILTERING[0]: 1 - RX packet accepted if its control + * fields matches with masked + * CONTROLx_FIELD registers. + * 4 SOURCE_FILTERING[0]: 1 - RX packet accepted if its source + * field matches w/ masked + * RX_SOURCE_ADDR register. + * 3 DEST_VS_ SOURCE _ADDR[0]: 1 - RX packet accepted if its + * destination address matches with + * TX_SOURCE_ADDR reg. + * 2 DEST_VS_MULTICAST_ADDR[0]: 1 - RX packet accepted if its + * destination address matches with + * MULTICAST register + * 1 DEST_VS_BROADCAST_ADDR[0]: 1 - RX packet accepted if its + * destination address matches with + * BROADCAST register. + * 0 CRC_CHECK[0]: 1 - packet discarded if CRC not valid. */ #define PCKT_FLT_OPTIONS_BASE ((uint8_t)0x4f) /* Options relative to packet filtering */ @@ -1347,7 +1395,8 @@ * * Default value: 0x00 * Read Write - * 7:0 TX_CTRLx[7:0]: Control field value to be used in TX packet as byte n.x + * 7:0 TX_CTRLx[7:0]: Control field value to be used in TX packet as + * byte n.x */ #define TX_CTRL_FIELD3_BASE ((uint8_t)0x68) /* Control field value to be used in @@ -1399,7 +1448,8 @@ * Default value: 0x00 * Read * - * 7:0 RX_PCKT_LEN1[7:0]: Length (number of bytes) of the received packet: + * 7:0 RX_PCKT_LEN1[7:0]: Length (number of bytes) of the received + * packet: * RX_PCKT_LEN=RX_PCKT_LEN1 × 256 + RX_PCKT_LEN0 * This value is packet_length/256 */ @@ -1412,7 +1462,8 @@ * Default value: 0x00 * Read * - * 7:0 RX_PCKT_LEN0[7:0]: Length (number of bytes) of the received packet: + * 7:0 RX_PCKT_LEN0[7:0]: Length (number of bytes) of the received + * packet: * RX_PCKT_LEN=RX_PCKT_LEN1 × 256 + RX_PCKT_LEN0 * This value is packet_length%256 */ @@ -1424,8 +1475,8 @@ * Default value: 0x00 * Read * - * 7:0 CRC_FIELDx[7:0]: upper(x=2), middle(x=1) and lower(x=0) part of the crc field of - * the received packet + * 7:0 CRC_FIELDx[7:0]: upper(x=2), middle(x=1) and lower(x=0) part + * of the crc field of the received packet */ #define CRC_FIELD2_BASE ((uint8_t)0xcb) /* CRC2 field of the received packet */ @@ -1437,7 +1488,9 @@ * Default value: 0x00 * Read * - * 7:0 RX_CTRL_FIELDx[7:0]: upper(x=3), middle(x=2), middle(x=1) and lower(x=0) part of the control field of the received packet + * 7:0 RX_CTRL_FIELDx[7:0]: upper(x=3), middle(x=2), middle(x=1) and + * lower(x=0) part of the control field of + * the received packet */ #define RX_CTRL_FIELD0_BASE ((uint8_t)0xce) /* CRTL3 Control field of the received packet */ @@ -1450,7 +1503,8 @@ * Default value: 0x00 * Read * - * 7:0 RX_ADDR_FIELDx[7:0]: source(x=1) and destination(x=0) address field of the received packet + * 7:0 RX_ADDR_FIELDx[7:0]: source(x=1) and destination(x=0) address + * field of the received packet */ #define RX_ADDR_FIELD1_BASE ((uint8_t)0xd2) /* ADDR1 Address field of the received packet */ @@ -1462,14 +1516,16 @@ * * Default value: 0x06 * Read Write - * 7 CS_TIMEOUT_MASK: 1 - CS value contributes to timeout disabling - * 6 SQI_TIMEOUT_MASK: 1 - SQI value contributes to timeout disabling - * 5 PQI_TIMEOUT_MASK: 1 - PQI value contributes to timeout disabling - * 4:3 TX_SEQ_NUM_RELOAD[1:0]: TX sequence number to be used when counting reset is - * required using the related command. - * 2 RCO_CALIBRATION[0]: 1 - Enables the automatic RCO calibration - * 1 VCO_CALIBRATION[0]: 1 - Enables the automatic VCO calibration - * 0 LDCR_MODE[0]: 1 - LDCR mode enabled + * 7 CS_TIMEOUT_MASK: 1 - CS value contributes to timeout disabling + * 6 SQI_TIMEOUT_MASK: 1 - SQI value contributes to timeout disabling + * 5 PQI_TIMEOUT_MASK: 1 - PQI value contributes to timeout disabling + * + * 4:3 TX_SEQ_NUM_RELOAD[1:0]: TX sequence number to be used when counting + * reset is required using the related command. + * + * 2 RCO_CALIBRATION[0]: 1 - Enables the automatic RCO calibration + * 1 VCO_CALIBRATION[0]: 1 - Enables the automatic VCO calibration + * 0 LDCR_MODE[0]: 1 - LDCR mode enabled */ #define PROTOCOL2_BASE ((uint8_t)0x50) /* Protocol2 regisetr address */ @@ -1490,16 +1546,16 @@ * * Default value: 0x00 * Read Write - * 7 LDCR_RELOAD_ON_SYNC: 1 - LDCR timer will be reloaded with the value stored in - * the LDCR_RELOAD registers - * 6 PIGGYBACKING: 1 - PIGGYBACKING enabled + * 7 LDCR_RELOAD_ON_SYNC: 1 - LDCR timer will be reloaded with the + * value stored in the LDCR_RELOAD registers + * 6 PIGGYBACKING: 1 - PIGGYBACKING enabled * 5:4 Reserved. - * 3 SEED_RELOAD[0]: 1 - Reload the back-off random generator - * seed using the value written in the - * BU_COUNTER_SEED_MSByte / LSByte registers - * 2 CSMA_ON [0]: 1 - CSMA channel access mode enabled - * 1 CSMA_PERS_ON[0]: 1 - CSMA persistent (no back-off) enabled - * 0 AUTO_PCKT_FLT[0]: 1 - automatic packet filtering mode enabled + * 3 SEED_RELOAD[0]: 1 - Reload the back-off random generator + * seed using the value written in the + * BU_COUNTER_SEED_MSByte / LSByte registers + * 2 CSMA_ON [0]: 1 - CSMA channel access mode enabled + * 1 CSMA_PERS_ON[0]: 1 - CSMA persistent (no back-off) enabled + * 0 AUTO_PCKT_FLT[0]: 1 - automatic packet filtering mode enabled */ #define PROTOCOL1_BASE ((uint8_t)0x51) /* Protocol1 register address */ @@ -1522,11 +1578,13 @@ * * Default value: 0x08 * Read Write - * 7:4 NMAX_RETX[3:0]: Max number of re-TX. 0 - re-transmission is not performed - * 3 NACK_TX[0]: 1 - field NO_ACK=1 on transmitted packet - * 2 AUTO_ACK[0]: 1 - automatic ack after RX - * 1 PERS_RX[0]: 1 - persistent reception enabled - * 0 PERS_TX[0]: 1 - persistent transmission enabled + * 7:4 NMAX_RETX[3:0]: Max number of re-TX. + * 0 - re-transmission is not performed + * + * 3 NACK_TX[0]: 1 - field NO_ACK=1 on transmitted packet + * 2 AUTO_ACK[0]: 1 - automatic ack after RX + * 1 PERS_RX[0]: 1 - persistent reception enabled + * 0 PERS_TX[0]: 1 - persistent transmission enabled */ #define PROTOCOL0_BASE ((uint8_t)0x52) /* Persistent RX/TX, autoack, Max @@ -1543,12 +1601,14 @@ * * Default value: 0x00 * Read Write - * 7:0 RX_TIMEOUT_PRESCALER[7:0] : RX operation timeout: prescaler value + * 7:0 RX_TIMEOUT_PRESCALER[7:0] : RX operation timeout: + * prescaler value */ -#define TIMERS5_RX_TIMEOUT_PRESCALER_BASE ((uint8_t)0x53) - /* RX operation timeout: prescaler - * value */ +#define TIMERS5_RX_TIMEOUT_PRESCALER_BASE ((uint8_t)0x53) /* RX operation + * timeout: + * prescaler + * value */ /* TIMERS4 register * @@ -1563,7 +1623,8 @@ * * Default value: 0x00 * Read Write - * 7:0 LDCR_PRESCALER[7:0] : LDC Mode: Prescaler part of the wake-up value + * 7:0 LDCR_PRESCALER[7:0] : LDC Mode: + * Prescaler part of the wake-up value */ #define TIMERS3_LDC_PRESCALER_BASE ((uint8_t)0x55) /* LDC Mode: Prescaler of the wake-up @@ -1582,18 +1643,21 @@ * * Default value: 0x00 * Read Write - * 7:0 LDCR_RELOAD_PRESCALER[7:0] : LDC Mode: Prescaler part of the reload value + * 7:0 LDCR_RELOAD_PRESCALER[7:0] : LDC Mode: + * Prescaler part of the reload value */ -#define TIMERS1_LDC_RELOAD_PRESCALER_BASE ((uint8_t)0x57) - /* LDC Mode: Prescaler part of the - * reload value */ +#define TIMERS1_LDC_RELOAD_PRESCALER_BASE ((uint8_t)0x57) /* LDC Mode: + * Prescaler part + * of the reload + * value */ /* TIMERS0 register * * Default value: 0x00 * Read Write - * 7:0 LDCR_RELOAD_COUNTER[7:0] : LDC Mode: Counter part of the reload value + * 7:0 LDCR_RELOAD_COUNTER[7:0] : LDC Mode: + * Counter part of the reload value */ #define TIMERS0_LDC_RELOAD_COUNTER_BASE ((uint8_t)0x58) /* LDC Mode: Counter part of the @@ -1603,8 +1667,8 @@ * * Default value: 0xff * Read Write - * 7:0 BU_COUNTER_SEED_MSByte: Seed of the random number generator used to apply the BEB - & (Binary Exponential Backoff) algorithm (MSB) + * 7:0 BU_COUNTER_SEED_MSByte: Seed of the random number generator used + * to apply the BEB (Binary Exponential Backoff) algorithm (MSB) */ #define CSMA_CONFIG3_BASE ((uint8_t)0x64) /* CSMA/CA: Seed of the random number @@ -1617,21 +1681,23 @@ * Default value: 0x00 * Read Write * - * 7:0 BU_COUNTER_SEED_LSByte: Seed of the random number generator used to apply - * the BEB (Binary Exponential Backoff) algorithm (LSB) + * 7:0 BU_COUNTER_SEED_LSByte: Seed of the random number generator used + * to apply the BEB (Binary Exponential + * Backoff) algorithm (LSB) */ #define CSMA_CONFIG2_BASE ((uint8_t)0x65) /* CSMA/CA: Seed of the random * number generator used to apply * the BEB (Binary Exponential - * Backoff) algorithm (LSB)*/ + * Backoff) algorithm (LSB) */ /* CSMA_CONFIG1 registers * * Default value: 0x04 * Read Write * 7:2 BU_PRESCALER[5:0]: Used to program the back-off unit BU - * 1:0 CCA_PERIOD[1:0]: Used to program the Tcca time (64 / 128 /256 / 512 × Tbit. + * 1:0 CCA_PERIOD[1:0]: Used to program the Tcca time + * (64 / 128 /256 / 512 × Tbit. */ #define CSMA_CONFIG1_BASE ((uint8_t)0x66) /* CSMA/CA: Prescaler of the back-off @@ -1661,8 +1727,10 @@ * Read Write * Default value: 0x02 * - * 7:6 SQI_TH[1:0]: SQI threshold according to the formula: 8*SYNC_LEN - 2*SQI_TH - * 5:2 PQI_TH[3:0]: PQI threshold according to the formula: 4*PQI_THR + * 7:6 SQI_TH[1:0]: SQI threshold according to the formula: + * 8*SYNC_LEN - 2*SQI_TH + * 5:2 PQI_TH[3:0]: PQI threshold according to the formula: + * 4*PQI_THR * 1 SQI_EN[0]: SQI enable * 1 - Enable * 0 - Disable @@ -1730,14 +1798,15 @@ * 7:4 RSSI_FLT[3:0]: Gain of the RSSI filter * 3:2 CS_MODE[1:0]: AFC loop gain in slow mode (2's log) * - * CS_MODE1 | CS_MODE0 | CS Mode - * ----------------------------------------------------------------------------------------- - * 0 | 0 | Static CS - * 0 | 1 | Dynamic CS with 6dB dynamic threshold - * 1 | 0 | Dynamic CS with 12dB dynamic threshold - * 1 | 1 | Dynamic CS with 18dB dynamic threshold + * CS_MODE1 | CS_MODE0 | CS Mode + * -------------------------------------------------------------------- + * 0 | 0 | Static CS + * 0 | 1 | Dynamic CS with 6dB dynamic threshold + * 1 | 0 | Dynamic CS with 12dB dynamic threshold + * 1 | 1 | Dynamic CS with 18dB dynamic threshold * - * 1:0 OOK_PEAK_DECAY[1:0]: Peak decay control for OOK: 3 slow decay; 0 fast decay + * 1:0 OOK_PEAK_DECAY[1:0]: Peak decay control for OOK: + * 3 slow decay; 0 fast decay */ #define RSSI_FLT_BASE ((uint8_t)0x21) /* Gain of the RSSI filter; lower value @@ -1770,7 +1839,8 @@ * Read Write * Default value: 0x24 * - * 7:0 RSSI_THRESHOLD [7:0]: Signal detect threshold in 0.5dB. -120dBm corresponds to 20 + * 7:0 RSSI_THRESHOLD [7:0]: Signal detect threshold in 0.5dB. + * -120dBm corresponds to 20 */ #define RSSI_TH_BASE ((uint8_t)0x22) /* Signal detect threshold in 0.5dB @@ -1859,7 +1929,8 @@ * Read Write * * 7:4 RWT_IN[3:0]: RaWThermometric word value for the RCO [7:4] - * 3:0 RFB_IN[4:1]: ResistorFineBit word value for the RCO (first 4 bits) + * 3:0 RFB_IN[4:1]: ResistorFineBit word value for the RCO + * (first 4 bits) */ #define RCO_VCO_CALIBR_IN2_BASE ((uint8_t)0x6d) /* RaWThermometric word value for the @@ -1897,7 +1968,8 @@ * Read * * 7:4 RWT_OUT[3:0]: RWT word from internal RCO calibrator - * 3:0 RFB_OUT[4:1]: RFB word from internal RCO calibrator (upper part) + * 3:0 RFB_OUT[4:1]: RFB word from internal RCO calibrator + * (upper part) */ #define RCO_VCO_CALIBR_OUT1_BASE ((uint8_t)0xe4) /* RaWThermometric RWT word from @@ -1910,7 +1982,8 @@ * Default value: 0x00 * Read * - * 7 RFB_OUT[0]: RFB word from internal RCO calibrator (last bit LSB) + * 7 RFB_OUT[0]: RFB word from internal RCO calibrator + * (last bit LSB) * 6:0 VCO_CALIBR_DATA[6:0]: Output word from internal VCO calibrator */ @@ -2005,8 +2078,8 @@ * Default value: 0x00 * Read Write * - * 7:0 INT_MASK0: IRQ mask, if the correspondent bit is set and IRQ can be generated - * (according to the next table) + * 7:0 INT_MASK0: IRQ mask, if the correspondent bit is set and IRQ + * can be generated (according to the next table) * * Bit | Events Group Interrupt Event * ------------------------------------------------------- @@ -2036,8 +2109,8 @@ * Default value: 0x00 * Read Write * - * 7:0 INT_MASK1: IRQ mask, if the correspondent bit is set and IRQ can be generated - * (according to the next table) + * 7:0 INT_MASK1: IRQ mask, if the correspondent bit is set and IRQ + * can be generated (according to the next table) * * Bit | Events Group Interrupt Event * ------------------------------------------------------- @@ -2067,8 +2140,8 @@ * Default value: 0x00 * Read Write * - * 7:0 INT_MASK2: IRQ mask, if the correspondent bit is set and IRQ can be generated - * (according to the next table) + * 7:0 INT_MASK2: IRQ mask, if the correspondent bit is set and IRQ + * can be generated (according to the next table) * * Bit | Events Group Interrupt Event * ------------------------------------------------------- @@ -2104,8 +2177,8 @@ * Default value: 0x00 * Read Write * - * 7:0 INT_MASK3: IRQ mask, if the correspondent bit is set and IRQ can be generated - * (according to the next table) + * 7:0 INT_MASK3: IRQ mask, if the correspondent bit is set and IRQ + * can be generated (according to the next table) * * Bit | Events Group Interrupt Event * ------------------------------------------------------- @@ -2139,8 +2212,8 @@ * Default value: 0x00 * Read Write * - * 7:0 INT_STATUS0: IRQ status, if the correspondent bit is set and IRQ has been generated - * (according to the next table) + * 7:0 INT_STATUS0: IRQ status, if the correspondent bit is set and IRQ + * has been generated (according to the next table) * * Bit | Events Group Interrupt Event * ------------------------------------------------------- @@ -2172,8 +2245,8 @@ * Default value: 0x00 * Read Write * - * 7:0 INT_STATUS1: IRQ status, if the correspondent bit is set and IRQ has been generated - * (according to the next table) + * 7:0 INT_STATUS1: IRQ status, if the correspondent bit is set and IRQ + * has been generated (according to the next table) * * Bit | Events Group Interrupt Event * ------------------------------------------------------- @@ -2208,8 +2281,8 @@ * Default value: 0x00 * Read Write * - * 7:0 INT_STATUS2: IRQ status, if the correspondent bit is set and IRQ has been generated - * (according to the next table) + * 7:0 INT_STATUS2: IRQ status, if the correspondent bit is set and IRQ + * has been generated (according to the next table) * * Bit | Events Group Interrupt Event * ------------------------------------------------------- @@ -2240,8 +2313,8 @@ * Default value: 0x00 * Read Write * - * 7:0 INT_STATUS3: IRQ status, if the correspondent bit is set and IRQ has been generated - * (according to the next table) + * 7:0 INT_STATUS3: IRQ status, if the correspondent bit is set and IRQ + * has been generated (according to the next table) * * Bit | Events Group Interrupt Event * -------------------------------------------------------