drivers/leds/ncp5623c&pca9635pw: Fix nxstyle issues.

This commit is contained in:
Ouss4 2020-06-12 15:56:26 +01:00 committed by Alan Carvalho de Assis
parent ebfc12d3d2
commit 02ad0e9094
3 changed files with 40 additions and 32 deletions

View File

@ -68,7 +68,8 @@ static int ncp5623c_i2c_write_byte(FAR struct ncp5623c_dev_s *priv,
static int ncp5623c_open(FAR struct file *filep); static int ncp5623c_open(FAR struct file *filep);
static int ncp5623c_close(FAR struct file *filep); static int ncp5623c_close(FAR struct file *filep);
static int ncp5623c_ioctl(FAR struct file *filep, int cmd, unsigned long arg); static int ncp5623c_ioctl(FAR struct file *filep, int cmd,
unsigned long arg);
static ssize_t ncp5623c_read(FAR struct file *filep, FAR char *buffer, static ssize_t ncp5623c_read(FAR struct file *filep, FAR char *buffer,
size_t buflen); size_t buflen);
static ssize_t ncp5623c_write(FAR struct file *filep, FAR const char *buffer, static ssize_t ncp5623c_write(FAR struct file *filep, FAR const char *buffer,
@ -162,7 +163,7 @@ static int ncp5623c_open(FAR struct file *filep)
/* Set up Max current */ /* Set up Max current */
ret = ncp5623c_i2c_write_byte(priv, NCP5623C_ILED, 0x1F); ret = ncp5623c_i2c_write_byte(priv, NCP5623C_ILED, 0x1f);
if (ret != OK) if (ret != OK)
{ {
lcderr("ERROR: Could not set up max current\n"); lcderr("ERROR: Could not set up max current\n");
@ -204,7 +205,8 @@ static int ncp5623c_close(FAR struct file *filep)
* Name: ncp5623c_ioctl * Name: ncp5623c_ioctl
* *
* Description: * Description:
* This function is called whenever an ioctl call to a NCP5623C is performed. * This function is called whenever an ioctl call to a NCP5623C is
* performed.
* *
****************************************************************************/ ****************************************************************************/

View File

@ -71,7 +71,8 @@ static int pca9635pw_set_led_mode(FAR struct pca9635pw_dev_s *priv,
static int pca9635pw_open(FAR struct file *filep); static int pca9635pw_open(FAR struct file *filep);
static int pca9635pw_close(FAR struct file *filep); static int pca9635pw_close(FAR struct file *filep);
static int pca9635pw_ioctl(FAR struct file *filep, int cmd, unsigned long arg); static int pca9635pw_ioctl(FAR struct file *filep, int cmd,
unsigned long arg);
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
@ -123,8 +124,8 @@ static int pca9635pw_i2c_write_byte(FAR struct pca9635pw_dev_s *priv,
/* Write the register address followed by the data (no RESTART) */ /* Write the register address followed by the data (no RESTART) */
lcdinfo("i2c addr: 0x%02X reg addr: 0x%02X value: 0x%02X\n", priv->i2c_addr, lcdinfo("i2c addr: 0x%02X reg addr: 0x%02X value: 0x%02X\n",
buffer[0], buffer[1]); priv->i2c_addr, buffer[0], buffer[1]);
ret = i2c_write(priv->i2c, &config, buffer, BUFFER_SIZE); ret = i2c_write(priv->i2c, &config, buffer, BUFFER_SIZE);
if (ret < 0) if (ret < 0)
@ -140,7 +141,8 @@ static int pca9635pw_i2c_write_byte(FAR struct pca9635pw_dev_s *priv,
* Name: pca9635pw_set_led_mode * Name: pca9635pw_set_led_mode
* *
* Description: * Description:
* Set the led output mode (see PCA9635PW_LED_OUT_x register value definitions) * Set the led output mode (see PCA9635PW_LED_OUT_x register value
* definitions)
* *
****************************************************************************/ ****************************************************************************/
@ -210,8 +212,8 @@ static int pca9635pw_open(FAR struct file *filep)
} }
/* A delay of 500 us is necessary since this is the maximum time which the /* A delay of 500 us is necessary since this is the maximum time which the
* oscillator of the PCA9635PW needs to be up and running once sleep mode was * oscillator of the PCA9635PW needs to be up and running once sleep mode
* left. * was left.
*/ */
nxsig_usleep(500); nxsig_usleep(500);
@ -220,11 +222,11 @@ static int pca9635pw_open(FAR struct file *filep)
* by the individual pwm registers. * by the individual pwm registers.
*/ */
ret = pca9635pw_set_led_mode(priv, PCA9635PW_LED_OUT_x_MODE_2); ret = pca9635pw_set_led_mode(priv, PCA9635PW_LED_OUT_X_MODE_2);
if (ret < 0) if (ret < 0)
{ {
lcderr("ERROR: Could not set led driver outputs to MODE2 (LED's brightness are " lcderr("ERROR: Could not set led driver outputs to MODE2"
"controlled by pwm registers)\n"); " (LED's brightness are controlled by pwm registers)\n");
return ret; return ret;
} }
@ -247,10 +249,11 @@ static int pca9635pw_close(FAR struct file *filep)
/* Turn all led drivers off */ /* Turn all led drivers off */
ret = pca9635pw_set_led_mode(priv, PCA9635PW_LED_OUT_x_MODE_0); ret = pca9635pw_set_led_mode(priv, PCA9635PW_LED_OUT_X_MODE_0);
if (ret < 0) if (ret < 0)
{ {
lcderr("ERROR: Could not set led driver outputs to MODE0 (LED's are off)\n"); lcderr("ERROR: Could not set led driver outputs to MODE0"
" (LED's are off)\n");
return ret; return ret;
} }
@ -258,7 +261,7 @@ static int pca9635pw_close(FAR struct file *filep)
uint8_t const PCA9635PW_MODE_1_FINAL_VALUE = PCA9635PW_MODE_1_SLEEP; uint8_t const PCA9635PW_MODE_1_FINAL_VALUE = PCA9635PW_MODE_1_SLEEP;
ret =pca9635pw_i2c_write_byte(priv, PCA9635PW_MODE_1, ret = pca9635pw_i2c_write_byte(priv, PCA9635PW_MODE_1,
PCA9635PW_MODE_1_FINAL_VALUE); PCA9635PW_MODE_1_FINAL_VALUE);
if (ret < 0) if (ret < 0)
{ {
@ -272,11 +275,13 @@ static int pca9635pw_close(FAR struct file *filep)
* Name: pca9635pw_close * Name: pca9635pw_close
* *
* Description: * Description:
* This function is called whenever an ioctl call to a PCA9635PW is performed. * This function is called whenever an ioctl call to a PCA9635PW is
* performed.
* *
****************************************************************************/ ****************************************************************************/
static int pca9635pw_ioctl(FAR struct file *filep, int cmd, unsigned long arg) static int pca9635pw_ioctl(FAR struct file *filep, int cmd,
unsigned long arg)
{ {
FAR struct inode *inode = filep->f_inode; FAR struct inode *inode = filep->f_inode;
FAR struct pca9635pw_dev_s *priv = inode->i_private; FAR struct pca9635pw_dev_s *priv = inode->i_private;
@ -286,16 +291,16 @@ static int pca9635pw_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
switch (cmd) switch (cmd)
{ {
/* Set the brightness of an individual LED. Arg: pca9635pw_led_brightness_s /* Set the brightness of an individual LED.
* pointer. * Arg: pca9635pw_brightness_s pointer.
*/ */
case PWMIOC_SETLED_BRIGHTNESS: case PWMIOC_SETLED_BRIGHTNESS:
{ {
/* Retrieve the information handed over as argument for this ioctl */ /* Retrieve the information handed over as argument for this ioctl */
FAR const struct pca9635pw_setled_brightness_arg_s *ptr = FAR const struct pca9635pw_brightness_s *ptr =
(FAR const struct pca9635pw_setled_brightness_arg_s *)((uintptr_t)arg); (FAR const struct pca9635pw_brightness_s *)((uintptr_t)arg);
DEBUGASSERT(ptr != NULL); DEBUGASSERT(ptr != NULL);

View File

@ -107,14 +107,14 @@
/* PCA9635PW_LED_OUT_x register value definitions */ /* PCA9635PW_LED_OUT_x register value definitions */
#define PCA9635PW_LED_OUT_x_MODE_0 (0x00) /* all led drivers are turned off */ #define PCA9635PW_LED_OUT_X_MODE_0 (0x00) /* all led drivers are turned off */
#define PCA9635PW_LED_OUT_x_MODE_1 (0x55) /* all led drivers are fully turned on */ #define PCA9635PW_LED_OUT_X_MODE_1 (0x55) /* all led drivers are fully turned on */
#define PCA9635PW_LED_OUT_x_MODE_2 (0xAA) /* all led drivers individual brightness can be controlled by their individual pwm registers */ #define PCA9635PW_LED_OUT_X_MODE_2 (0xAA) /* all led drivers individual brightness can be controlled by their individual pwm registers */
#define PCA9635PW_LED_OUT_x_MODE_3 (0xFF) /* all led drivers individual brightness and group dimming/blinking can be controlled by their individual pwm registers and the GRPPWM register */ #define PCA9635PW_LED_OUT_X_MODE_3 (0xFF) /* all led drivers individual brightness and group dimming/blinking can be controlled by their individual pwm registers and the GRPPWM register */
/* IOCTL commands */ /* IOCTL commands */
#define PWMIOC_SETLED_BRIGHTNESS _PWMIOC(1) /* Arg: pca9635pw_setled_brightness_arg_s * pointer */ #define PWMIOC_SETLED_BRIGHTNESS _PWMIOC(1) /* Arg: pca9635pw_brightness_s * pointer */
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
@ -140,14 +140,15 @@ enum led_select_e
LED_15 = PCA9635PW_LED_15 LED_15 = PCA9635PW_LED_15
}; };
/* This structure is used in an IOCTL command for setting the PWM of an individual /* This structure is used in an IOCTL command for setting the PWM of an
* LED. The desired LED is selected by setting the 'led' parameter accordingly * individual LED. The desired LED is selected by setting the 'led'
* whereas the 'led_pwm' field governs the brightness of the selected LED. A value * parameter accordingly whereas the 'led_pwm' field governs the brightness
* of 0 (0x00) leads to a duty cycle of 0 % = LED off while a value of 255 (0xFF) * of the selected LED.
* leads to a duty cycle of 99.6 % = Maximum brightness. * A value of 0 (0x00) leads to a duty cycle of 0 % = LED off while a value
* of 255 (0xFF) leads to a duty cycle of 99.6 % = Maximum brightness.
*/ */
struct pca9635pw_setled_brightness_arg_s struct pca9635pw_brightness_s
{ {
enum led_select_e led; enum led_select_e led;
uint8_t brightness; uint8_t brightness;