apache-mynewt-bot commented on issue #2255: Add SGM4056 charger driver to pinetime BSP URL: https://github.com/apache/mynewt-core/pull/2255#issuecomment-606501796 <!-- style-bot --> ## Style check summary ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md) #### hw/drivers/chg_ctrl/sgm4056/include/sgm4056/sgm4056.h <details> ```diff @@ -28,24 +28,24 @@ struct sgm4056_dev { struct os_dev dev; #if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL) - struct charge_control chg_ctrl; + struct charge_control chg_ctrl; struct os_event interrupt_event; #endif struct sgm4056_dev_config config; }; /** -* Init function for SGM4056 charger -* @return 0 on success, non-zero on failure -*/ + * Init function for SGM4056 charger + * @return 0 on success, non-zero on failure + */ int sgm4056_dev_init(struct os_dev *dev, void *arg); /** - * Reads the state of the power presence indication. Value is 1 when the input + * Reads the state of the power presence indication. Value is 1 when the input * voltage is above the POR threshold but below the OVP threshold and 0 otherwise. * * @param dev The sgm4056 device to read on - * @param power_present Power presence indication to be returned by the + * @param power_present Power presence indication to be returned by the * function (0 if input voltage is not detected, 1 if it is detected) * * @return 0 on success, non-zero on failure @@ -53,11 +53,11 @@ int sgm4056_get_power_presence(struct sgm4056_dev *dev, int *power_present); /** - * Reads the state of the charge indication. Value is 1 when a charge cycle + * Reads the state of the charge indication. Value is 1 when a charge cycle * started and will be 0 when the end-of-charge (EOC) condition is met. * * @param dev The sgm4056 device to read on - * @param charging Charge indication to be returned by the + * @param charging Charge indication to be returned by the * function (0 if battery is not charging, 1 if it is charging) * * @return 0 on success, non-zero on failure @@ -65,7 +65,7 @@ int sgm4056_get_charge_indicator(struct sgm4056_dev *dev, int *charging); /** - * Reads the state of the charger. This is a combination of the power presence + * Reads the state of the charger. This is a combination of the power presence * and charge indications. Value is either: * - CHARGE_CONTROL_STATUS_NO_SOURCE, when no power present * - CHARGE_CONTROL_STATUS_CHARGING, when power present and charging ``` </details> #### hw/drivers/chg_ctrl/sgm4056/src/sgm4056.c <details> ```diff @@ -19,7 +19,7 @@ #if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL) -static int +static int sgm4056_chg_ctrl_get_status(struct charge_control * chg_ctrl, int * status) { struct sgm4056_dev *dev; @@ -37,10 +37,10 @@ return rc; } -static int -sgm4056_chg_ctrl_read(struct charge_control * chg_ctrl, - charge_control_type_t type, charge_control_data_func_t data_func, - void *data_arg, uint32_t timeout) +static int +sgm4056_chg_ctrl_read(struct charge_control * chg_ctrl, + charge_control_type_t type, charge_control_data_func_t data_func, + void *data_arg, uint32_t timeout) { int rc = 0; int status; @@ -51,8 +51,8 @@ goto err; } - if(data_func) { - data_func(chg_ctrl, data_arg, (void*)&status, CHARGE_CONTROL_TYPE_STATUS); + if (data_func) { + data_func(chg_ctrl, data_arg, (void *)&status, CHARGE_CONTROL_TYPE_STATUS); } } @@ -80,7 +80,7 @@ NULL, NULL, OS_TIMEOUT_NEVER); } -static void +static void sgm4056_irq_handler(void *arg) { struct sgm4056_dev *dev = (struct sgm4056_dev *)arg; @@ -90,8 +90,9 @@ } #endif -int -sgm4056_dev_init(struct os_dev *odev, void *arg) { +int +sgm4056_dev_init(struct os_dev *odev, void *arg) +{ struct sgm4056_dev *dev = (struct sgm4056_dev *)odev; const struct sgm4056_dev_config *cfg = arg; int rc = 0; @@ -107,7 +108,8 @@ dev->interrupt_event.ev_cb = sgm4056_interrupt_event_handler; dev->interrupt_event.ev_arg = dev; - rc = hal_gpio_irq_init(dev->config.power_presence_pin, sgm4056_irq_handler, dev, HAL_GPIO_TRIG_BOTH, HAL_GPIO_PULL_NONE); + rc = hal_gpio_irq_init(dev->config.power_presence_pin, sgm4056_irq_handler, dev, HAL_GPIO_TRIG_BOTH, + HAL_GPIO_PULL_NONE); hal_gpio_irq_enable(dev->config.power_presence_pin); #else rc = hal_gpio_init_in(dev->config.power_presence_pin, HAL_GPIO_PULL_NONE); @@ -128,7 +130,7 @@ } rc = charge_control_set_driver(&dev->chg_ctrl, CHARGE_CONTROL_TYPE_STATUS, - (struct charge_control_driver *)&sgm4056_chg_ctrl_driver); + (struct charge_control_driver *)&sgm4056_chg_ctrl_driver); if (rc) { goto err; } @@ -148,21 +150,27 @@ return rc; } -int sgm4056_get_power_presence(struct sgm4056_dev *dev, int *power_present) { +int +sgm4056_get_power_presence(struct sgm4056_dev *dev, int *power_present) +{ int gpio_value = hal_gpio_read(dev->config.power_presence_pin); *power_present = (gpio_value == 0); return 0; } -int sgm4056_get_charge_indicator(struct sgm4056_dev *dev, int *charging) { +int +sgm4056_get_charge_indicator(struct sgm4056_dev *dev, int *charging) +{ int gpio_value = hal_gpio_read(dev->config.charge_indicator_pin); *charging = (gpio_value == 0); return 0; } -int sgm4056_get_charger_status(struct sgm4056_dev *dev, charge_control_status_t *charger_status) { +int +sgm4056_get_charger_status(struct sgm4056_dev *dev, charge_control_status_t *charger_status) +{ int power_present; int charging; int rc; ``` </details>
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services