[GitHub] [mynewt-core] sjanc commented on a change in pull request #2269: hw/drivers/i2s: Add I2S driver for NRF52 family

2020-04-16 Thread GitBox
sjanc commented on a change in pull request #2269: hw/drivers/i2s: Add I2S 
driver for NRF52 family
URL: https://github.com/apache/mynewt-core/pull/2269#discussion_r409360222
 
 

 ##
 File path: hw/drivers/i2s/i2s_nrf52/src/i2s_nrf52.c
 ##
 @@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct nrf52_i2s {
+nrfx_i2s_config_t nrfx_i2s_cfg;
+bool running;
+int8_t nrfx_queued_count;
+struct i2s *i2s;
+struct i2s_sample_buffer *nrfx_buffers[2];
+};
+
+static struct nrf52_i2s nrf52_i2s;
+
+static void
+nrfx_add_buffer(struct i2s *i2s, struct i2s_sample_buffer *buffer)
+{
+nrfx_i2s_buffers_t nrfx_buffers = {0};
+nrfx_err_t err;
+
+assert(i2s != NULL);
+if (buffer == NULL) {
+return;
+}
+
+if (i2s->direction == I2S_OUT || i2s->direction == I2S_OUT_IN) {
+nrfx_buffers.p_tx_buffer = buffer->sample_data;
+}
+if (i2s->direction == I2S_IN || i2s->direction == I2S_OUT_IN) {
+nrfx_buffers.p_rx_buffer = buffer->sample_data;
+}
+
+assert(nrf52_i2s.nrfx_queued_count < 2);
+assert(nrf52_i2s.nrfx_buffers[nrf52_i2s.nrfx_queued_count] == NULL);
+
+nrf52_i2s.nrfx_buffers[nrf52_i2s.nrfx_queued_count] = buffer;
+nrf52_i2s.nrfx_queued_count++;
+if (nrf52_i2s.nrfx_queued_count == 1) {
+i2s_driver_state_changed (i2s, I2S_STATE_RUNNING);
+err = nrfx_i2s_start(&nrfx_buffers, buffer->sample_count * 
i2s->sample_size_in_bytes / 4, 0);
+} else {
+err = nrfx_i2s_next_buffers_set(&nrfx_buffers);
+}
+
+assert(err == NRFX_SUCCESS);
+}
+
+static void
+feed_nrfx(void)
+{
+struct i2s_sample_buffer *buffer;
+
+buffer = i2s_driver_buffer_get(nrf52_i2s.i2s);
+nrfx_add_buffer(nrf52_i2s.i2s, buffer);
+}
+
+static void
+nrf52_i2s_data_handler(const nrfx_i2s_buffers_t *p_released, uint32_t status)
+{
+struct i2s_sample_buffer *buffer;
+
+if (p_released != NULL &&
+(p_released->p_rx_buffer != NULL || p_released->p_tx_buffer != NULL)) {
+nrf52_i2s.nrfx_queued_count--;
+assert(nrf52_i2s.nrfx_queued_count >= 0);
+buffer = nrf52_i2s.nrfx_buffers[0];
+assert(buffer->sample_data == p_released->p_tx_buffer || 
buffer->sample_data == p_released->p_rx_buffer);
+nrf52_i2s.nrfx_buffers[0] = nrf52_i2s.nrfx_buffers[1];
+nrf52_i2s.nrfx_buffers[1] = NULL;
+i2s_driver_buffer_put(nrf52_i2s.i2s, buffer);
+}
+if (nrf52_i2s.running && nrf52_i2s.nrfx_queued_count < 2) {
+assert(nrf52_i2s.nrfx_buffers[1] == NULL);
+feed_nrfx();
+}
+if (status == NRFX_I2S_STATUS_TRANSFER_STOPPED) {
+i2s_driver_state_changed(nrf52_i2s.i2s, I2S_STATE_STOPPED);
+}
+}
+
+static int
+nrf52_i2s_init(struct i2s *i2s, const struct i2s_cfg *cfg)
+{
+int rc;
+
+nrf52_i2s.i2s = i2s;
+
+NVIC_SetVector(nrfx_get_irq_number(NRF_I2S), (uint32_t) 
nrfx_i2s_irq_handler);
+
+nrf52_i2s.nrfx_i2s_cfg = cfg->nrfx_i2s_cfg;
+switch (cfg->nrfx_i2s_cfg.sample_width) {
+case NRF_I2S_SWIDTH_8BIT:
+i2s->sample_size_in_bytes = 1;
+break;
+case NRF_I2S_SWIDTH_16BIT:
+i2s->sample_size_in_bytes = 2;
+break;
+case NRF_I2S_SWIDTH_24BIT:
+i2s->sample_size_in_bytes = 4;
+break;
+}
+
+i2s->direction = I2S_INVALID;
+if (cfg->nrfx_i2s_cfg.sdin_pin != NRFX_I2S_PIN_NOT_USED) {
+i2s->direction = I2S_IN;
+}
+if (cfg->nrfx_i2s_cfg.sdout_pin != NRFX_I2S_PIN_NOT_USED) {
+i2s->direction |= I2S_OUT;
 
 Review comment:
   while the resulting value seems fine it is a bit unclear to do that with 
enum values


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 removed a comment on issue #796: Apps: central added

2020-04-16 Thread GitBox
apache-mynewt-bot removed a comment on issue #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#issuecomment-611446715
 
 
   
   
   
   ## 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-nimble] apache-mynewt-bot commented on issue #796: Apps: central added

2020-04-16 Thread GitBox
apache-mynewt-bot commented on issue #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#issuecomment-614506014
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    apps/central/src/main.c
   
   
   ```diff
   @@ -112,7 +112,7 @@
return 0;
}
}
   -
   +
MODLOG_DFLT(INFO, "UUID ");
for (int i = 0; i < sizeof(predef_uuid); i++) {
MODLOG_DFLT(INFO, "%d, ", parsed_fields.uuids128->value[i]);
   ```
   
   


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 #796: Apps: central added

2020-04-16 Thread GitBox
apache-mynewt-bot commented on issue #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#issuecomment-614542392
 
 
   
   
   
   ## 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-nimble] apache-mynewt-bot removed a comment on issue #796: Apps: central added

2020-04-16 Thread GitBox
apache-mynewt-bot removed a comment on issue #796: Apps: central added
URL: https://github.com/apache/mynewt-nimble/pull/796#issuecomment-614506014
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    apps/central/src/main.c
   
   
   ```diff
   @@ -112,7 +112,7 @@
return 0;
}
}
   -
   +
MODLOG_DFLT(INFO, "UUID ");
for (int i = 0; i < sizeof(predef_uuid); i++) {
MODLOG_DFLT(INFO, "%d, ", parsed_fields.uuids128->value[i]);
   ```
   
   


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-04-16 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-614615008
 
 
   
   
   
   ## 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-nimble] apache-mynewt-bot removed a comment on issue #790: nimble/store: Fix nimble store behavior when CCCDs exceed static defined limit

2020-04-16 Thread GitBox
apache-mynewt-bot removed a comment 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-610780987
 
 
   
   
   
   ## 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-nimble] rymanluk commented on a change in pull request #790: nimble/store: Fix nimble store behavior when CCCDs exceed static defined limit

2020-04-16 Thread GitBox
rymanluk commented on a change in pull request #790: nimble/store: Fix nimble 
store behavior when CCCDs exceed static defined limit
URL: https://github.com/apache/mynewt-nimble/pull/790#discussion_r409499230
 
 

 ##
 File path: nimble/host/src/ble_store_util.c
 ##
 @@ -233,13 +233,15 @@ ble_store_util_status_rr(struct ble_store_status_event 
*event, void *arg)
 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:
-return ble_gap_unpair_oldest_peer();
-
-default:
-return BLE_HS_EUNKNOWN;
+case BLE_STORE_OBJ_TYPE_OUR_SEC:
+case BLE_STORE_OBJ_TYPE_PEER_SEC:
+return ble_gap_unpair_oldest_peer();
+case BLE_STORE_OBJ_TYPE_CCCD:
+/* Try unpairing oldest peer except current peer */
+return ble_gap_unpair_oldest_except((void *) 
&event->overflow.value->cccd.peer_addr);
 
 Review comment:
   nitpick: (void *) seems to be not needed here.


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] rymanluk opened a new pull request #799: nimble/host: Minor fixes around the host.

2020-04-16 Thread GitBox
rymanluk opened a new pull request #799: nimble/host: Minor fixes around the 
host.
URL: https://github.com/apache/mynewt-nimble/pull/799
 
 
   


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 #799: nimble/host: Minor fixes around the host.

2020-04-16 Thread GitBox
apache-mynewt-bot commented on issue #799: nimble/host: Minor fixes around the 
host.
URL: https://github.com/apache/mynewt-nimble/pull/799#issuecomment-614652316
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    nimble/host/src/ble_l2cap_coc.c
   
   
   ```diff
   @@ -455,7 +455,7 @@
if (rc) {
rc = BLE_HS_ENOMEM;
BLE_HS_LOG(DEBUG, "Could not append data rc=%d", rc);
   -   goto failed;
   +goto failed;
}

ble_hs_lock();
   ```
   
   


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] zacwbond commented on issue #783: Make ble_gap_rx_l2cap_update_req() behave like ble_gap_rx_param_req()

