[GitHub] [mynewt-nimble] prasad-alatkar commented on issue #790: nimble/store: Fix nimble store behavior when CCCDs exceed static defined limit

2020-03-31 Thread GitBox
prasad-alatkar commented on issue #790: nimble/store: Fix nimble store behavior 
when CCCDs exceed static defined limit
URL: https://github.com/apache/mynewt-nimble/pull/790#issuecomment-607031816
 
 
   @h2zero That is a valid point, will update if I find anything. Maybe 
@rymanluk can explain it to us.


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


[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on issue #2257: sys/id: Add optional id/serial_mfg field for storing manufacturer serial number

2020-03-31 Thread GitBox
apache-mynewt-bot removed a comment on issue #2257: sys/id: Add optional 
id/serial_mfg field for storing manufacturer serial number
URL: https://github.com/apache/mynewt-core/pull/2257#issuecomment-606996564
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    sys/id/include/id/id.h
   
   
   ```diff
   @@ -25,19 +25,19 @@
#endif

#if MYNEWT_VAL(ID_SERIAL_PRESENT)
   -/*
   - * Maximum expected serial number string length.
   - */
   +/*
   + * Maximum expected serial number string length.
   + */
#define ID_SERIAL_MAX_LEN   MYNEWT_VAL(ID_SERIAL_MAX_LEN)
   -extern char id_serial[];
   +extern char id_serial[];
#endif

#if MYNEWT_VAL(ID_SERIAL_MFG_PRESENT)
   -/*
   - * Maximum expected serial_mfg number string length.
   - */
   +/*
   + * Maximum expected serial_mfg number string length.
   + */
#define ID_SERIAL_MFG_MAX_LEN   MYNEWT_VAL(ID_SERIAL_MFG_MAX_LEN)
   -extern char id_serial_mfg[];
   +extern char id_serial_mfg[];
#endif

#if MYNEWT_VAL(ID_MANUFACTURER_LOCAL)
   ```
   
   


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


[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2257: sys/id: Add optional id/serial_mfg field for storing manufacturer serial number

2020-03-31 Thread GitBox
apache-mynewt-bot commented on issue #2257: sys/id: Add optional id/serial_mfg 
field for storing manufacturer serial number
URL: https://github.com/apache/mynewt-core/pull/2257#issuecomment-606999280
 
 
   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


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


[GitHub] [mynewt-core] benmccrea commented on issue #2256: sys/id: Add optional id/serial_mfg field for storing manufacturer serial numbers

2020-03-31 Thread GitBox
benmccrea commented on issue #2256: sys/id: Add optional id/serial_mfg field 
for storing manufacturer serial numbers
URL: https://github.com/apache/mynewt-core/pull/2256#issuecomment-606997984
 
 
   Closing in favor of 2257


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


[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2257: sys/id: Add optional id/serial_mfg field for storing manufacturer serial number

2020-03-31 Thread GitBox
apache-mynewt-bot commented on issue #2257: sys/id: Add optional id/serial_mfg 
field for storing manufacturer serial number
URL: https://github.com/apache/mynewt-core/pull/2257#issuecomment-606996564
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    sys/id/include/id/id.h
   
   
   ```diff
   @@ -25,19 +25,19 @@
#endif

#if MYNEWT_VAL(ID_SERIAL_PRESENT)
   -/*
   - * Maximum expected serial number string length.
   - */
   +/*
   + * Maximum expected serial number string length.
   + */
#define ID_SERIAL_MAX_LEN   MYNEWT_VAL(ID_SERIAL_MAX_LEN)
   -extern char id_serial[];
   +extern char id_serial[];
#endif

#if MYNEWT_VAL(ID_SERIAL_MFG_PRESENT)
   -/*
   - * Maximum expected serial_mfg number string length.
   - */
   +/*
   + * Maximum expected serial_mfg number string length.
   + */
#define ID_SERIAL_MFG_MAX_LEN   MYNEWT_VAL(ID_SERIAL_MFG_MAX_LEN)
   -extern char id_serial_mfg[];
   +extern char id_serial_mfg[];
#endif

#if MYNEWT_VAL(ID_MANUFACTURER_LOCAL)
   ```
   
   


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


[GitHub] [mynewt-core] benmccrea opened a new pull request #2257: sys/id: Add optional id/serial_mfg field for storing manufacturer serial number

2020-03-31 Thread GitBox
benmccrea opened a new pull request #2257: sys/id: Add optional id/serial_mfg 
field for storing manufacturer serial number
URL: https://github.com/apache/mynewt-core/pull/2257
 
 
   This PR adds a new optional field, id/serial_mfg to be used for alternate 
serial numbers on devices during the manufacturing process.
   
   The syscfg ID_SERIAL_MFG_PRESENT is disabled by default.


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


[GitHub] [mynewt-core] benmccrea closed pull request #2256: sys/id: Add optional id/serial_mfg field for storing manufacturer serial numbers

2020-03-31 Thread GitBox
benmccrea closed pull request #2256: sys/id: Add optional id/serial_mfg field 
for storing manufacturer serial numbers
URL: https://github.com/apache/mynewt-core/pull/2256
 
 
   


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


[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2256: sys/id: Add optional id/serial_mfg field for storing manufacturer serial numbers

2020-03-31 Thread GitBox
apache-mynewt-bot commented on issue #2256: sys/id: Add optional id/serial_mfg 
field for storing manufacturer serial numbers
URL: https://github.com/apache/mynewt-core/pull/2256#issuecomment-606987980
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    sys/id/include/id/id.h
   
   
   ```diff
   @@ -25,19 +25,19 @@
#endif

#if MYNEWT_VAL(ID_SERIAL_PRESENT)
   -/*
   - * Maximum expected serial number string length.
   - */
   +/*
   + * Maximum expected serial number string length.
   + */
#define ID_SERIAL_MAX_LEN   MYNEWT_VAL(ID_SERIAL_MAX_LEN)
   -extern char id_serial[];
   +extern char id_serial[];
#endif

#if MYNEWT_VAL(ID_SERIAL_MFG_PRESENT)
   -/*
   - * Maximum expected serial_mfg number string length.
   - */
   +/*
   + * Maximum expected serial_mfg number string length.
   + */
#define ID_SERIAL_MFG_MAX_LEN   MYNEWT_VAL(ID_SERIAL_MFG_MAX_LEN)
   -extern char id_serial_mfg[];
   +extern char id_serial_mfg[];
#endif

#if MYNEWT_VAL(ID_MANUFACTURER_LOCAL)
   ```
   
   


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


[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2256: sys/id: Add optional id/serial_mfg field for storing manufacturer serial numbers

2020-03-31 Thread GitBox
apache-mynewt-bot commented on issue #2256: sys/id: Add optional id/serial_mfg 
field for storing manufacturer serial numbers
URL: https://github.com/apache/mynewt-core/pull/2256#issuecomment-606987859
 
 
   
   
   
   ## RAT Report (2020-04-01 02:20:28)
   
   ## New files with unknown licenses
   
   * https://github.com/apache/mynewt-core/blob/d30ce3fe710b2d9f951df9c2decefc3522645038/hw/bsp/pinetime/boot-pinetime.ld;>hw/bsp/pinetime/boot-pinetime.ld
   
   ## 11 new files were excluded from check (.rat-excludes)
   
   
 Detailed analysis
   
   ## New files in this PR
   
   | License | File |
   |-|--|
   | ?  | https://github.com/apache/mynewt-core/blob/d30ce3fe710b2d9f951df9c2decefc3522645038/hw/bsp/pinetime/boot-pinetime.ld;>hw/bsp/pinetime/boot-pinetime.ld
 |
   | AL | https://github.com/apache/mynewt-core/blob/d30ce3fe710b2d9f951df9c2decefc3522645038/hw/bsp/pinetime/bsp.yml;>hw/bsp/pinetime/bsp.yml
 |
   | AL | https://github.com/apache/mynewt-core/blob/d30ce3fe710b2d9f951df9c2decefc3522645038/hw/bsp/pinetime/pinetime.ld;>hw/bsp/pinetime/pinetime.ld
 |
   | AL | https://github.com/apache/mynewt-core/blob/d30ce3fe710b2d9f951df9c2decefc3522645038/hw/bsp/pinetime/pinetime_debug.sh;>hw/bsp/pinetime/pinetime_debug.sh
 |
   | AL | https://github.com/apache/mynewt-core/blob/d30ce3fe710b2d9f951df9c2decefc3522645038/hw/bsp/pinetime/pinetime_download.sh;>hw/bsp/pinetime/pinetime_download.sh
 |
   | AL | https://github.com/apache/mynewt-core/blob/d30ce3fe710b2d9f951df9c2decefc3522645038/hw/bsp/pinetime/pkg.yml;>hw/bsp/pinetime/pkg.yml
 |
   | AL | https://github.com/apache/mynewt-core/blob/d30ce3fe710b2d9f951df9c2decefc3522645038/hw/bsp/pinetime/syscfg.yml;>hw/bsp/pinetime/syscfg.yml
 |
   | AL | https://github.com/apache/mynewt-core/blob/d30ce3fe710b2d9f951df9c2decefc3522645038/hw/bsp/pinetime/include/bsp/bsp.h;>hw/bsp/pinetime/include/bsp/bsp.h
 |
   | AL | https://github.com/apache/mynewt-core/blob/d30ce3fe710b2d9f951df9c2decefc3522645038/hw/bsp/pinetime/src/hal_bsp.c;>hw/bsp/pinetime/src/hal_bsp.c
 |
   | AL | https://github.com/apache/mynewt-core/blob/d30ce3fe710b2d9f951df9c2decefc3522645038/hw/bsp/pinetime/src/sbrk.c;>hw/bsp/pinetime/src/sbrk.c
 |
   
   
   


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


[GitHub] [mynewt-core] benmccrea opened a new pull request #2256: sys/id: Add optional id/serial_mfg field for storing manufacturer serial numbers

2020-03-31 Thread GitBox
benmccrea opened a new pull request #2256: sys/id: Add optional id/serial_mfg 
field for storing manufacturer serial numbers
URL: https://github.com/apache/mynewt-core/pull/2256
 
 
   This PR adds a new optional field, `id/serial_mfg` to be used for alternate 
serial numbers on devices during the manufacturing process.
   
   The syscfg `ID_SERIAL_MFG_PRESENT` is disabled by default. 


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


[GitHub] [mynewt-nimble] h2zero commented on issue #790: nimble/store: Fix nimble store behavior when CCCDs exceed static defined limit

2020-03-31 Thread GitBox
h2zero commented on issue #790: nimble/store: Fix nimble store behavior when 
CCCDs exceed static defined limit
URL: https://github.com/apache/mynewt-nimble/pull/790#issuecomment-606926563
 
 
   Glad you built a proper fix and hope it gets merged. 
   
   I still question why we store cccd data for devices that aren’t bonded but 
that’s a separate issue.


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


[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #790: nimble/store: Fix nimble store behavior when CCCDs exceed static defined limit

2020-03-31 Thread GitBox
apache-mynewt-bot commented on issue #790: nimble/store: Fix nimble store 
behavior when CCCDs exceed static defined limit
URL: https://github.com/apache/mynewt-nimble/pull/790#issuecomment-606821185
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    nimble/host/src/ble_store_util.c
   
   
   ```diff
   @@ -306,31 +306,31 @@
switch (event->event_code) {
case BLE_STORE_EVENT_OVERFLOW:
switch (event->overflow.obj_type) {
   -case BLE_STORE_OBJ_TYPE_OUR_SEC:
   -case BLE_STORE_OBJ_TYPE_PEER_SEC:
   -case BLE_STORE_OBJ_TYPE_CCCD:
   -if (( rc = ble_gap_unpair_oldest_peer()) == BLE_HS_ENOENT) {
   -/* No peer to unpair. Here bonds do not exist but CCCDs 
are
   - * stored. Need to delete CCCDs to make space. */
   -rc = ble_store_util_subscribed_cccds(_id_addr,
   +case BLE_STORE_OBJ_TYPE_OUR_SEC:
   +case BLE_STORE_OBJ_TYPE_PEER_SEC:
   +case BLE_STORE_OBJ_TYPE_CCCD:
   +if ((rc = ble_gap_unpair_oldest_peer()) == BLE_HS_ENOENT) {
   +/* No peer to unpair. Here bonds do not exist but CCCDs are
   + * stored. Need to delete CCCDs to make space. */
   +rc = ble_store_util_subscribed_cccds(_id_addr,
 _peers, 1);
   -if ((rc != 0) || (num_peers == 0)) {
   -return rc;
   -}
   -
   -union ble_store_key key = {0};
   -key.cccd.peer_addr = peer_id_addr;
   -
   -rc = ble_store_util_delete_all(BLE_STORE_OBJ_TYPE_CCCD, 
);
   -if (rc != 0) {
   -return rc;
   -}
   +if ((rc != 0) || (num_peers == 0)) {
   +return rc;
}

   -return rc;
   -
   -default:
   -return BLE_HS_EUNKNOWN;
   +union ble_store_key key = {0};
   +key.cccd.peer_addr = peer_id_addr;
   +
   +rc = ble_store_util_delete_all(BLE_STORE_OBJ_TYPE_CCCD, 
);
   +if (rc != 0) {
   +return rc;
   +}
   +}
   +
   +return rc;
   +
   +default:
   +return BLE_HS_EUNKNOWN;
}

case BLE_STORE_EVENT_FULL:
   ```
   
   


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


[GitHub] [mynewt-nimble] prasad-alatkar opened a new pull request #790: nimble/store: Fix nimble store behavior when CCCDs exceed static defined limit

2020-03-31 Thread GitBox
prasad-alatkar opened a new pull request #790: nimble/store: Fix nimble store 
behavior when CCCDs exceed static defined limit
URL: https://github.com/apache/mynewt-nimble/pull/790
 
 
   Issue reference: #788 
   
   Description: In cases where CCCDs are exceeding 
MYNEWT_VAL(BLE_STORE_MAX_CCCDS) (overflow event), we can end up in continuous 
while loop.
   
   Change list:
   1. In `ble_gap_unpair_oldest_peer` changed return value from `0` to 
`BLE_HS_ENOENT` when there is no entry found.
   2. Modified `ble_store_util_status_rr` to address overflow event of CCCDs.
   
   Previous to this PR, if CCCDs used to exceed the MAX_CCCDs then in 
`ble_store_write` call there used to come OVERFLOW event, which used to call 
`ble_store_delete_oldest_peer`, now here as we do not have any peer to be 
deleted, we should have identified that we need to make space for CCCDs and not 
`peer_sec` or `our_sec`. The PR tries to address this issue.


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


[GitHub] [mynewt-core] mlaz commented on issue #2254: [RFC] docs/os/bsp: Add board support section

2020-03-31 Thread GitBox
mlaz commented on issue #2254: [RFC] docs/os/bsp: Add board support section
URL: https://github.com/apache/mynewt-core/pull/2254#issuecomment-606784118
 
 
   Ok, I changed the title of this PR to [RFC] since this is a structural 
change to doc. Anyway I agree with it and I think we should encourage new BSP 
PRs to also include an entry under this new section.


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


[GitHub] [mynewt-core] mlaz commented on a change in pull request #2255: Add SGM4056 charger driver to pinetime BSP

2020-03-31 Thread GitBox
mlaz commented on a change in pull request #2255: Add SGM4056 charger driver to 
pinetime BSP
URL: https://github.com/apache/mynewt-core/pull/2255#discussion_r401102875
 
 

 ##
 File path: hw/drivers/chg_ctrl/sgm4056/src/sgm4056.c
 ##
 @@ -0,0 +1,192 @@
+/*
+ * Copyright 2020 Casper Meijn 
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sgm4056/sgm4056.h"
+#include "hal/hal_gpio.h"
+
+#if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL)
+
+static int 
+sgm4056_chg_ctrl_get_status(struct charge_control * chg_ctrl, int * status)
+{
+struct sgm4056_dev *dev;
+int rc;
+
+dev = (struct sgm4056_dev *)CHARGE_CONTROL_GET_DEVICE(chg_ctrl);
+if (dev == NULL) {
+rc = SYS_ENODEV;
+goto err;
+}
+
+rc = sgm4056_get_charger_status(dev, (charge_control_status_t *)status);
+
+err:
+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)
+{
+int rc = 0;
+int status;
+
+if (type & CHARGE_CONTROL_TYPE_STATUS) {
+rc = sgm4056_chg_ctrl_get_status(chg_ctrl, );
+if (rc) {
+goto err;
+}
+
+if(data_func) {
+data_func(chg_ctrl, data_arg, (void*), 
CHARGE_CONTROL_TYPE_STATUS);
+}
+}
+
+err:
+return rc;
+}
+
+static const struct charge_control_driver sgm4056_chg_ctrl_driver = {
+.ccd_read = sgm4056_chg_ctrl_read,
+.ccd_get_config = NULL,
+.ccd_set_config = NULL,
+.ccd_get_status = sgm4056_chg_ctrl_get_status,
+.ccd_get_fault = NULL,
+.ccd_enable = NULL,
+.ccd_disable = NULL,
+};
+
+static void
+sgm4056_interrupt_event_handler(struct os_event *ev)
+{
+struct sgm4056_dev *dev = (struct sgm4056_dev *)ev->ev_arg;
+assert(dev);
+
+charge_control_read(>chg_ctrl, CHARGE_CONTROL_TYPE_STATUS,
+NULL, NULL, OS_TIMEOUT_NEVER);
+}
+
+static void 
+sgm4056_irq_handler(void *arg)
+{
+struct sgm4056_dev *dev = (struct sgm4056_dev *)arg;
+assert(dev);
+
+os_eventq_put(os_eventq_dflt_get(), >interrupt_event);
+}
+#endif
+
+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;
+
+if (!dev) {
+rc = SYS_ENODEV;
+goto err;
+}
+
+dev->config = *cfg;
+
+#if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL)
+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);
+hal_gpio_irq_enable(dev->config.power_presence_pin);
+#else
+rc = hal_gpio_init_in(dev->config.power_presence_pin, HAL_GPIO_PULL_NONE);
+#endif
+if (rc) {
+goto err;
+}
+
+rc = hal_gpio_init_in(dev->config.charge_indicator_pin, 
HAL_GPIO_PULL_NONE);
+if (rc) {
+goto err;
+}
+
+#if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL)
+rc = charge_control_init(>chg_ctrl, odev);
+if (rc) {
+goto err;
+}
+
+rc = charge_control_set_driver(>chg_ctrl, CHARGE_CONTROL_TYPE_STATUS,
+(struct charge_control_driver *)_chg_ctrl_driver);
+if (rc) {
+goto err;
+}
+
+rc = charge_control_set_type_mask(>chg_ctrl, 
CHARGE_CONTROL_TYPE_STATUS);
+if (rc) {
+goto err;
+}
+
+rc = charge_control_mgr_register(>chg_ctrl);
+if (rc) {
+goto err;
+}
+#endif
+
+err:
+return rc;
+}
+
+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 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) {
 
 Review comment:
   Curl bracket should be on the next line and line is longer than 80 columns.


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 

[GitHub] [mynewt-core] mlaz commented on a change in pull request #2255: Add SGM4056 charger driver to pinetime BSP

2020-03-31 Thread GitBox
mlaz commented on a change in pull request #2255: Add SGM4056 charger driver to 
pinetime BSP
URL: https://github.com/apache/mynewt-core/pull/2255#discussion_r401104807
 
 

 ##
 File path: hw/drivers/chg_ctrl/sgm4056/src/sgm4056.c
 ##
 @@ -0,0 +1,192 @@
+/*
+ * Copyright 2020 Casper Meijn 
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sgm4056/sgm4056.h"
+#include "hal/hal_gpio.h"
+
+#if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL)
+
+static int 
+sgm4056_chg_ctrl_get_status(struct charge_control * chg_ctrl, int * status)
+{
+struct sgm4056_dev *dev;
+int rc;
+
+dev = (struct sgm4056_dev *)CHARGE_CONTROL_GET_DEVICE(chg_ctrl);
+if (dev == NULL) {
+rc = SYS_ENODEV;
+goto err;
+}
+
+rc = sgm4056_get_charger_status(dev, (charge_control_status_t *)status);
+
+err:
+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)
+{
+int rc = 0;
+int status;
+
+if (type & CHARGE_CONTROL_TYPE_STATUS) {
+rc = sgm4056_chg_ctrl_get_status(chg_ctrl, );
+if (rc) {
+goto err;
+}
+
+if(data_func) {
+data_func(chg_ctrl, data_arg, (void*), 
CHARGE_CONTROL_TYPE_STATUS);
+}
+}
+
+err:
+return rc;
+}
+
+static const struct charge_control_driver sgm4056_chg_ctrl_driver = {
+.ccd_read = sgm4056_chg_ctrl_read,
+.ccd_get_config = NULL,
+.ccd_set_config = NULL,
+.ccd_get_status = sgm4056_chg_ctrl_get_status,
+.ccd_get_fault = NULL,
+.ccd_enable = NULL,
+.ccd_disable = NULL,
+};
+
+static void
+sgm4056_interrupt_event_handler(struct os_event *ev)
+{
+struct sgm4056_dev *dev = (struct sgm4056_dev *)ev->ev_arg;
+assert(dev);
+
+charge_control_read(>chg_ctrl, CHARGE_CONTROL_TYPE_STATUS,
+NULL, NULL, OS_TIMEOUT_NEVER);
+}
+
+static void 
+sgm4056_irq_handler(void *arg)
+{
+struct sgm4056_dev *dev = (struct sgm4056_dev *)arg;
+assert(dev);
+
+os_eventq_put(os_eventq_dflt_get(), >interrupt_event);
+}
+#endif
+
+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;
+
+if (!dev) {
+rc = SYS_ENODEV;
+goto err;
+}
+
+dev->config = *cfg;
+
+#if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL)
+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);
+hal_gpio_irq_enable(dev->config.power_presence_pin);
+#else
+rc = hal_gpio_init_in(dev->config.power_presence_pin, HAL_GPIO_PULL_NONE);
+#endif
+if (rc) {
+goto err;
+}
+
+rc = hal_gpio_init_in(dev->config.charge_indicator_pin, 
HAL_GPIO_PULL_NONE);
+if (rc) {
+goto err;
+}
+
+#if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL)
+rc = charge_control_init(>chg_ctrl, odev);
+if (rc) {
+goto err;
+}
+
+rc = charge_control_set_driver(>chg_ctrl, CHARGE_CONTROL_TYPE_STATUS,
+(struct charge_control_driver *)_chg_ctrl_driver);
+if (rc) {
+goto err;
+}
+
+rc = charge_control_set_type_mask(>chg_ctrl, 
CHARGE_CONTROL_TYPE_STATUS);
+if (rc) {
+goto err;
+}
+
+rc = charge_control_mgr_register(>chg_ctrl);
+if (rc) {
+goto err;
+}
+#endif
+
+err:
+return rc;
+}
+
+int sgm4056_get_power_presence(struct sgm4056_dev *dev, int *power_present) {
 
 Review comment:
   Curl brackets supposed to be on the next line.


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


[GitHub] [mynewt-core] mlaz commented on a change in pull request #2255: Add SGM4056 charger driver to pinetime BSP

2020-03-31 Thread GitBox
mlaz commented on a change in pull request #2255: Add SGM4056 charger driver to 
pinetime BSP
URL: https://github.com/apache/mynewt-core/pull/2255#discussion_r401102369
 
 

 ##
 File path: hw/drivers/chg_ctrl/sgm4056/src/sgm4056.c
 ##
 @@ -0,0 +1,192 @@
+/*
+ * Copyright 2020 Casper Meijn 
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sgm4056/sgm4056.h"
+#include "hal/hal_gpio.h"
+
+#if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL)
+
+static int 
+sgm4056_chg_ctrl_get_status(struct charge_control * chg_ctrl, int * status)
+{
+struct sgm4056_dev *dev;
+int rc;
+
+dev = (struct sgm4056_dev *)CHARGE_CONTROL_GET_DEVICE(chg_ctrl);
+if (dev == NULL) {
+rc = SYS_ENODEV;
+goto err;
+}
+
+rc = sgm4056_get_charger_status(dev, (charge_control_status_t *)status);
+
+err:
+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)
+{
+int rc = 0;
+int status;
+
+if (type & CHARGE_CONTROL_TYPE_STATUS) {
+rc = sgm4056_chg_ctrl_get_status(chg_ctrl, );
+if (rc) {
+goto err;
+}
+
+if(data_func) {
+data_func(chg_ctrl, data_arg, (void*), 
CHARGE_CONTROL_TYPE_STATUS);
+}
+}
+
+err:
+return rc;
+}
+
+static const struct charge_control_driver sgm4056_chg_ctrl_driver = {
+.ccd_read = sgm4056_chg_ctrl_read,
+.ccd_get_config = NULL,
+.ccd_set_config = NULL,
+.ccd_get_status = sgm4056_chg_ctrl_get_status,
+.ccd_get_fault = NULL,
+.ccd_enable = NULL,
+.ccd_disable = NULL,
+};
+
+static void
+sgm4056_interrupt_event_handler(struct os_event *ev)
+{
+struct sgm4056_dev *dev = (struct sgm4056_dev *)ev->ev_arg;
+assert(dev);
+
+charge_control_read(>chg_ctrl, CHARGE_CONTROL_TYPE_STATUS,
+NULL, NULL, OS_TIMEOUT_NEVER);
+}
+
+static void 
+sgm4056_irq_handler(void *arg)
+{
+struct sgm4056_dev *dev = (struct sgm4056_dev *)arg;
+assert(dev);
+
+os_eventq_put(os_eventq_dflt_get(), >interrupt_event);
+}
+#endif
+
+int 
+sgm4056_dev_init(struct os_dev *odev, void *arg) {
 
 Review comment:
   This curl bracket should be on the next line.


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


[GitHub] [mynewt-core] mlaz commented on a change in pull request #2255: Add SGM4056 charger driver to pinetime BSP

2020-03-31 Thread GitBox
mlaz commented on a change in pull request #2255: Add SGM4056 charger driver to 
pinetime BSP
URL: https://github.com/apache/mynewt-core/pull/2255#discussion_r401104932
 
 

 ##
 File path: hw/drivers/chg_ctrl/sgm4056/src/sgm4056.c
 ##
 @@ -0,0 +1,192 @@
+/*
+ * Copyright 2020 Casper Meijn 
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sgm4056/sgm4056.h"
+#include "hal/hal_gpio.h"
+
+#if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL)
+
+static int 
+sgm4056_chg_ctrl_get_status(struct charge_control * chg_ctrl, int * status)
+{
+struct sgm4056_dev *dev;
+int rc;
+
+dev = (struct sgm4056_dev *)CHARGE_CONTROL_GET_DEVICE(chg_ctrl);
+if (dev == NULL) {
+rc = SYS_ENODEV;
+goto err;
+}
+
+rc = sgm4056_get_charger_status(dev, (charge_control_status_t *)status);
+
+err:
+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)
+{
+int rc = 0;
+int status;
+
+if (type & CHARGE_CONTROL_TYPE_STATUS) {
+rc = sgm4056_chg_ctrl_get_status(chg_ctrl, );
+if (rc) {
+goto err;
+}
+
+if(data_func) {
+data_func(chg_ctrl, data_arg, (void*), 
CHARGE_CONTROL_TYPE_STATUS);
+}
+}
+
+err:
+return rc;
+}
+
+static const struct charge_control_driver sgm4056_chg_ctrl_driver = {
+.ccd_read = sgm4056_chg_ctrl_read,
+.ccd_get_config = NULL,
+.ccd_set_config = NULL,
+.ccd_get_status = sgm4056_chg_ctrl_get_status,
+.ccd_get_fault = NULL,
+.ccd_enable = NULL,
+.ccd_disable = NULL,
+};
+
+static void
+sgm4056_interrupt_event_handler(struct os_event *ev)
+{
+struct sgm4056_dev *dev = (struct sgm4056_dev *)ev->ev_arg;
+assert(dev);
+
+charge_control_read(>chg_ctrl, CHARGE_CONTROL_TYPE_STATUS,
+NULL, NULL, OS_TIMEOUT_NEVER);
+}
+
+static void 
+sgm4056_irq_handler(void *arg)
+{
+struct sgm4056_dev *dev = (struct sgm4056_dev *)arg;
+assert(dev);
+
+os_eventq_put(os_eventq_dflt_get(), >interrupt_event);
+}
+#endif
+
+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;
+
+if (!dev) {
+rc = SYS_ENODEV;
+goto err;
+}
+
+dev->config = *cfg;
+
+#if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL)
+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);
+hal_gpio_irq_enable(dev->config.power_presence_pin);
+#else
+rc = hal_gpio_init_in(dev->config.power_presence_pin, HAL_GPIO_PULL_NONE);
+#endif
+if (rc) {
+goto err;
+}
+
+rc = hal_gpio_init_in(dev->config.charge_indicator_pin, 
HAL_GPIO_PULL_NONE);
+if (rc) {
+goto err;
+}
+
+#if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL)
+rc = charge_control_init(>chg_ctrl, odev);
+if (rc) {
+goto err;
+}
+
+rc = charge_control_set_driver(>chg_ctrl, CHARGE_CONTROL_TYPE_STATUS,
+(struct charge_control_driver *)_chg_ctrl_driver);
+if (rc) {
+goto err;
+}
+
+rc = charge_control_set_type_mask(>chg_ctrl, 
CHARGE_CONTROL_TYPE_STATUS);
+if (rc) {
+goto err;
+}
+
+rc = charge_control_mgr_register(>chg_ctrl);
+if (rc) {
+goto err;
+}
+#endif
+
+err:
+return rc;
+}
+
+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) {
 
 Review comment:
   Same as above.


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


[GitHub] [mynewt-core] mlaz commented on a change in pull request #2255: Add SGM4056 charger driver to pinetime BSP

2020-03-31 Thread GitBox
mlaz commented on a change in pull request #2255: Add SGM4056 charger driver to 
pinetime BSP
URL: https://github.com/apache/mynewt-core/pull/2255#discussion_r401104381
 
 

 ##
 File path: hw/drivers/chg_ctrl/sgm4056/src/sgm4056.c
 ##
 @@ -0,0 +1,192 @@
+/*
+ * Copyright 2020 Casper Meijn 
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sgm4056/sgm4056.h"
+#include "hal/hal_gpio.h"
+
+#if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL)
+
+static int 
+sgm4056_chg_ctrl_get_status(struct charge_control * chg_ctrl, int * status)
+{
+struct sgm4056_dev *dev;
+int rc;
+
+dev = (struct sgm4056_dev *)CHARGE_CONTROL_GET_DEVICE(chg_ctrl);
+if (dev == NULL) {
+rc = SYS_ENODEV;
+goto err;
+}
+
+rc = sgm4056_get_charger_status(dev, (charge_control_status_t *)status);
+
+err:
+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)
 
 Review comment:
   This indentation looks strange, I think it should start below `struct 
charge_control`, also same thing regarding the space between * and variable 
name.


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


[GitHub] [mynewt-nimble] h2zero commented on issue #788: nimble/store: `ble_gap_unpair_oldest_peer` in `ble_store_util_status_rr`(store callback) can cause infinite loop for CCCDs

2020-03-31 Thread GitBox
h2zero commented on issue #788: nimble/store: `ble_gap_unpair_oldest_peer` in 
`ble_store_util_status_rr`(store callback) can cause infinite loop for CCCDs
URL: https://github.com/apache/mynewt-nimble/issues/788#issuecomment-606723283
 
 
   I found this as well, currently testing a fix in my own fork. works for my 
purposes.
   You can see it 
[here](https://github.com/h2zero/NimBLE-Arduino/blob/bae2eb26d0128d649eb854bc23a4846d7d7581fc/src/nimble/host/src/ble_gap.c#L5305)


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


[GitHub] [mynewt-nimble] joonazan opened a new issue #789: How to use ble_gap_connect?

2020-03-31 Thread GitBox
joonazan opened a new issue #789: How to use ble_gap_connect?
URL: https://github.com/apache/mynewt-nimble/issues/789
 
 
   I am using NimBLE with esp-idf. I would like to set the connection interval 
but I can't figure out how.
   
   ble_gap_connect lets you set the interval but it seems that 
ble_gap_adv_start calls it for you.
   
   What is the most sane way of doing this?


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


[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2252: [RFC] I2S API and driver for STM32 MCUs

2020-03-31 Thread GitBox
apache-mynewt-bot commented on issue #2252: [RFC] I2S API and driver for STM32 
MCUs
URL: https://github.com/apache/mynewt-core/pull/2252#issuecomment-606714969
 
 
   
   
   
   ## Style check summary
   
    No suggestions at this time!
   


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


[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on issue #2252: [RFC] I2S API and driver for STM32 MCUs

2020-03-31 Thread GitBox
apache-mynewt-bot removed a comment on issue #2252: [RFC] I2S API and driver 
for STM32 MCUs
URL: https://github.com/apache/mynewt-core/pull/2252#issuecomment-605108684
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    hw/drivers/i2s/include/i2s/i2s.h
   
   
   ```diff
   @@ -64,7 +64,7 @@
 * @param size   single buffer size in bytes
 */
#define I2S_BUFFER_POOL_DEF(name, count, size) \
   -static uint8_t _Alignas(struct i2s_buffer_pool) name ## 
_buffers[(sizeof(struct i2s_sample_buffer[count])) + \
   +static uint8_t _Alignas(struct i2s_buffer_pool) name ## 
_buffers[(sizeof(struct i2s_sample_buffer [count])) + \
 size * 
count]; \
struct i2s_buffer_pool name = { \
.buffer_size = size, \
   ```
   
   


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


[GitHub] [mynewt-core] kasjer commented on a change in pull request #2255: Add SGM4056 charger driver to pinetime BSP

2020-03-31 Thread GitBox
kasjer commented on a change in pull request #2255: Add SGM4056 charger driver 
to pinetime BSP
URL: https://github.com/apache/mynewt-core/pull/2255#discussion_r400836974
 
 

 ##
 File path: hw/drivers/chg_ctrl/sgm4056/src/sgm4056.c
 ##
 @@ -0,0 +1,192 @@
+/*
+ * Copyright 2020 Casper Meijn 
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "sgm4056/sgm4056.h"
+#include "hal/hal_gpio.h"
+
+#if MYNEWT_VAL(SGM4056_USE_CHARGE_CONTROL)
+
+static int 
+sgm4056_chg_ctrl_get_status(struct charge_control * chg_ctrl, int * status)
 
 Review comment:
   Mynewt code usually does not have space between * and variable even though 
it's not enforce by style checker as I see.
   If you fill confident about force-pushing to you branch you can do it, then 
you changes will look perfect in git history once merged.
   If not just add commit with minor style changes that checker complained 
about.


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


[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2224: add functionality to allow low power operation for STM32L1xx

2020-03-31 Thread GitBox
apache-mynewt-bot commented on issue #2224: add functionality to allow low 
power operation for STM32L1xx
URL: https://github.com/apache/mynewt-core/pull/2224#issuecomment-606555366
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    hw/mcu/stm/stm32l1xx/src/hal_power_mgnt.c
   
   
   ```diff
   @@ -35,8 +35,8 @@
void stm32_tickless_start(uint32_t timeMS);

/* Put MCU  in lowest power stop state, exit only via POR or reset pin */
   -void 
   -hal_mcu_halt() 
   +void
   +hal_mcu_halt()
{

/* all interupts and exceptions off */
   @@ -49,7 +49,7 @@

while (1) {

   -/*Disables the Power Voltage Detector(PVD) */
   +/*Disables the Power Voltage Detector(PVD) */
HAL_PWR_DisablePVD( );
/* Enable Ultra low power mode */
HAL_PWREx_EnableUltraLowPower( );
   @@ -61,13 +61,13 @@
}
}

   -void 
   +void
stm32_tick_init(uint32_t os_ticks_per_sec, int prio)
{
/* Even for tickless we use SYSTICK for normal tick.*/
/* nb of ticks per seconds is hardcoded in HAL_InitTick(..) to have 
1ms/tick */
assert(os_ticks_per_sec == OS_TICKS_PER_SEC);
   -
   +
volatile uint32_t reload_val;

/*Reload Value = SysTick Counter Clock (Hz) x  Desired Time base (s) */
   @@ -77,8 +77,8 @@
SysTick->VAL = 0;

/* CLKSOURCE : 1 -> HCLK, 0-> AHB Clock (which is HCLK/8). Use HCLK, as 
this is the value of SystemCoreClock as used above */
   -SysTick->CTRL = (SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk 
| SysTick_CTRL_ENABLE_Msk);  
   -
   +SysTick->CTRL = (SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk 
| SysTick_CTRL_ENABLE_Msk);
   +
/* Set the system tick priority */
NVIC_SetPriority(SysTick_IRQn, prio);

   @@ -102,7 +102,7 @@

}

   -void 
   +void
stm32_tickless_start(uint32_t timeMS)
{

   @@ -116,10 +116,10 @@
CLEAR_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
}

   -void 
   +void
stm32_tickless_stop(uint32_t timeMS)
{
   -
   +
/* add asleep duration to tick counter : how long we should have slept 
for minus any remaining time */
volatile uint32_t asleep_ms = hal_rtc_get_elapsed_wakeup_timer();
volatile int asleep_ticks = os_time_ms_to_ticks32(asleep_ms);
   @@ -133,10 +133,10 @@
NVIC_EnableIRQ(SysTick_IRQn);
/* reenable SysTick */
SET_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
   -
   -}
   -
   -void 
   +
   +}
   +
   +void
stm32_power_enter(int power_mode, uint32_t durationMS)
{
/* if sleep time was less than MIN_TICKS, it is 0. Just do usual WFI 
and systick will wake us in 1ms */
   @@ -147,7 +147,7 @@

if (durationMS >= 32000) {
/* 32 sec is the largest value of wakeuptimer   leave 100ms slack */
   -durationMS = (32000 - 100); 
   +durationMS = (32000 - 100);
}

/* begin tickless */
   @@ -158,7 +158,7 @@
switch (power_mode) {
case HAL_BSP_POWER_OFF:
case HAL_BSP_POWER_DEEP_SLEEP: {
   -/*Disables the Power Voltage Detector(PVD) */
   +/*Disables the Power Voltage Detector(PVD) */
HAL_PWR_DisablePVD( );
/* Enable Ultra low power mode */
HAL_PWREx_EnableUltraLowPower( );
   @@ -172,7 +172,7 @@
}
case HAL_BSP_POWER_SLEEP: {

   -/*Disables the Power Voltage Detector(PVD) */
   +/*Disables the Power Voltage Detector(PVD) */
HAL_PWR_DisablePVD( );
/* Enable Ultra low power mode */
HAL_PWREx_EnableUltraLowPower( );
   @@ -191,11 +191,11 @@
}
case HAL_BSP_POWER_ON:
default: {
   -
   -break;
   -}
   -}
   -
   +
   +break;
   +}
   +}
   +
#if MYNEWT_VAL(OS_TICKLESS_RTC)
/* exit tickless low power mode */
stm32_tickless_stop(durationMS);
   ```
   
   
   
    hw/mcu/stm/stm32l1xx/src/rtc_utils.c
   
   
   ```diff
   @@ -1,13 +1,13 @@
/**
 * Copyright 2019 Wyres
   - * Licensed under the Apache License, Version 2.0 (the "License"); 
   - * you may not use this file except in compliance with the License. 
   + * Licensed under the Apache License, Version 2.0 (the "License");
   + * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *http://www.apache.org/licenses/LICENSE-2.0
   - * Unless required by applicable law or agreed to in writing, 
   - * software distributed under the License is distributed on 
   - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
   - * either express or implied. See the License for the 

[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on issue #2224: add functionality to allow low power operation for STM32L1xx

2020-03-31 Thread GitBox
apache-mynewt-bot removed a comment on issue #2224: add functionality to allow 
low power operation for STM32L1xx
URL: https://github.com/apache/mynewt-core/pull/2224#issuecomment-595362454
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    hw/mcu/stm/stm32l1xx/src/hal_power_mgnt.c
   
   
   ```diff
   @@ -35,8 +35,8 @@
void stm32_tickless_start(uint32_t timeMS);

/* Put MCU  in lowest power stop state, exit only via POR or reset pin */
   -void 
   -hal_mcu_halt() 
   +void
   +hal_mcu_halt()
{

/* all interupts and exceptions off */
   @@ -49,7 +49,7 @@

while (1) {

   -/*Disables the Power Voltage Detector(PVD) */
   +/*Disables the Power Voltage Detector(PVD) */
HAL_PWR_DisablePVD( );
/* Enable Ultra low power mode */
HAL_PWREx_EnableUltraLowPower( );
   @@ -61,13 +61,13 @@
}
}

   -void 
   +void
stm32_tick_init(uint32_t os_ticks_per_sec, int prio)
{
/* Even for tickless we use SYSTICK for normal tick.*/
/* nb of ticks per seconds is hardcoded in HAL_InitTick(..) to have 
1ms/tick */
assert(os_ticks_per_sec == OS_TICKS_PER_SEC);
   -
   +
volatile uint32_t reload_val;

/*Reload Value = SysTick Counter Clock (Hz) x  Desired Time base (s) */
   @@ -77,8 +77,8 @@
SysTick->VAL = 0;

/* CLKSOURCE : 1 -> HCLK, 0-> AHB Clock (which is HCLK/8). Use HCLK, as 
this is the value of SystemCoreClock as used above */
   -SysTick->CTRL = (SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk 
| SysTick_CTRL_ENABLE_Msk);  
   -
   +SysTick->CTRL = (SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk 
| SysTick_CTRL_ENABLE_Msk);
   +
/* Set the system tick priority */
NVIC_SetPriority(SysTick_IRQn, prio);

   @@ -102,7 +102,7 @@

}

   -void 
   +void
stm32_tickless_start(uint32_t timeMS)
{

   @@ -116,10 +116,10 @@
CLEAR_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
}

   -void 
   +void
stm32_tickless_stop(uint32_t timeMS)
{
   -
   +
/* add asleep duration to tick counter : how long we should have slept 
for minus any remaining time */
volatile uint32_t asleep_ms = hal_rtc_get_elapsed_wakeup_timer();
volatile int asleep_ticks = os_time_ms_to_ticks32(asleep_ms);
   @@ -133,10 +133,10 @@
NVIC_EnableIRQ(SysTick_IRQn);
/* reenable SysTick */
SET_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
   -
   -}
   -
   -void 
   +
   +}
   +
   +void
stm32_power_enter(int power_mode, uint32_t durationMS)
{
/* if sleep time was less than MIN_TICKS, it is 0. Just do usual WFI 
and systick will wake us in 1ms */
   @@ -147,7 +147,7 @@

if (durationMS >= 32000) {
/* 32 sec is the largest value of wakeuptimer   leave 100ms slack */
   -durationMS = (32000 - 100); 
   +durationMS = (32000 - 100);
}

/* begin tickless */
   @@ -158,7 +158,7 @@
switch (power_mode) {
case HAL_BSP_POWER_OFF:
case HAL_BSP_POWER_DEEP_SLEEP: {
   -/*Disables the Power Voltage Detector(PVD) */
   +/*Disables the Power Voltage Detector(PVD) */
HAL_PWR_DisablePVD( );
/* Enable Ultra low power mode */
HAL_PWREx_EnableUltraLowPower( );
   @@ -172,7 +172,7 @@
}
case HAL_BSP_POWER_SLEEP: {

   -/*Disables the Power Voltage Detector(PVD) */
   +/*Disables the Power Voltage Detector(PVD) */
HAL_PWR_DisablePVD( );
/* Enable Ultra low power mode */
HAL_PWREx_EnableUltraLowPower( );
   @@ -187,16 +187,16 @@
case HAL_BSP_POWER_WFI: {
HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);

   -//SystemClock_RestartPLL();
   +/*SystemClock_RestartPLL(); */
break;
}
case HAL_BSP_POWER_ON:
default: {
   -
   -break;
   -}
   -}
   -
   +
   +break;
   +}
   +}
   +
#if MYNEWT_VAL(OS_TICKLESS_RTC)
/* exit tickless low power mode */
stm32_tickless_stop(durationMS);
   ```
   
   
   
    hw/mcu/stm/stm32l1xx/src/rtc_utils.c
   
   
   ```diff
   @@ -1,13 +1,13 @@
/**
 * Copyright 2019 Wyres
   - * Licensed under the Apache License, Version 2.0 (the "License"); 
   - * you may not use this file except in compliance with the License. 
   + * Licensed under the Apache License, Version 2.0 (the "License");
   + * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *http://www.apache.org/licenses/LICENSE-2.0
   - * Unless required by 

[GitHub] [mynewt-core] apache-mynewt-bot commented on issue #2255: Add SGM4056 charger driver to pinetime BSP

2020-03-31 Thread GitBox
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 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
   
   
   ```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
   ```
   
   
   
    hw/drivers/chg_ctrl/sgm4056/src/sgm4056.c
   
   
   ```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*), 
CHARGE_CONTROL_TYPE_STATUS);
   +if (data_func) {
   +data_func(chg_ctrl, data_arg, (void *), 
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);
  

[GitHub] [mynewt-core] caspermeijn opened a new pull request #2255: Add SGM4056 charger driver to pinetime BSP

2020-03-31 Thread GitBox
caspermeijn opened a new pull request #2255: Add SGM4056 charger driver to 
pinetime BSP
URL: https://github.com/apache/mynewt-core/pull/2255
 
 
   This adds a driver for the SGM4056 driver. The first commit adds the base 
driver, second commit adds charge control integration to the base driver. The 
last commit adds driver initialization to the pinetime BSP.


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