2020-04-16 Thread GitBox
zacwbond commented on issue #783: Make ble_gap_rx_l2cap_update_req() behave 
like ble_gap_rx_param_req()
URL: https://github.com/apache/mynewt-nimble/pull/783#issuecomment-614686578
 
 
   > @zacwbond Could you please add additional check as @andrzej-kaczmarek 
suggested?
   
   Got it, thanks.  I'll make the change as soon as I am able.


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-04-16 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-614727452
 
 
   
   
   
   ## 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-nimble] apache-mynewt-bot removed a comment on issue #790: nimble/store: Fix nimble store behavior when CCCDs exceed static defined limit

2020-04-16 Thread GitBox
apache-mynewt-bot removed a comment 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-614615008
 
 
   
   
   
   ## 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-nimble] apache-mynewt-bot removed a comment on issue #799: nimble/host: Minor fixes around the host.

2020-04-16 Thread GitBox
apache-mynewt-bot removed a comment on issue #799: nimble/host: Minor fixes 
around the host.
URL: https://github.com/apache/mynewt-nimble/pull/799#issuecomment-614652316
 
 
   
   
   
   ## Style check summary
   
   ### Our coding style is 
[here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
    nimble/host/src/ble_l2cap_coc.c
   
   
   ```diff
   @@ -455,7 +455,7 @@
if (rc) {
rc = BLE_HS_ENOMEM;
BLE_HS_LOG(DEBUG, "Could not append data rc=%d", rc);
   -   goto failed;
   +goto failed;
}

ble_hs_lock();
   ```
   
   


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 #799: nimble/host: Minor fixes around the host.

2020-04-16 Thread GitBox
apache-mynewt-bot commented on issue #799: nimble/host: Minor fixes around the 
host.
URL: https://github.com/apache/mynewt-nimble/pull/799#issuecomment-614869756
 
 
   
   
   
   ## 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