You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2017/03/24 23:15:23 UTC

[01/50] [abbrv] incubator-mynewt-core git commit: This closes #181. [Forced Update!]

Repository: incubator-mynewt-core
Updated Branches:
  refs/heads/nrf_cputime 96e2cd2f7 -> 34d901901 (forced update)


This closes #181.

Merge branch 'stm32f7' of https://github.com/utzig/incubator-mynewt-core into develop


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/e67144fc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/e67144fc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/e67144fc

Branch: refs/heads/nrf_cputime
Commit: e67144fc47298c5afaa989412b32f78f7f955a3a
Parents: 0759b12 35529b9
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Mar 10 11:49:02 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Mar 10 11:49:02 2017 -0800

----------------------------------------------------------------------
 compiler/arm-none-eabi-m7/compiler.yml          |     2 +-
 hw/bsp/stm32f767-nucleo/_f407.cfg               |    82 +
 .../stm32f767-nucleo/boot-stm32f767-nucleo.ld   |    30 +
 hw/bsp/stm32f767-nucleo/bsp.yml                 |    61 +
 hw/bsp/stm32f767-nucleo/include/bsp/bsp.h       |    61 +
 .../stm32f767-nucleo/include/bsp/cmsis_nvic.h   |    29 +
 .../include/bsp/stm32f7xx_hal_conf.h            |   446 +
 hw/bsp/stm32f767-nucleo/nucleo767.cfg           |    22 +
 hw/bsp/stm32f767-nucleo/nucleo767_debug.sh      |    37 +
 hw/bsp/stm32f767-nucleo/nucleo767_download.sh   |    41 +
 hw/bsp/stm32f767-nucleo/pkg.yml                 |    40 +
 .../src/arch/cortex_m7/startup_stm32f767xx.s    |   652 +
 hw/bsp/stm32f767-nucleo/src/hal_bsp.c           |   133 +
 hw/bsp/stm32f767-nucleo/src/sbrk.c              |    50 +
 hw/bsp/stm32f767-nucleo/src/system_stm32f7xx.c  |   277 +
 hw/bsp/stm32f767-nucleo/stm32f767-nucleo.ld     |    32 +
 hw/bsp/stm32f767-nucleo/syscfg.yml              |    38 +
 hw/mcu/stm/stm32f7xx/include/mcu/cortex_m7.h    |    35 +
 hw/mcu/stm/stm32f7xx/include/mcu/mcu.h          |    48 +
 hw/mcu/stm/stm32f7xx/include/mcu/stm32f7_bsp.h  |    55 +
 .../include/mcu/stm32f7xx_mynewt_hal.h          |    74 +
 hw/mcu/stm/stm32f7xx/pkg.yml                    |    40 +
 .../Device/ST/STM32F7xx/Include/stm32f722xx.h   | 15165 ++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f723xx.h   | 15244 ++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f732xx.h   | 15390 ++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f733xx.h   | 15469 ++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f745xx.h   | 17219 +++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f746xx.h   | 17569 +++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f756xx.h   | 17856 +++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f765xx.h   | 17938 ++++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f767xx.h   | 18599 ++++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f769xx.h   | 21769 ++++++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f777xx.h   | 18886 ++++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f779xx.h   | 22056 +++++++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f7xx.h     |   230 +
 .../ST/STM32F7xx/Include/system_stm32f7xx.h     |   125 +
 .../Device/ST/STM32F7xx/Release_Notes.html      |   191 +
 .../Source/Templates/arm/startup_stm32f722xx.s  |   463 +
 .../Source/Templates/arm/startup_stm32f723xx.s  |   463 +
 .../Source/Templates/arm/startup_stm32f732xx.s  |   465 +
 .../Source/Templates/arm/startup_stm32f733xx.s  |   465 +
 .../Source/Templates/arm/startup_stm32f745xx.s  |   481 +
 .../Source/Templates/arm/startup_stm32f746xx.s  |   485 +
 .../Source/Templates/arm/startup_stm32f756xx.s  |   487 +
 .../Source/Templates/arm/startup_stm32f765xx.s  |   513 +
 .../Source/Templates/arm/startup_stm32f767xx.s  |   519 +
 .../Source/Templates/arm/startup_stm32f769xx.s  |   521 +
 .../Source/Templates/arm/startup_stm32f777xx.s  |   521 +
 .../Source/Templates/arm/startup_stm32f779xx.s  |   523 +
 .../Source/Templates/gcc/startup_stm32f722xx.s  |   555 +
 .../Source/Templates/gcc/startup_stm32f723xx.s  |   555 +
 .../Source/Templates/gcc/startup_stm32f732xx.s  |   558 +
 .../Source/Templates/gcc/startup_stm32f733xx.s  |   558 +
 .../Source/Templates/gcc/startup_stm32f745xx.s  |   585 +
 .../Source/Templates/gcc/startup_stm32f746xx.s  |   591 +
 .../Source/Templates/gcc/startup_stm32f756xx.s  |   594 +
 .../Source/Templates/gcc/startup_stm32f765xx.s  |   627 +
 .../Source/Templates/gcc/startup_stm32f767xx.s  |   636 +
 .../Source/Templates/gcc/startup_stm32f769xx.s  |   639 +
 .../Source/Templates/gcc/startup_stm32f777xx.s  |   639 +
 .../Source/Templates/gcc/startup_stm32f779xx.s  |   642 +
 .../iar/linker/stm32f722xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f722xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f722xx_sram.icf   |    34 +
 .../iar/linker/stm32f723xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f723xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f723xx_sram.icf   |    34 +
 .../iar/linker/stm32f732xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f732xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f732xx_sram.icf   |    34 +
 .../iar/linker/stm32f733xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f733xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f733xx_sram.icf   |    34 +
 .../iar/linker/stm32f745xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f745xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f745xx_sram.icf   |    34 +
 .../iar/linker/stm32f746xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f746xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f746xx_sram.icf   |    34 +
 .../iar/linker/stm32f756xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f756xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f756xx_sram.icf   |    34 +
 .../iar/linker/stm32f765xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f765xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f765xx_sram.icf   |    34 +
 .../iar/linker/stm32f767xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f767xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f767xx_sram.icf   |    34 +
 .../iar/linker/stm32f769xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f769xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f769xx_sram.icf   |    34 +
 .../iar/linker/stm32f777xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f777xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f777xx_sram.icf   |    34 +
 .../iar/linker/stm32f779xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f779xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f779xx_sram.icf   |    34 +
 .../Source/Templates/iar/startup_stm32f722xx.s  |   668 +
 .../Source/Templates/iar/startup_stm32f723xx.s  |   668 +
 .../Source/Templates/iar/startup_stm32f732xx.s  |   673 +
 .../Source/Templates/iar/startup_stm32f733xx.s  |   673 +
 .../Source/Templates/iar/startup_stm32f745xx.s  |   722 +
 .../Source/Templates/iar/startup_stm32f746xx.s  |   732 +
 .../Source/Templates/iar/startup_stm32f756xx.s  |   737 +
 .../Source/Templates/iar/startup_stm32f765xx.s  |   784 +
 .../Source/Templates/iar/startup_stm32f767xx.s  |   799 +
 .../Source/Templates/iar/startup_stm32f769xx.s  |   804 +
 .../Source/Templates/iar/startup_stm32f777xx.s  |   804 +
 .../Source/Templates/iar/startup_stm32f779xx.s  |   809 +
 .../Source/Templates/system_stm32f7xx.c         |   280 +
 .../Inc/Legacy/stm32_hal_legacy.h               |  3158 +++
 .../Inc/stm32_assert_template.h                 |    75 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal.h    |   253 +
 .../Inc/stm32f7xx_hal_adc.h                     |   915 +
 .../Inc/stm32f7xx_hal_adc_ex.h                  |   379 +
 .../Inc/stm32f7xx_hal_can.h                     |   768 +
 .../Inc/stm32f7xx_hal_cec.h                     |   751 +
 .../Inc/stm32f7xx_hal_conf_template.h           |   464 +
 .../Inc/stm32f7xx_hal_cortex.h                  |   424 +
 .../Inc/stm32f7xx_hal_crc.h                     |   423 +
 .../Inc/stm32f7xx_hal_crc_ex.h                  |   168 +
 .../Inc/stm32f7xx_hal_cryp.h                    |  1168 +
 .../Inc/stm32f7xx_hal_cryp_ex.h                 |   293 +
 .../Inc/stm32f7xx_hal_dac.h                     |   408 +
 .../Inc/stm32f7xx_hal_dac_ex.h                  |   191 +
 .../Inc/stm32f7xx_hal_dcmi.h                    |   628 +
 .../Inc/stm32f7xx_hal_dcmi_ex.h                 |    55 +
 .../Inc/stm32f7xx_hal_def.h                     |   213 +
 .../Inc/stm32f7xx_hal_dfsdm.h                   |   710 +
 .../Inc/stm32f7xx_hal_dma.h                     |   768 +
 .../Inc/stm32f7xx_hal_dma2d.h                   |   638 +
 .../Inc/stm32f7xx_hal_dma_ex.h                  |   203 +
 .../Inc/stm32f7xx_hal_dsi.h                     |  1242 +
 .../Inc/stm32f7xx_hal_eth.h                     |  2184 ++
 .../Inc/stm32f7xx_hal_flash.h                   |   426 +
 .../Inc/stm32f7xx_hal_flash_ex.h                |   663 +
 .../Inc/stm32f7xx_hal_gpio.h                    |   327 +
 .../Inc/stm32f7xx_hal_gpio_ex.h                 |   675 +
 .../Inc/stm32f7xx_hal_hash.h                    |   450 +
 .../Inc/stm32f7xx_hal_hash_ex.h                 |   199 +
 .../Inc/stm32f7xx_hal_hcd.h                     |   281 +
 .../Inc/stm32f7xx_hal_i2c.h                     |   710 +
 .../Inc/stm32f7xx_hal_i2c_ex.h                  |   223 +
 .../Inc/stm32f7xx_hal_i2s.h                     |   483 +
 .../Inc/stm32f7xx_hal_irda.h                    |   760 +
 .../Inc/stm32f7xx_hal_irda_ex.h                 |   239 +
 .../Inc/stm32f7xx_hal_iwdg.h                    |   257 +
 .../Inc/stm32f7xx_hal_jpeg.h                    |   581 +
 .../Inc/stm32f7xx_hal_lptim.h                   |   739 +
 .../Inc/stm32f7xx_hal_ltdc.h                    |   662 +
 .../Inc/stm32f7xx_hal_ltdc_ex.h                 |   151 +
 .../Inc/stm32f7xx_hal_mdios.h                   |   537 +
 .../Inc/stm32f7xx_hal_mmc.h                     |   695 +
 .../Inc/stm32f7xx_hal_nand.h                    |   336 +
 .../Inc/stm32f7xx_hal_nor.h                     |   299 +
 .../Inc/stm32f7xx_hal_pcd.h                     |   337 +
 .../Inc/stm32f7xx_hal_pcd_ex.h                  |   116 +
 .../Inc/stm32f7xx_hal_pwr.h                     |   422 +
 .../Inc/stm32f7xx_hal_pwr_ex.h                  |   280 +
 .../Inc/stm32f7xx_hal_qspi.h                    |   781 +
 .../Inc/stm32f7xx_hal_rcc.h                     |  1306 +
 .../Inc/stm32f7xx_hal_rcc_ex.h                  |  3519 +++
 .../Inc/stm32f7xx_hal_rng.h                     |   358 +
 .../Inc/stm32f7xx_hal_rtc.h                     |   813 +
 .../Inc/stm32f7xx_hal_rtc_ex.h                  |  1035 +
 .../Inc/stm32f7xx_hal_sai.h                     |   850 +
 .../Inc/stm32f7xx_hal_sai_ex.h                  |    56 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_sd.h |   716 +
 .../Inc/stm32f7xx_hal_sdram.h                   |   199 +
 .../Inc/stm32f7xx_hal_smartcard.h               |   949 +
 .../Inc/stm32f7xx_hal_smartcard_ex.h            |   308 +
 .../Inc/stm32f7xx_hal_smbus.h                   |   697 +
 .../Inc/stm32f7xx_hal_spdifrx.h                 |   560 +
 .../Inc/stm32f7xx_hal_spi.h                     |   689 +
 .../Inc/stm32f7xx_hal_sram.h                    |   195 +
 .../Inc/stm32f7xx_hal_tim.h                     |  1563 ++
 .../Inc/stm32f7xx_hal_tim_ex.h                  |   648 +
 .../Inc/stm32f7xx_hal_uart.h                    |  1221 +
 .../Inc/stm32f7xx_hal_uart_ex.h                 |   365 +
 .../Inc/stm32f7xx_hal_usart.h                   |   696 +
 .../Inc/stm32f7xx_hal_usart_ex.h                |   158 +
 .../Inc/stm32f7xx_hal_wwdg.h                    |   285 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_adc.h |  4767 ++++
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_bus.h |  1994 ++
 .../Inc/stm32f7xx_ll_cortex.h                   |   657 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_crc.h |   479 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_dac.h |  1316 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_dma.h |  2911 +++
 .../Inc/stm32f7xx_ll_dma2d.h                    |  2070 ++
 .../Inc/stm32f7xx_ll_exti.h                     |   968 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_fmc.h |  1339 +
 .../Inc/stm32f7xx_ll_gpio.h                     |  1000 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_i2c.h |  2207 ++
 .../Inc/stm32f7xx_ll_iwdg.h                     |   363 +
 .../Inc/stm32f7xx_ll_lptim.h                    |  1382 ++
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_pwr.h |  1036 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_rcc.h |  5170 ++++
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_rng.h |   355 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_rtc.h |  3867 +++
 .../Inc/stm32f7xx_ll_sdmmc.h                    |  1024 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_spi.h |  2293 ++
 .../Inc/stm32f7xx_ll_system.h                   |  1039 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_tim.h |  4663 ++++
 .../Inc/stm32f7xx_ll_usart.h                    |  3560 +++
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_usb.h |   474 +
 .../Inc/stm32f7xx_ll_utils.h                    |   323 +
 .../Inc/stm32f7xx_ll_wwdg.h                     |   342 +
 .../STM32F7xx_HAL_Driver/Release_Notes.html     |  1028 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.c    |   536 +
 .../Src/stm32f7xx_hal_adc.c                     |  1686 ++
 .../Src/stm32f7xx_hal_adc_ex.c                  |  1069 +
 .../Src/stm32f7xx_hal_can.c                     |  1412 ++
 .../Src/stm32f7xx_hal_cec.c                     |   670 +
 .../Src/stm32f7xx_hal_cortex.c                  |   523 +
 .../Src/stm32f7xx_hal_crc.c                     |   531 +
 .../Src/stm32f7xx_hal_crc_ex.c                  |   242 +
 .../Src/stm32f7xx_hal_cryp.c                    |  5182 ++++
 .../Src/stm32f7xx_hal_cryp_ex.c                 |  6039 +++++
 .../Src/stm32f7xx_hal_dac.c                     |   967 +
 .../Src/stm32f7xx_hal_dac_ex.c                  |   388 +
 .../Src/stm32f7xx_hal_dcmi.c                    |   906 +
 .../Src/stm32f7xx_hal_dcmi_ex.c                 |    52 +
 .../Src/stm32f7xx_hal_dfsdm.c                   |  3018 +++
 .../Src/stm32f7xx_hal_dma.c                     |  1318 +
 .../Src/stm32f7xx_hal_dma2d.c                   |  1764 ++
 .../Src/stm32f7xx_hal_dma_ex.c                  |   328 +
 .../Src/stm32f7xx_hal_dsi.c                     |  2262 ++
 .../Src/stm32f7xx_hal_eth.c                     |  2045 ++
 .../Src/stm32f7xx_hal_flash.c                   |   829 +
 .../Src/stm32f7xx_hal_flash_ex.c                |  1140 +
 .../Src/stm32f7xx_hal_gpio.c                    |   543 +
 .../Src/stm32f7xx_hal_hash.c                    |  1878 ++
 .../Src/stm32f7xx_hal_hash_ex.c                 |  1636 ++
 .../Src/stm32f7xx_hal_hcd.c                     |  1229 +
 .../Src/stm32f7xx_hal_i2c.c                     |  4867 ++++
 .../Src/stm32f7xx_hal_i2c_ex.c                  |   275 +
 .../Src/stm32f7xx_hal_i2s.c                     |  1556 ++
 .../Src/stm32f7xx_hal_irda.c                    |  2240 ++
 .../Src/stm32f7xx_hal_iwdg.c                    |   282 +
 .../Src/stm32f7xx_hal_jpeg.c                    |  3460 +++
 .../Src/stm32f7xx_hal_lptim.c                   |  1705 ++
 .../Src/stm32f7xx_hal_ltdc.c                    |  1915 ++
 .../Src/stm32f7xx_hal_ltdc_ex.c                 |   162 +
 .../Src/stm32f7xx_hal_mdios.c                   |   627 +
 .../Src/stm32f7xx_hal_mmc.c                     |  2493 ++
 .../Src/stm32f7xx_hal_msp_template.c            |   119 +
 .../Src/stm32f7xx_hal_nand.c                    |  1859 ++
 .../Src/stm32f7xx_hal_nor.c                     |  1044 +
 .../Src/stm32f7xx_hal_pcd.c                     |  1311 +
 .../Src/stm32f7xx_hal_pcd_ex.c                  |   322 +
 .../Src/stm32f7xx_hal_pwr.c                     |   609 +
 .../Src/stm32f7xx_hal_pwr_ex.c                  |   572 +
 .../Src/stm32f7xx_hal_qspi.c                    |  2337 ++
 .../Src/stm32f7xx_hal_rcc.c                     |  1130 +
 .../Src/stm32f7xx_hal_rcc_ex.c                  |  1602 ++
 .../Src/stm32f7xx_hal_rng.c                     |   522 +
 .../Src/stm32f7xx_hal_rtc.c                     |  1567 ++
 .../Src/stm32f7xx_hal_rtc_ex.c                  |  1853 ++
 .../Src/stm32f7xx_hal_sai.c                     |  2184 ++
 .../Src/stm32f7xx_hal_sai_ex.c                  |    52 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_sd.c |  2913 +++
 .../Src/stm32f7xx_hal_sdram.c                   |   859 +
 .../Src/stm32f7xx_hal_smartcard.c               |  2282 ++
 .../Src/stm32f7xx_hal_smartcard_ex.c            |   184 +
 .../Src/stm32f7xx_hal_smbus.c                   |  2053 ++
 .../Src/stm32f7xx_hal_spdifrx.c                 |  1258 +
 .../Src/stm32f7xx_hal_spi.c                     |  3739 +++
 .../Src/stm32f7xx_hal_sram.c                    |   690 +
 .../Src/stm32f7xx_hal_tim.c                     |  5534 +++++
 .../Src/stm32f7xx_hal_tim_ex.c                  |  2565 ++
 .../stm32f7xx_hal_timebase_rtc_alarm_template.c |   314 +
 ...stm32f7xx_hal_timebase_rtc_wakeup_template.c |   293 +
 .../Src/stm32f7xx_hal_timebase_tim_template.c   |   184 +
 .../Src/stm32f7xx_hal_uart.c                    |  2174 ++
 .../Src/stm32f7xx_hal_usart.c                   |  1986 ++
 .../Src/stm32f7xx_hal_wwdg.c                    |   322 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_adc.c |   920 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_crc.c |   125 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_dac.c |   273 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_dma.c |   464 +
 .../Src/stm32f7xx_ll_dma2d.c                    |   653 +
 .../Src/stm32f7xx_ll_exti.c                     |   232 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_fmc.c |  1117 +
 .../Src/stm32f7xx_ll_gpio.c                     |   325 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_i2c.c |   258 +
 .../Src/stm32f7xx_ll_lptim.c                    |   212 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_pwr.c |   105 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_rcc.c |  1581 ++
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_rng.c |   116 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_rtc.c |   897 +
 .../Src/stm32f7xx_ll_sdmmc.c                    |  1504 ++
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_spi.c |   589 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_tim.c |  1396 ++
 .../Src/stm32f7xx_ll_usart.c                    |   463 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c |  1797 ++
 .../Src/stm32f7xx_ll_utils.c                    |   757 +
 hw/mcu/stm/stm32f7xx/src/hal_flash.c            |   141 +
 hw/mcu/stm/stm32f7xx/src/hal_gpio.c             |   715 +
 hw/mcu/stm/stm32f7xx/src/hal_i2c.c              |   177 +
 hw/mcu/stm/stm32f7xx/src/hal_os_tick.c          |    55 +
 hw/mcu/stm/stm32f7xx/src/hal_reset_cause.c      |    47 +
 hw/mcu/stm/stm32f7xx/src/hal_system.c           |    55 +
 hw/mcu/stm/stm32f7xx/src/hal_system_start.c     |    54 +
 hw/mcu/stm/stm32f7xx/src/hal_timer.c            |   648 +
 hw/mcu/stm/stm32f7xx/src/hal_uart.c             |   428 +
 hw/mcu/stm/stm32f7xx/src/hal_watchdog.c         |    59 +
 hw/mcu/stm/stm32f7xx/src/stm32f7xx_hw_id.c      |    42 +
 hw/mcu/stm/stm32f7xx/stm32f767.ld               |   212 +
 hw/scripts/common.sh                            |     7 +-
 hw/scripts/openocd.sh                           |    64 +-
 .../os/include/os/arch/cortex_m7/os/os_arch.h   |    84 +
 kernel/os/src/arch/cortex_m7/m7/HAL_CM7.s       |   240 +
 kernel/os/src/arch/cortex_m7/m7/SVC_Table.s     |    56 +
 kernel/os/src/arch/cortex_m7/os_arch_arm.c      |   352 +
 kernel/os/src/arch/cortex_m7/os_fault.c         |   176 +
 315 files changed, 450953 insertions(+), 37 deletions(-)
----------------------------------------------------------------------



[04/50] [abbrv] incubator-mynewt-core git commit: scripts; pathnames need to be converted when calling cmd.exe. CMDSPEC not set when using win-bash.

Posted by we...@apache.org.
scripts; pathnames need to be converted when calling cmd.exe.
CMDSPEC not set when using win-bash.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/567a360f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/567a360f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/567a360f

Branch: refs/heads/nrf_cputime
Commit: 567a360fe0c4eb8f0d5d1c15585b6805e3559c27
Parents: 56444ed
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Sat Mar 4 19:07:48 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Mar 10 13:10:53 2017 -0800

----------------------------------------------------------------------
 hw/scripts/common.sh  | 15 +++++++++++++++
 hw/scripts/jlink.sh   | 30 +++++++++++++-----------------
 hw/scripts/openocd.sh | 16 ++++++++--------
 3 files changed, 36 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/567a360f/hw/scripts/common.sh
----------------------------------------------------------------------
diff --git a/hw/scripts/common.sh b/hw/scripts/common.sh
index 06b6f2b..ee85a90 100644
--- a/hw/scripts/common.sh
+++ b/hw/scripts/common.sh
@@ -28,3 +28,18 @@ common_file_to_load () {
         FILE_NAME=$BIN_BASENAME.img
     fi
 }
+
+#
+# Check if this is executing in Windows. If so, set variable WINDOWS to 1.
+# Also check if $COMSPEC is set or not.
+#
+windows_detect() {
+    BUILD_OS=`uname`
+    WINDOWS=0
+    if [ $BUILD_OS = "Windows_NT" ]; then
+	WINDOWS=1
+    fi
+    if [ $WINDOWS -eq 1 -a -z "$COMSPEC" ]; then
+	COMSPEC=cmd.exe
+    fi
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/567a360f/hw/scripts/jlink.sh
----------------------------------------------------------------------
diff --git a/hw/scripts/jlink.sh b/hw/scripts/jlink.sh
index 2f3fbe8..7b35017 100644
--- a/hw/scripts/jlink.sh
+++ b/hw/scripts/jlink.sh
@@ -17,15 +17,6 @@
 
 . $CORE_PATH/hw/scripts/common.sh
 
-if which JLinkGDBServerCL >/dev/null 2>&1; then
-  JLINK_GDB_SERVER=JLinkGDBServerCL
-elif which JLinkGDBServer >/dev/null 2>&1; then
-  JLINK_GDB_SERVER=JLinkGDBServer
-else
-  echo "Cannot find JLinkGDBServer, make sure J-Link tools are in your PATH"
-  exit 1
-fi
-
 #
 # FILE_NAME is the file to load
 # FLASH_OFFSET is location in the flash
@@ -35,6 +26,10 @@ jlink_load () {
     GDB_CMD_FILE=.gdb_cmds
     GDB_OUT_FILE=.gdb_out
 
+    windows_detect
+    if [ $WINDOWS -eq 1 ]; then
+	JLINK_GDB_SERVER=JLinkGDBServerCL
+    fi
     if [ -z $FILE_NAME ]; then
         echo "Missing filename"
         exit 1
@@ -104,6 +99,11 @@ jlink_load () {
 # RESET is set if we should reset the target at attach time
 #
 jlink_debug() {
+    windows_detect
+    if [ $WINDOWS -eq 1 ]; then
+	JLINK_GDB_SERVER=JLinkGDBServerCL
+    fi
+
     if [ -z "$NO_GDB" ]; then
         GDB_CMD_FILE=.gdb_cmds
 
@@ -118,12 +118,12 @@ jlink_debug() {
 
         echo "Debugging" $FILE_NAME
 
-        if [ -x "$COMSPEC" ]; then
+        if [ $WINDOWS -eq 1 ]; then
             #
             # Launch jlink server in a separate command interpreter, to make
             # sure it doesn't get killed by Ctrl-C signal from bash.
             #
-            $COMSPEC /C "start $COMSPEC /C $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun"
+            $COMSPEC "/C start $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun"
         else
             #
             # Block Ctrl-C from getting passed to jlink server.
@@ -141,12 +141,8 @@ jlink_debug() {
         fi
         echo "$EXTRA_GDB_CMDS" >> $GDB_CMD_FILE
 
-        if [ -x "$COMSPEC" ]; then
-            $COMSPEC /C "start $COMSPEC /C arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME"
-        else
-            arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
-            rm $GDB_CMD_FILE
-        fi
+        arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
+        rm $GDB_CMD_FILE
     else
         $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun
     fi

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/567a360f/hw/scripts/openocd.sh
----------------------------------------------------------------------
diff --git a/hw/scripts/openocd.sh b/hw/scripts/openocd.sh
index e838bcd..a20e451 100644
--- a/hw/scripts/openocd.sh
+++ b/hw/scripts/openocd.sh
@@ -62,6 +62,8 @@ openocd_load () {
 openocd_debug () {
     OCD_CMD_FILE=.openocd_cmds
 
+    windows_detect
+
     echo "gdb_port 3333" > $OCD_CMD_FILE
     echo "telnet_port 4444" >> $OCD_CMD_FILE
     echo "$EXTRA_JTAG_CMD" >> $OCD_CMD_FILE
@@ -76,12 +78,14 @@ openocd_debug () {
             exit 1
         fi
 
-        if [ -x "$COMSPEC" ]; then
+        if [ $WINDOWS -eq 1 ]; then
             #
             # Launch openocd in a separate command interpreter, to make sure
             # it doesn't get killed by Ctrl-C signal from bash.
             #
-            $COMSPEC /C "start $COMSPEC /C openocd $CFG -f $OCD_CMD_FILE -c init -c halt"
+            CFG=`echo $CFG | sed 's/\//\\\\/g'`
+            echo $CFG
+            $COMSPEC "/C start openocd openocd $CFG -f $OCD_CMD_FILE -c init -c halt"
         else
             #
             # Block Ctrl-C from getting passed to openocd.
@@ -97,12 +101,8 @@ openocd_debug () {
         if [ ! -z "$RESET" ]; then
             echo "mon reset halt" >> $GDB_CMD_FILE
         fi
-        if [ -x "$COMSPEC" ]; then
-            $COMSPEC /C "start $COMSPEC /C arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME"
-        else
-            arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
-            rm $GDB_CMD_FILE
-        fi
+        arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
+        rm $GDB_CMD_FILE
     else
         # No GDB, wait for openocd to exit
         openocd $CFG -f $OCD_CMD_FILE -c init -c halt


[50/50] [abbrv] incubator-mynewt-core git commit: Low power timer. Only nrf52 right now.

Posted by we...@apache.org.
Low power timer. Only nrf52 right now.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/34d90190
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/34d90190
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/34d90190

Branch: refs/heads/nrf_cputime
Commit: 34d901901a40adefa587ab92f6e8727d03a9cdc0
Parents: e888457
Author: William San Filippo <wi...@runtime.io>
Authored: Thu Feb 16 16:12:39 2017 -0800
Committer: William San Filippo <wi...@runtime.io>
Committed: Fri Mar 24 16:14:47 2017 -0700

----------------------------------------------------------------------
 apps/bletest/src/main.c                         |   2 +-
 hw/drivers/nimble/nrf52/include/ble/xcvr.h      |  12 +-
 hw/drivers/nimble/nrf52/src/ble_phy.c           | 438 +++++++++++++++++--
 kernel/os/include/os/os_cputime.h               |   8 +
 kernel/os/src/os_cputime.c                      |  50 +++
 .../controller/include/controller/ble_ll.h      |  51 ++-
 .../controller/include/controller/ble_ll_conn.h |   5 +
 .../include/controller/ble_ll_sched.h           |  32 +-
 .../controller/include/controller/ble_ll_xcvr.h |  48 ++
 .../controller/include/controller/ble_phy.h     |  31 +-
 net/nimble/controller/src/ble_ll.c              |  37 ++
 net/nimble/controller/src/ble_ll_adv.c          |  86 +++-
 net/nimble/controller/src/ble_ll_conn.c         | 263 +++++++++--
 net/nimble/controller/src/ble_ll_conn_priv.h    |   3 +-
 net/nimble/controller/src/ble_ll_scan.c         | 145 +++++-
 net/nimble/controller/src/ble_ll_sched.c        | 354 +++++++++++----
 net/nimble/controller/src/ble_ll_xcvr.c         | 153 +++++++
 net/nimble/controller/syscfg.yml                |   8 +
 net/nimble/host/src/ble_hs_hci_evt.c            |   6 +-
 net/nimble/include/nimble/ble.h                 |   3 +
 20 files changed, 1531 insertions(+), 204 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/apps/bletest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletest/src/main.c b/apps/bletest/src/main.c
index e2519eb..efb3fd4 100755
--- a/apps/bletest/src/main.c
+++ b/apps/bletest/src/main.c
@@ -172,7 +172,7 @@ bletest_multi_adv_instances[BLETEST_CFG_ADV_TEST_INSTANCES] = {
 #define BLETEST_CFG_MAX_CE_LEN          (BLETEST_CFG_CONN_ITVL)
 #define BLETEST_CFG_CONN_PEER_ADDR_TYPE (BLE_HCI_CONN_PEER_ADDR_PUBLIC)
 #define BLETEST_CFG_CONN_OWN_ADDR_TYPE  (BLE_HCI_ADV_OWN_ADDR_PUBLIC)
-#define BLETEST_CFG_CONCURRENT_CONNS    (1)
+#define BLETEST_CFG_CONCURRENT_CONNS    (8)
 
 /* Test packet config */
 #define BLETEST_CFG_RAND_PKT_SIZE       (1)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/hw/drivers/nimble/nrf52/include/ble/xcvr.h
----------------------------------------------------------------------
diff --git a/hw/drivers/nimble/nrf52/include/ble/xcvr.h b/hw/drivers/nimble/nrf52/include/ble/xcvr.h
index 6a35124..2b6d7ea 100644
--- a/hw/drivers/nimble/nrf52/include/ble/xcvr.h
+++ b/hw/drivers/nimble/nrf52/include/ble/xcvr.h
@@ -24,10 +24,18 @@
 extern "C" {
 #endif
 
-/* Transceiver specific definitions */
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+/*
+ * NOTE: we have to account for the RTC output compare issue, which is why
+ * this number is much larger when using the 32.768 crystal for cputime. We
+ * want it to be 5 ticks.
+ */
+#define XCVR_PROC_DELAY_USECS         (153)
+#else
+#define XCVR_PROC_DELAY_USECS         (50)
+#endif
 #define XCVR_RX_START_DELAY_USECS     (140)
 #define XCVR_TX_START_DELAY_USECS     (140)
-#define XCVR_PROC_DELAY_USECS         (50)
 #define XCVR_TX_SCHED_DELAY_USECS     \
     (XCVR_TX_START_DELAY_USECS + XCVR_PROC_DELAY_USECS)
 #define XCVR_RX_SCHED_DELAY_USECS     \

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/hw/drivers/nimble/nrf52/src/ble_phy.c
----------------------------------------------------------------------
diff --git a/hw/drivers/nimble/nrf52/src/ble_phy.c b/hw/drivers/nimble/nrf52/src/ble_phy.c
index 8771f49..8d8b0e1 100644
--- a/hw/drivers/nimble/nrf52/src/ble_phy.c
+++ b/hw/drivers/nimble/nrf52/src/ble_phy.c
@@ -78,6 +78,9 @@ struct ble_phy_obj
     struct ble_mbuf_hdr rxhdr;
     void *txend_arg;
     ble_phy_tx_end_func txend_cb;
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    uint32_t phy_start_cputime;
+#endif
 };
 struct ble_phy_obj g_ble_phy_data;
 
@@ -280,6 +283,133 @@ nrf_wait_disabled(void)
     }
 }
 
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+/**
+ *
+ *
+ */
+int
+ble_phy_set_start_time(uint32_t cputime, uint8_t rem_usecs)
+{
+    uint32_t next_cc;
+    uint32_t cur_cc;
+    uint32_t cntr;
+    uint32_t delta;
+
+    /*
+     * XXX: The TXEN time is 140 usecs but there may be additional delays
+     * Need to look at this.
+     */
+
+    /*
+     * With the 32.768 kHz crystal, we may need to adjust the RTC compare
+     * value by 1 tick due to the time it takes for TXEN. The code uses a 5 RTC
+     * tick offset, which is 152.5 usecs. The TXEN time is 140 usecs. This
+     * means that with a remainder of 0, TIMER0 should be set to 12 or 13 (as
+     * TIMER0 counts at 1MHz). A remainder of 19 or more we will need to add
+     * 1 tick. We dont need to add 1 tick per se, but it does give us slightly
+     * more time and thus less of a chance to miss a tick. Another note: we
+     * cant set TIMER0 CC to 0 as the compare wont occur; it must be 1 or more.
+     * This is why we subtract 18 (as opposed to 19) as rem_uses will be >= 1.
+     */
+    if (rem_usecs <= 18) {
+        cputime -= 5;
+        rem_usecs += 12;
+    } else {
+        cputime -= 4;
+        rem_usecs -= 18;
+    }
+
+    /*
+     * Can we set the RTC compare to start TIMER0? We can do it if:
+     *      a) Current compare value is not N+1 or N+2 ticks from current
+     *      counter.
+     *      b) The value we want to set is not at least N+2 from current
+     *      counter.
+     *
+     * NOTE: since the counter can tick 1 while we do these calculations we
+     * need to account for it.
+     */
+    next_cc = cputime & 0xffffff;
+    cur_cc = NRF_RTC0->CC[0];
+    cntr = NRF_RTC0->COUNTER;
+
+    delta = (cur_cc - cntr) & 0xffffff;
+    if ((delta <= 3) && (delta != 0)) {
+        return -1;
+    }
+    delta = (next_cc - cntr) & 0xffffff;
+    if ((delta & 0x800000) || (delta < 3)) {
+        return -1;
+    }
+
+    /* Clear and set TIMER0 to fire off at proper time */
+    NRF_TIMER0->TASKS_CLEAR = 1;
+    NRF_TIMER0->CC[0] = rem_usecs;
+    NRF_TIMER0->EVENTS_COMPARE[0] = 0;
+
+    /* Set RTC compare to start TIMER0 */
+    NRF_RTC0->EVENTS_COMPARE[0] = 0;
+    NRF_RTC0->CC[0] = next_cc;
+    NRF_RTC0->EVTENSET = RTC_EVTENSET_COMPARE0_Msk;
+
+    /* Enable PPI */
+    NRF_PPI->CHENSET = PPI_CHEN_CH31_Msk;
+
+    /* Store the cputime at which we set the RTC */
+    g_ble_phy_data.phy_start_cputime = cputime;
+
+    return 0;
+}
+
+/**
+ * Function is used to set PPI so that we can time out waiting for a reception
+ * to occur. This happens for two reasons: we have sent a packet and we are
+ * waiting for a respons (txrx should be set to ENABLE_TXRX) or we are
+ * starting a connection event and we are a slave and we are waiting for the
+ * master to send us a packet (txrx should be set to ENABLE_RX).
+ *
+ * NOTE: when waiting for a txrx turn-around, wfr_usecs is not used as there
+ * is no additional time to wait; we know when we should receive the address of
+ * the received frame.
+ *
+ * @param txrx Flag denoting if this wfr is a txrx turn-around or not.
+ * @param wfr_usecs Amount of usecs to wait.
+ */
+void
+ble_phy_wfr_enable(int txrx, uint32_t wfr_usecs)
+{
+    uint32_t end_time;
+
+    if (txrx == BLE_PHY_WFR_ENABLE_TXRX) {
+        /*
+         * Timeout occurs an IFS time plus time it takes to receive address
+         * from the transmit end. We add additional time to make sure the
+         * address event comes before the compare. Note that transmit end
+         * is captured in CC[2]
+         *
+         * XXX: this assumes 1Mbps as 40 usecs is header rx time for 1Mbps
+         */
+        end_time = NRF_TIMER0->CC[2] + BLE_LL_IFS + 40 + 16;
+    } else {
+        /* CC[0] is set to when RXEN occurs. NOTE: the extra 16 usecs is
+           jitter */
+        end_time = NRF_TIMER0->CC[0] + XCVR_RX_START_DELAY_USECS + wfr_usecs +
+            40 + 16;
+    }
+
+    /* wfr_secs is the time from rxen until timeout */
+    NRF_TIMER0->CC[3] = end_time;
+    NRF_TIMER0->EVENTS_COMPARE[3] = 0;
+
+    /* Enable wait for response PPI */
+    NRF_PPI->CHENSET = (PPI_CHEN_CH4_Msk | PPI_CHEN_CH5_Msk);
+
+    /* Enable the disabled interrupt so we time out on events compare */
+    NRF_RADIO->INTENSET = RADIO_INTENSET_DISABLED_Msk;
+}
+#endif
+
 /**
  * Setup transceiver for receive.
  */
@@ -360,14 +490,18 @@ ble_phy_tx_end_isr(void)
     uint8_t transition;
     uint8_t txlen;
     uint32_t wfr_time;
+#if (MYNEWT_VAL(OS_CPUTIME_FREQ) != 32768)
     uint32_t txstart;
+#endif
 
+#if (MYNEWT_VAL(OS_CPUTIME_FREQ) != 32768)
     /*
      * Read captured tx start time. This is not the actual transmit start
      * time but it is the time at which the address event occurred
      * (after transmission of access address)
      */
     txstart = NRF_TIMER0->CC[1];
+#endif
 
     /* If this transmission was encrypted we need to remember it */
     was_encrypted = g_ble_phy_data.phy_encrypted;
@@ -376,14 +510,20 @@ ble_phy_tx_end_isr(void)
     assert(g_ble_phy_data.phy_state == BLE_PHY_STATE_TX);
 
     /* Log the event */
+#if (MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768)
+    ble_ll_log(BLE_LL_LOG_ID_PHY_TXEND, g_ble_phy_data.phy_tx_pyld_len,
+               was_encrypted, NRF_TIMER0->CC[2]);
+#else
     ble_ll_log(BLE_LL_LOG_ID_PHY_TXEND, g_ble_phy_data.phy_tx_pyld_len,
                was_encrypted, txstart);
+#endif
 
     /* Clear events and clear interrupt on disabled event */
     NRF_RADIO->EVENTS_DISABLED = 0;
     NRF_RADIO->INTENCLR = RADIO_INTENCLR_DISABLED_Msk;
     NRF_RADIO->EVENTS_END = 0;
     wfr_time = NRF_RADIO->SHORTS;
+    (void)wfr_time;
 
 #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
     /*
@@ -416,13 +556,28 @@ ble_phy_tx_end_isr(void)
         if (txlen && was_encrypted) {
             txlen += BLE_LL_DATA_MIC_LEN;
         }
+#if (MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768)
+        ble_phy_wfr_enable(BLE_PHY_WFR_ENABLE_TXRX, 0);
+#else
         wfr_time = BLE_LL_WFR_USECS - BLE_TX_LEN_USECS_M(NRF_RX_START_OFFSET);
         wfr_time += BLE_TX_DUR_USECS_M(txlen);
         wfr_time = os_cputime_usecs_to_ticks(wfr_time);
         ble_ll_wfr_enable(txstart + wfr_time);
+#endif
     } else {
+#if (MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768)
+        /*
+         * XXX: not sure we need to stop the timer here all the time. Or that
+         * it should be stopped here.
+         */
+        NRF_TIMER0->TASKS_STOP = 1;
+        NRF_TIMER0->TASKS_SHUTDOWN = 1;
+        NRF_PPI->CHENCLR = PPI_CHEN_CH4_Msk | PPI_CHEN_CH5_Msk |
+                           PPI_CHEN_CH20_Msk | PPI_CHEN_CH31_Msk;
+#else
         /* Disable automatic TXEN */
         NRF_PPI->CHENCLR = PPI_CHEN_CH20_Msk;
+#endif
         assert(transition == BLE_PHY_TRANSITION_NONE);
     }
 }
@@ -506,12 +661,48 @@ ble_phy_rx_start_isr(void)
 {
     int rc;
     uint32_t state;
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    uint32_t usecs;
+    uint32_t ticks;
+#endif
     struct ble_mbuf_hdr *ble_hdr;
 
     /* Clear events and clear interrupt */
     NRF_RADIO->EVENTS_ADDRESS = 0;
+
+    /* Clear wfr timer channels and DISABLED interrupt */
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    NRF_RADIO->INTENCLR = RADIO_INTENCLR_DISABLED_Msk | RADIO_INTENCLR_ADDRESS_Msk;
+    NRF_PPI->CHENCLR = PPI_CHEN_CH4_Msk | PPI_CHEN_CH5_Msk;
+#else
     NRF_RADIO->INTENCLR = RADIO_INTENCLR_ADDRESS_Msk;
+#endif
 
+    /* Initialize the ble mbuf header */
+    ble_hdr = &g_ble_phy_data.rxhdr;
+    ble_hdr->rxinfo.flags = ble_ll_state_get();
+    ble_hdr->rxinfo.channel = g_ble_phy_data.phy_chan;
+    ble_hdr->rxinfo.handle = 0;
+
+#if (MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768)
+    /*
+     * Calculate receive start time. We assume that the header time is
+     * 40 usecs (only 1 mbps supported right now).
+     *
+     * XXX: possibly use other routine with remainder!
+     */
+    usecs = NRF_TIMER0->CC[1] - 40;
+    ticks = os_cputime_usecs_to_ticks(usecs);
+    ble_hdr->rem_usecs = usecs - os_cputime_ticks_to_usecs(ticks);
+    ble_hdr->beg_cputime = g_ble_phy_data.phy_start_cputime + ticks;
+#else
+    ble_hdr->beg_cputime = NRF_TIMER0->CC[1] -
+        os_cputime_usecs_to_ticks(BLE_TX_LEN_USECS_M(NRF_RX_START_OFFSET));
+#endif
+
+    /* XXX: I wonder if we always have the 1st byte. If we need to wait for
+     * rx chain delay, it could be 18 usecs from address interrupt. The
+       nrf52 may be able to get here early. */
     /* Wait to get 1st byte of frame */
     while (1) {
         state = NRF_RADIO->STATE;
@@ -530,14 +721,6 @@ ble_phy_rx_start_isr(void)
         }
     }
 
-    /* Initialize flags, channel and state in ble header at rx start */
-    ble_hdr = &g_ble_phy_data.rxhdr;
-    ble_hdr->rxinfo.flags = ble_ll_state_get();
-    ble_hdr->rxinfo.channel = g_ble_phy_data.phy_chan;
-    ble_hdr->rxinfo.handle = 0;
-    ble_hdr->beg_cputime = NRF_TIMER0->CC[1] -
-        os_cputime_usecs_to_ticks(BLE_TX_LEN_USECS_M(NRF_RX_START_OFFSET));
-
     /* Call Link Layer receive start function */
     rc = ble_ll_rx_start((uint8_t *)&g_ble_phy_rx_buf[0] + 3,
                          g_ble_phy_data.phy_chan,
@@ -573,16 +756,34 @@ ble_phy_isr(void)
     /* Read irq register to determine which interrupts are enabled */
     irq_en = NRF_RADIO->INTENCLR;
 
-    /* Check for disabled event. This only happens for transmits now */
-    if ((irq_en & RADIO_INTENCLR_DISABLED_Msk) && NRF_RADIO->EVENTS_DISABLED) {
-        ble_phy_tx_end_isr();
-    }
+    /*
+     * NOTE: order of checking is important! Possible, if things get delayed,
+     * we have both an ADDRESS and DISABLED interrupt in rx state. If we get
+     * an address, we disable the DISABLED interrupt.
+     */
 
     /* We get this if we have started to receive a frame */
     if ((irq_en & RADIO_INTENCLR_ADDRESS_Msk) && NRF_RADIO->EVENTS_ADDRESS) {
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+        irq_en &= ~RADIO_INTENCLR_DISABLED_Msk;
+#endif
         ble_phy_rx_start_isr();
     }
 
+    /* Check for disabled event. This only happens for transmits now */
+    if ((irq_en & RADIO_INTENCLR_DISABLED_Msk) && NRF_RADIO->EVENTS_DISABLED) {
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+        if (g_ble_phy_data.phy_state == BLE_PHY_STATE_RX) {
+            NRF_RADIO->EVENTS_DISABLED = 0;
+            ble_ll_wfr_timer_exp(NULL);
+        } else {
+            ble_phy_tx_end_isr();
+        }
+#else
+        ble_phy_tx_end_isr();
+#endif
+    }
+
     /* Receive packet end (we dont enable this for transmit) */
     if ((irq_en & RADIO_INTENCLR_END_Msk) && NRF_RADIO->EVENTS_END) {
         ble_phy_rx_end_isr();
@@ -606,6 +807,8 @@ int
 ble_phy_init(void)
 {
     int rc;
+
+#if !defined(BLE_XCVR_RFCLK)
     uint32_t os_tmo;
 
     /* Make sure HFXO is started */
@@ -620,6 +823,7 @@ ble_phy_init(void)
             return BLE_PHY_ERR_INIT;
         }
     }
+#endif
 
     /* Set phy channel to an invalid channel so first set channel works */
     g_ble_phy_data.phy_chan = BLE_PHY_NUM_CHANS;
@@ -657,8 +861,13 @@ ble_phy_init(void)
     /* Configure IFS */
     NRF_RADIO->TIFS = BLE_LL_IFS;
 
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    /* Captures tx/rx start in timer0 cc 1 and tx/rx end in timer0 cc 2 */
+    NRF_PPI->CHENSET = PPI_CHEN_CH26_Msk | PPI_CHEN_CH27_Msk;
+#else
     /* Captures tx/rx start in timer0 capture 1 */
     NRF_PPI->CHENSET = PPI_CHEN_CH26_Msk;
+#endif
 
 #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
     NRF_CCM->INTENCLR = 0xffffffff;
@@ -677,6 +886,27 @@ ble_phy_init(void)
     NRF_AAR->NIRK = 0;
 #endif
 
+    /* TIMER0 setup for PHY when using RTC */
+#if (MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768)
+    NRF_TIMER0->TASKS_STOP = 1;
+    NRF_TIMER0->TASKS_SHUTDOWN = 1;
+    NRF_TIMER0->BITMODE = 3;    /* 32-bit timer */
+    NRF_TIMER0->MODE = 0;       /* Timer mode */
+    NRF_TIMER0->PRESCALER = 4;  /* gives us 1 MHz */
+
+    /*
+     * PPI setup.
+     * Channel 4: Captures TIMER0 in CC[3] when EVENTS_ADDRESS occurs. Used
+     *            to cancel the wait for response timer.
+     * Channel 5: TIMER0 CC[3] to TASKS_DISABLE on radio. This is the wait
+     *            for response timer.
+     */
+    NRF_PPI->CH[4].EEP = (uint32_t)&(NRF_RADIO->EVENTS_ADDRESS);
+    NRF_PPI->CH[4].TEP = (uint32_t)&(NRF_TIMER0->TASKS_CAPTURE[3]);
+    NRF_PPI->CH[5].EEP = (uint32_t)&(NRF_TIMER0->EVENTS_COMPARE[3]);
+    NRF_PPI->CH[5].TEP = (uint32_t)&(NRF_RADIO->TASKS_DISABLE);
+#endif
+
     /* Set isr in vector table and enable interrupt */
     NVIC_SetPriority(RADIO_IRQn, 0);
     NVIC_SetVector(RADIO_IRQn, (uint32_t)ble_phy_isr);
@@ -785,6 +1015,7 @@ ble_phy_set_txend_cb(ble_phy_tx_end_func txend_cb, void *arg)
     g_ble_phy_data.txend_arg = arg;
 }
 
+#if (MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768)
 /**
  * Called to set the start time of a transmission.
  *
@@ -794,28 +1025,38 @@ ble_phy_set_txend_cb(ble_phy_tx_end_func txend_cb, void *arg)
  * NOTE: care must be taken when calling this function. The channel should
  * already be set.
  *
- * @param cputime
- *
+ * @param cputime   This is the tick at which the 1st bit of the preamble
+ *                  should be transmitted
+ * @param rem_usecs This is used only when the underlying timing uses a 32.768
+ *                  kHz crystal. It is the # of usecs from the cputime tick
+ *                  at which the first bit of the preamble should be
+ *                  transmitted.
  * @return int
  */
 int
-ble_phy_tx_set_start_time(uint32_t cputime)
+ble_phy_tx_set_start_time(uint32_t cputime, uint8_t rem_usecs)
 {
     int rc;
 
-    NRF_TIMER0->CC[0] = cputime;
-    NRF_PPI->CHENSET = PPI_CHEN_CH20_Msk;
+    /* XXX: This should not be necessary, but paranoia is good! */
+    /* Clear timer0 compare to RXEN since we are transmitting */
     NRF_PPI->CHENCLR = PPI_CHEN_CH21_Msk;
-    if ((int32_t)(os_cputime_get32() - cputime) >= 0) {
+
+    /*
+     * XXX: The TXEN time is 140 usecs but there may be additional delays
+     * Need to look at this.
+     */
+    if (ble_phy_set_start_time(cputime, rem_usecs) != 0) {
         STATS_INC(ble_phy_stats, tx_late);
         ble_phy_disable();
-        rc =  BLE_PHY_ERR_TX_LATE;
+        rc = BLE_PHY_ERR_TX_LATE;
     } else {
+        /* Enable PPI to automatically start TXEN */
+        NRF_PPI->CHENSET = PPI_CHEN_CH20_Msk;
         rc = 0;
     }
     return rc;
 }
-
 /**
  * Called to set the start time of a reception
  *
@@ -830,23 +1071,90 @@ ble_phy_tx_set_start_time(uint32_t cputime)
  * @return int
  */
 int
-ble_phy_rx_set_start_time(uint32_t cputime)
+ble_phy_rx_set_start_time(uint32_t cputime, uint8_t rem_usecs)
 {
     int rc;
 
+    /* XXX: This should not be necessary, but paranoia is good! */
+    /* Clear timer0 compare to TXEN since we are transmitting */
+    NRF_PPI->CHENCLR = PPI_CHEN_CH20_Msk;
+
+    /*
+     * XXX: The RXEN time is 138 usecs but there may be additional delays
+     * Need to look at this.
+     */
+    if (ble_phy_set_start_time(cputime, rem_usecs) != 0) {
+        STATS_INC(ble_phy_stats, rx_late);
+        NRF_PPI->CHENCLR = PPI_CHEN_CH21_Msk;
+        NRF_RADIO->TASKS_RXEN = 1;
+        rc = BLE_PHY_ERR_RX_LATE;
+    } else {
+        /* Enable PPI to automatically start RXEN */
+        NRF_PPI->CHENSET = PPI_CHEN_CH21_Msk;
+
+        /* Start rx */
+        rc = ble_phy_rx();
+    }
+    return rc;
+}
+#else
+/**
+ * Called to set the start time of a transmission.
+ *
+ * This function is called to set the start time when we are not going from
+ * rx to tx automatically.
+ *
+ * NOTE: care must be taken when calling this function. The channel should
+ * already be set.
+ *
+ * @param cputime   This is the tick at which the 1st bit of the preamble
+ *                  should be transmitted
+ * @return int
+ */
+int
+ble_phy_tx_set_start_time(uint32_t cputime)
+{
+    int rc;
+
+    cputime -= os_cputime_usecs_to_ticks(XCVR_TX_START_DELAY_USECS);
+    NRF_PPI->CHENCLR = PPI_CHEN_CH21_Msk;
     NRF_TIMER0->CC[0] = cputime;
+    NRF_TIMER0->EVENTS_COMPARE[0] = 0;
+    NRF_PPI->CHENSET = PPI_CHEN_CH20_Msk;
+    if ((int32_t)(os_cputime_get32() - cputime) >= 0) {
+        STATS_INC(ble_phy_stats, tx_late);
+        ble_phy_disable();
+        rc = BLE_PHY_ERR_TX_LATE;
+    } else {
+        rc = 0;
+    }
+
+    return rc;
+}
+
+#if 0
+int
+ble_phy_rx_set_start_time(void)
+{
+    /*
+     * XXX: For now, we dont use this function if we are not using the
+     * RTC. Keeping the code around just in case we want to use it later.
+     */
     NRF_PPI->CHENCLR = PPI_CHEN_CH20_Msk;
+    NRF_TIMER0->CC[0] = cputime;
+    NRF_TIMER0->EVENTS_COMPARE[0] = 0;
     NRF_PPI->CHENSET = PPI_CHEN_CH21_Msk;
     if ((int32_t)(os_cputime_get32() - cputime) >= 0) {
         STATS_INC(ble_phy_stats, rx_late);
         NRF_PPI->CHENCLR = PPI_CHEN_CH21_Msk;
         NRF_RADIO->TASKS_RXEN = 1;
-        rc =  BLE_PHY_ERR_TX_LATE;
+        rc =  BLE_PHY_ERR_RX_LATE;
     } else {
         rc = 0;
     }
-    return rc;
 }
+#endif
+#endif
 
 int
 ble_phy_tx(struct os_mbuf *txpdu, uint8_t end_trans)
@@ -871,6 +1179,16 @@ ble_phy_tx(struct os_mbuf *txpdu, uint8_t end_trans)
     ble_hdr = BLE_MBUF_HDR_PTR(txpdu);
     payload_len = ble_hdr->txinfo.pyld_len;
 
+    /*
+     * XXX: Although we may not have to do this here, I clear all the PPI
+     * that should not be used when transmitting. Some of them are only enabled
+     * if encryption and/or privacy is on, but I dont care. Better to be
+     * paranoid, and if you are going to clear one, might as well clear them
+     * all.
+     */
+    NRF_PPI->CHENCLR = PPI_CHEN_CH4_Msk | PPI_CHEN_CH5_Msk | PPI_CHEN_CH23_Msk |
+                       PPI_CHEN_CH25_Msk;
+
 #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
     if (g_ble_phy_data.phy_encrypted) {
         dptr = (uint8_t *)&g_ble_phy_enc_buf[0];
@@ -883,11 +1201,9 @@ ble_phy_tx(struct os_mbuf *txpdu, uint8_t end_trans)
         NRF_CCM->EVENTS_ERROR = 0;
         NRF_CCM->MODE = CCM_MODE_LENGTH_Msk;
         NRF_CCM->CNFPTR = (uint32_t)&g_nrf_ccm_data;
-        NRF_PPI->CHENCLR = PPI_CHEN_CH25_Msk | PPI_CHEN_CH23_Msk;
         NRF_PPI->CHENSET = PPI_CHEN_CH24_Msk;
     } else {
 #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
-        NRF_PPI->CHENCLR = PPI_CHEN_CH23_Msk;
         NRF_AAR->IRKPTR = (uint32_t)&g_nrf_irk_list[0];
 #endif
         dptr = (uint8_t *)&g_ble_phy_tx_buf[0];
@@ -895,9 +1211,6 @@ ble_phy_tx(struct os_mbuf *txpdu, uint8_t end_trans)
         pktptr = dptr;
     }
 #else
-#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY) == 1)
-    NRF_PPI->CHENCLR = PPI_CHEN_CH23_Msk;
-#endif
     dptr = (uint8_t *)&g_ble_phy_tx_buf[0];
     ++dptr;
     pktptr = dptr;
@@ -1077,29 +1390,62 @@ ble_phy_setchan(uint8_t chan, uint32_t access_addr, uint32_t crcinit)
     return 0;
 }
 
+#if (MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768)
 /**
- * Disable the PHY. This will do the following:
- *  -> Turn off all phy interrupts.
- *  -> Disable internal shortcuts.
- *  -> Disable the radio.
- *  -> Make sure we wont automatically go to rx/tx on output compare
- *  -> Sets phy state to idle.
- *  -> Clears any pending irqs in the NVIC. Might not be necessary but we do
- *  it as a precaution.
+ * Stop the timer used to count microseconds when using RTC for cputime
  */
 void
-ble_phy_disable(void)
+ble_phy_stop_usec_timer(void)
 {
-    ble_ll_log(BLE_LL_LOG_ID_PHY_DISABLE, g_ble_phy_data.phy_state, 0, 0);
+    NRF_TIMER0->TASKS_STOP = 1;
+    NRF_TIMER0->TASKS_SHUTDOWN = 1;
+    NRF_RTC0->EVTENCLR = RTC_EVTENSET_COMPARE0_Msk;
+}
+#endif
 
+/**
+ * ble phy disable irq and ppi
+ *
+ * This routine is to be called when reception was stopped due to either a
+ * wait for response timeout or a packet being received and the phy is to be
+ * restarted in receive mode. Generally, the disable routine is called to stop
+ * the phy.
+ */
+void
+ble_phy_disable_irq_and_ppi(void)
+{
     NRF_RADIO->INTENCLR = NRF_RADIO_IRQ_MASK_ALL;
     NRF_RADIO->SHORTS = 0;
     NRF_RADIO->TASKS_DISABLE = 1;
-    NRF_PPI->CHENCLR = PPI_CHEN_CH23_Msk | PPI_CHEN_CH21_Msk | PPI_CHEN_CH20_Msk;
+    NRF_PPI->CHENCLR = PPI_CHEN_CH4_Msk | PPI_CHEN_CH5_Msk | PPI_CHEN_CH20_Msk |
+          PPI_CHEN_CH21_Msk | PPI_CHEN_CH23_Msk | PPI_CHEN_CH24_Msk |
+          PPI_CHEN_CH25_Msk | PPI_CHEN_CH31_Msk;
     NVIC_ClearPendingIRQ(RADIO_IRQn);
     g_ble_phy_data.phy_state = BLE_PHY_STATE_IDLE;
 }
 
+void
+ble_phy_restart_rx(void)
+{
+    ble_phy_disable_irq_and_ppi();
+    ble_phy_rx();
+}
+
+/**
+ * ble phy disable
+ *
+ * Disables the PHY. This should be called when an event is over. It stops
+ * the usec timer (if used), disables interrupts, disables the RADIO, disables
+ * PPI and sets state to idle.
+ */
+void
+ble_phy_disable(void)
+{
+    ble_ll_log(BLE_LL_LOG_ID_PHY_DISABLE, g_ble_phy_data.phy_state, 0, 0);
+    ble_phy_stop_usec_timer();
+    ble_phy_disable_irq_and_ppi();
+}
+
 /* Gets the current access address */
 uint32_t ble_phy_access_addr_get(void)
 {
@@ -1168,3 +1514,17 @@ ble_phy_resolv_list_disable(void)
     g_ble_phy_data.phy_privacy = 0;
 }
 #endif
+
+#ifdef BLE_XCVR_RFCLK
+void
+ble_phy_rfclk_enable(void)
+{
+    NRF_CLOCK->TASKS_HFCLKSTART = 1;
+}
+
+void
+ble_phy_rfclk_disable(void)
+{
+    NRF_CLOCK->TASKS_HFCLKSTOP = 1;
+}
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/kernel/os/include/os/os_cputime.h
----------------------------------------------------------------------
diff --git a/kernel/os/include/os/os_cputime.h b/kernel/os/include/os/os_cputime.h
index f44c941..022efdc 100644
--- a/kernel/os/include/os/os_cputime.h
+++ b/kernel/os/include/os/os_cputime.h
@@ -45,6 +45,10 @@ extern "C" {
 #define OS_CPUTIME_FREQ_1MHZ
 #endif
 
+#if (MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768)
+#define OS_CPUTIME_FREQ_32768
+#endif
+
 /* CPUTIME data. */
 struct os_cputime_data
 {
@@ -80,6 +84,7 @@ int os_cputime_init(uint32_t clock_freq);
  */
 uint32_t os_cputime_get32(void);
 
+#if !defined(OS_CPUTIME_FREQ_32768)
 /**
  * os cputime nsecs to ticks
  *
@@ -101,6 +106,7 @@ uint32_t os_cputime_nsecs_to_ticks(uint32_t nsecs);
  * @return uint32_t The number of nanoseconds corresponding to 'ticks'
  */
 uint32_t os_cputime_ticks_to_nsecs(uint32_t ticks);
+#endif
 
 #if defined(OS_CPUTIME_FREQ_1MHZ)
 #define os_cputime_usecs_to_ticks(x)    (x)
@@ -138,6 +144,7 @@ uint32_t os_cputime_ticks_to_usecs(uint32_t ticks);
  */
 void os_cputime_delay_ticks(uint32_t ticks);
 
+#if !defined(OS_CPUTIME_FREQ_32768)
 /**
  * os cputime delay nsecs
  *
@@ -146,6 +153,7 @@ void os_cputime_delay_ticks(uint32_t ticks);
  * @param nsecs The number of nanoseconds to wait.
  */
 void os_cputime_delay_nsecs(uint32_t nsecs);
+#endif
 
 /**
  * os cputime delay usecs

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/kernel/os/src/os_cputime.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/os_cputime.c b/kernel/os/src/os_cputime.c
index 067f1a1..01b15fe 100644
--- a/kernel/os/src/os_cputime.c
+++ b/kernel/os/src/os_cputime.c
@@ -30,7 +30,9 @@
  *   @{
  */
 
+#if !defined(OS_CPUTIME_FREQ_32768) && !defined(OS_CPUTIME_FREQ_1MHZ)
 struct os_cputime_data g_os_cputime;
+#endif
 
 /**
  * os cputime init
@@ -49,11 +51,14 @@ os_cputime_init(uint32_t clock_freq)
     int rc;
 
     /* Set the ticks per microsecond. */
+#if !defined(OS_CPUTIME_FREQ_32768) && !defined(OS_CPUTIME_FREQ_1MHZ)
     g_os_cputime.ticks_per_usec = clock_freq / 1000000U;
+#endif
     rc = hal_timer_config(MYNEWT_VAL(OS_CPUTIME_TIMER_NUM), clock_freq);
     return rc;
 }
 
+#if !defined(OS_CPUTIME_FREQ_32768)
 /**
  * os cputime nsecs to ticks
  *
@@ -99,8 +104,50 @@ os_cputime_ticks_to_nsecs(uint32_t ticks)
 
     return nsecs;
 }
+#endif
 
 #if !defined(OS_CPUTIME_FREQ_1MHZ)
+#if defined(OS_CPUTIME_FREQ_32768)
+/**
+ * os cputime usecs to ticks
+ *
+ * Converts the given number of microseconds into cputime ticks.
+ *
+ * @param usecs The number of microseconds to convert to ticks
+ *
+ * @return uint32_t The number of ticks corresponding to 'usecs'
+ */
+uint32_t
+os_cputime_usecs_to_ticks(uint32_t usecs)
+{
+    uint64_t ticks;
+
+    ticks = ((uint64_t)usecs << 9) / 15625;
+    return (uint32_t)ticks;
+}
+
+/**
+ * cputime ticks to usecs
+ *
+ * Convert the given number of ticks into microseconds.
+ *
+ * @param ticks The number of ticks to convert to microseconds.
+ *
+ * @return uint32_t The number of microseconds corresponding to 'ticks'
+ *
+ * NOTE: This calculation will overflow if the value for ticks is greater
+ * than 140737488. I am not going to check that here because that many ticks
+ * is about 4222 seconds, way more than what this routine should be used for.
+ */
+uint32_t
+os_cputime_ticks_to_usecs(uint32_t ticks)
+{
+    uint32_t usecs;
+
+    usecs = ((ticks >> 9) * 15625) + (((ticks & 0x1ff) * 15625) >> 9);
+    return usecs;
+}
+#else
 /**
  * os cputime usecs to ticks
  *
@@ -138,6 +185,7 @@ os_cputime_ticks_to_usecs(uint32_t ticks)
     return us;
 }
 #endif
+#endif
 
 /**
  * os cputime delay ticks
@@ -157,6 +205,7 @@ os_cputime_delay_ticks(uint32_t ticks)
     }
 }
 
+#if !defined(OS_CPUTIME_FREQ_32768)
 /**
  * os cputime delay nsecs
  *
@@ -172,6 +221,7 @@ os_cputime_delay_nsecs(uint32_t nsecs)
     ticks = os_cputime_nsecs_to_ticks(nsecs);
     os_cputime_delay_ticks(ticks);
 }
+#endif
 
 /**
  * os cputime delay usecs

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/controller/include/controller/ble_ll.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll.h b/net/nimble/controller/include/controller/ble_ll.h
index e349d71..acc201d 100644
--- a/net/nimble/controller/include/controller/ble_ll.h
+++ b/net/nimble/controller/include/controller/ble_ll.h
@@ -22,13 +22,41 @@
 
 #include "stats/stats.h"
 #include "os/os_eventq.h"
+#include "os/os_callout.h"
 #include "os/os_cputime.h"
 #include "nimble/nimble_opt.h"
+#include "controller/ble_phy.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+/*
+ * XXX:
+ * I guess this should not depend on the 32768 crystal to be honest. This
+ * should be done for TIMER0 as well since the rf clock chews up more current.
+ * Deal with this later.
+ *
+ * Another note: BLE_XTAL_SETTLE_TIME should be bsp related (I guess). There
+ * should be a note in there that the converted usecs to ticks value of this
+ * should not be 0. Thus: if you are using a 32.768 os cputime freq, the min
+ * value of settle time should be 31 usecs. I would suspect all settling times
+ * would exceed 31 usecs.
+ */
+
+/* Determines if we need to turn on/off rf clock */
+#undef BLE_XCVR_RFCLK
+
+/* Transceiver specific definitions */
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+
+/* We will turn on/off rf clock */
+#if MYNEWT_VAL(BLE_XTAL_SETTLE_TIME) != 0
+#define BLE_XCVR_RFCLK
+#endif
+
+#endif
+
 /* Controller revision. */
 #define BLE_LL_SUB_VERS_NR      (0x0000)
 
@@ -61,11 +89,22 @@ struct ble_ll_obj
 
     /* Number of ACL data packets supported */
     uint8_t ll_num_acl_pkts;
+
+#ifdef BLE_XCVR_RFCLK
+    uint8_t ll_rfclk_state;
+    uint16_t ll_xtal_ticks;
+#else
     uint8_t _pad;
+    uint16_t _pad16;
+#endif
 
     /* ACL data packet size */
     uint16_t ll_acl_pkt_size;
-    uint16_t _pad16;
+
+#ifdef BLE_XCVR_RFCLK
+    uint32_t ll_rfclk_start_time;
+    struct hal_timer ll_rfclk_timer;
+#endif
 
     /* Task event queue */
     struct os_eventq ll_evq;
@@ -362,6 +401,9 @@ void ble_ll_wfr_enable(uint32_t cputime);
 /* Disable wait for response timer */
 void ble_ll_wfr_disable(void);
 
+/* Wait for response timer expiration callback */
+void ble_ll_wfr_timer_exp(void *arg);
+
 /* Read set of features supported by the Link Layer */
 uint8_t ble_ll_read_supp_features(void);
 
@@ -383,7 +425,7 @@ int ble_ll_rand_start(void);
  * XXX: temporary LL debug log. Will get removed once we transition to real
  * log
  */
-#undef BLE_LL_LOG
+#define BLE_LL_LOG
 #include "console/console.h"
 
 #define BLE_LL_LOG_ID_PHY_SETCHAN       (1)
@@ -405,6 +447,11 @@ int ble_ll_rand_start(void);
 #define BLE_LL_LOG_ID_ADV_TXBEG         (50)
 #define BLE_LL_LOG_ID_ADV_TXDONE        (60)
 #define BLE_LL_LOG_ID_SCHED             (80)
+#define BLE_LL_LOG_ID_RFCLK_START       (90)
+#define BLE_LL_LOG_ID_RFCLK_ENABLE      (91)
+#define BLE_LL_LOG_ID_RFCLK_STOP        (95)
+#define BLE_LL_LOG_ID_RFCLK_SCHED_DIS   (96)
+#define BLE_LL_LOG_ID_RFCLK_SCAN_DIS    (97)
 
 #ifdef BLE_LL_LOG
 void ble_ll_log(uint8_t id, uint8_t arg8, uint16_t arg16, uint32_t arg32);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/controller/include/controller/ble_ll_conn.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_conn.h b/net/nimble/controller/include/controller/ble_ll_conn.h
index b2e6410..041504d 100644
--- a/net/nimble/controller/include/controller/ble_ll_conn.h
+++ b/net/nimble/controller/include/controller/ble_ll_conn.h
@@ -202,6 +202,11 @@ struct ble_ll_conn_sm
     uint16_t max_ce_len;
     uint16_t tx_win_off;
     uint32_t anchor_point;
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    uint8_t anchor_point_usecs;     /* XXX: can this be uint8_t ?*/
+    uint8_t conn_itvl_usecs;
+    uint32_t conn_itvl_ticks;
+#endif
     uint32_t last_anchor_point;     /* Slave only */
     uint32_t slave_cur_tx_win_usecs;
     uint32_t slave_cur_window_widening;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/controller/include/controller/ble_ll_sched.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_sched.h b/net/nimble/controller/include/controller/ble_ll_sched.h
index 3a05cfe..d2321b7 100644
--- a/net/nimble/controller/include/controller/ble_ll_sched.h
+++ b/net/nimble/controller/include/controller/ble_ll_sched.h
@@ -25,7 +25,8 @@ extern "C" {
 #endif
 
 /* Time per BLE scheduler slot */
-#define BLE_LL_SCHED_USECS_PER_SLOT (1250)
+#define BLE_LL_SCHED_USECS_PER_SLOT         (1250)
+#define BLE_LL_SCHED_32KHZ_TICKS_PER_SLOT   (41)    /* 1 tick = 30.517 usecs */
 
 /*
  * Worst case time needed for scheduled advertising item. This is the longest
@@ -46,6 +47,17 @@ extern "C" {
 #define BLE_LL_SCHED_DIRECT_ADV_MAX_USECS   (502)
 #define BLE_LL_SCHED_MAX_ADV_PDU_USECS      (376)
 
+/* BLE Jitter (+/- 16 useecs) */
+#define BLE_LL_JITTER_USECS                 (16)
+
+/*
+ * This is the offset from the start of the scheduled item until the actual
+ * tx/rx should occur, in ticks.
+ */
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+extern uint8_t g_ble_ll_sched_offset_ticks;
+#endif
+
 /*
  * This is the number of slots needed to transmit and receive a maximum
  * size PDU, including an IFS time before each. The actual time is
@@ -69,10 +81,19 @@ extern "C" {
 struct ble_ll_sched_item;
 typedef int (*sched_cb_func)(struct ble_ll_sched_item *sch);
 
+/*
+ * Schedule item
+ *  sched_type: This is the type of the schedule item.
+ *  enqueued: Flag denoting if item is on the scheduler list. 0: no, 1:yes
+ *  remainder: # of usecs from offset till tx/rx should occur
+ *  txrx_offset: Number of ticks from start time until tx/rx should occur.
+ *
+ */
 struct ble_ll_sched_item
 {
     uint8_t         sched_type;
     uint8_t         enqueued;
+    uint8_t         remainder;
     uint32_t        start_time;
     uint32_t        end_time;
     void            *cb_arg;
@@ -94,8 +115,8 @@ void ble_ll_sched_free_item(struct ble_ll_sched_item *sch);
 
 /* Schedule a new master connection */
 struct ble_ll_conn_sm;
-int ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm, uint32_t adv_rxend,
-                            uint8_t req_slots);
+int ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm,
+                            struct ble_mbuf_hdr *ble_hdr, uint8_t pyld_len);
 
 /* Schedule a new slave connection */
 int ble_ll_sched_slave_new(struct ble_ll_conn_sm *connsm);
@@ -128,6 +149,11 @@ int ble_ll_sched_next_time(uint32_t *next_event_time);
 /* Stop the scheduler */
 void ble_ll_sched_stop(void);
 
+#ifdef BLE_XCVR_RFCLK
+/* Check if RF clock needs to be restarted */
+void ble_ll_sched_rfclk_chk_restart(void);
+#endif
+
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/controller/include/controller/ble_ll_xcvr.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_xcvr.h b/net/nimble/controller/include/controller/ble_ll_xcvr.h
new file mode 100644
index 0000000..c59b009
--- /dev/null
+++ b/net/nimble/controller/include/controller/ble_ll_xcvr.h
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+
+#ifndef H_BLE_LL_XCVR_
+#define H_BLE_LL_XCVR_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef BLE_XCVR_RFCLK
+
+/* RF clock states */
+#define BLE_RFCLK_STATE_OFF     (0)
+#define BLE_RFCLK_STATE_ON      (1)
+#define BLE_RFCLK_STATE_SETTLED (2)
+
+int ble_ll_xcvr_rfclk_state(void);
+void ble_ll_xcvr_rfclk_start_now(uint32_t now);
+void ble_ll_xcvr_rfclk_stop(void);
+void ble_ll_xcvr_rfclk_enable(void);
+void ble_ll_xcvr_rfclk_disable(void);
+uint32_t ble_ll_xcvr_rfclk_time_till_settled(void);
+void ble_ll_xcvr_rfclk_timer_exp(void *arg);
+void ble_ll_xcvr_rfclk_timer_start(uint32_t cputime);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* H_LL_ */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/controller/include/controller/ble_phy.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_phy.h b/net/nimble/controller/include/controller/ble_phy.h
index 674cbc5..e62b216 100644
--- a/net/nimble/controller/include/controller/ble_phy.h
+++ b/net/nimble/controller/include/controller/ble_phy.h
@@ -70,6 +70,7 @@ struct os_mbuf;
 #define BLE_PHY_ERR_INV_PARAM       (3)
 #define BLE_PHY_ERR_NO_BUFS         (4)
 #define BLE_PHY_ERR_TX_LATE         (5)
+#define BLE_PHY_ERR_RX_LATE         (6)
 
 /* Maximun PDU length. Includes LL header of 2 bytes and 255 bytes payload. */
 #define BLE_PHY_MAX_PDU_LEN         (257)
@@ -86,11 +87,16 @@ int ble_phy_reset(void);
 /* Set the PHY channel */
 int ble_phy_setchan(uint8_t chan, uint32_t access_addr, uint32_t crcinit);
 
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
 /* Set transmit start time */
-int ble_phy_tx_set_start_time(uint32_t cputime);
+int ble_phy_tx_set_start_time(uint32_t cputime, uint8_t rem_usecs);
 
 /* Set receive start time */
-int ble_phy_rx_set_start_time(uint32_t cputime);
+int ble_phy_rx_set_start_time(uint32_t cputime, uint8_t rem_usecs);
+#else
+/* Set transmit start time */
+int ble_phy_tx_set_start_time(uint32_t cputime);
+#endif
 
 /* Set the transmit end callback and argument */
 void ble_phy_set_txend_cb(ble_phy_tx_end_func txend_cb, void *arg);
@@ -116,6 +122,27 @@ int ble_phy_txpwr_get(void);
 /* Disable the PHY */
 void ble_phy_disable(void);
 
+#if (MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768)
+void ble_phy_stop_usec_timer(void);
+void ble_phy_wfr_enable(int txrx, uint32_t wfr_usecs);
+#define BLE_PHY_WFR_ENABLE_RX       (0)
+#define BLE_PHY_WFR_ENABLE_TXRX     (1)
+#else
+#define ble_phy_stop_usec_timer()
+#endif
+
+/* Starts rf clock */
+void ble_phy_rfclk_enable(void);
+
+/* Stops rf clock */
+void ble_phy_rfclk_disable(void);
+
+/*
+ * Used to restart reception on same channel after wfr timer expiration or
+ * frame received.
+ */
+void ble_phy_restart_rx(void);
+
 /* Gets the current state of the PHY */
 int ble_phy_state_get(void);
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/controller/src/ble_ll.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll.c b/net/nimble/controller/src/ble_ll.c
index 6071d3c..3204ff2 100644
--- a/net/nimble/controller/src/ble_ll.c
+++ b/net/nimble/controller/src/ble_ll.c
@@ -39,6 +39,7 @@
 #include "controller/ble_ll_hci.h"
 #include "controller/ble_ll_whitelist.h"
 #include "controller/ble_ll_resolv.h"
+#include "controller/ble_ll_xcvr.h"
 #include "ble_ll_conn_priv.h"
 
 /* XXX:
@@ -51,6 +52,11 @@
  * 4) Should look into always disabled the wfr interrupt if we receive the
  * start of a frame. Need to look at the various states to see if this is the
  * right thing to do.
+ * 5) I am not sure that if we are passed the output compare that we actually
+ * get the interrupt. Test this.
+ * 6) I am not sure that if we receive a packet while scanning that we actually
+ * go back to scanning. I need to make sure we re-enable the receive.
+ * Put an event in the log!
  */
 
 /* Supported states */
@@ -536,7 +542,9 @@ ble_ll_wfr_timer_exp(void *arg)
 void
 ble_ll_wfr_enable(uint32_t cputime)
 {
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) != 32768
     os_cputime_timer_start(&g_ble_ll_data.ll_wfr_timer, cputime);
+#endif
 }
 
 /**
@@ -545,7 +553,9 @@ ble_ll_wfr_enable(uint32_t cputime)
 void
 ble_ll_wfr_disable(void)
 {
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) != 32768
     os_cputime_timer_stop(&g_ble_ll_data.ll_wfr_timer);
+#endif
 }
 
 /**
@@ -786,7 +796,12 @@ ble_ll_rx_start(uint8_t *rxbuf, uint8_t chan, struct ble_mbuf_hdr *rxhdr)
     int rc;
     uint8_t pdu_type;
 
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    ble_ll_log(BLE_LL_LOG_ID_RX_START, chan, rxhdr->rem_usecs,
+               rxhdr->beg_cputime);
+#else
     ble_ll_log(BLE_LL_LOG_ID_RX_START, chan, 0, rxhdr->beg_cputime);
+#endif
 
     /* Check channel type */
     if (chan < BLE_PHY_NUM_DATA_CHANS) {
@@ -1167,6 +1182,11 @@ ble_ll_reset(void)
     /* Set state to standby */
     ble_ll_state_set(BLE_LL_STATE_STANDBY);
 
+#ifdef BLE_XCVR_RFCLK
+    /* Stops rf clock and rfclock timer */
+    ble_ll_xcvr_rfclk_stop();
+#endif
+
     /* Reset our random address */
     memset(g_random_addr, 0, BLE_DEV_ADDR_LEN);
 
@@ -1211,11 +1231,26 @@ ble_ll_init(void)
 {
     int rc;
     uint8_t features;
+#ifdef BLE_XCVR_RFCLK
+    uint32_t xtal_ticks;
+#endif
     struct ble_ll_obj *lldata;
 
     /* Ensure this function only gets called by sysinit. */
     SYSINIT_ASSERT_ACTIVE();
 
+#ifdef BLE_XCVR_RFCLK
+    /* Settling time of crystal, in ticks */
+    xtal_ticks = MYNEWT_VAL(BLE_XTAL_SETTLE_TIME);
+    assert(xtal_ticks != 0);
+    g_ble_ll_data.ll_xtal_ticks = os_cputime_usecs_to_ticks(xtal_ticks);
+
+    /* Initialize rf clock timer */
+    os_cputime_timer_init(&g_ble_ll_data.ll_rfclk_timer,
+                          ble_ll_xcvr_rfclk_timer_exp, NULL);
+
+#endif
+
     /* Get pointer to global data object */
     lldata = &g_ble_ll_data;
 
@@ -1241,9 +1276,11 @@ ble_ll_init(void)
                     ble_ll_hw_err_timer_cb,
                     NULL);
 
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) != 32768
     /* Initialize wait for response timer */
     os_cputime_timer_init(&g_ble_ll_data.ll_wfr_timer, ble_ll_wfr_timer_exp,
                           NULL);
+#endif
 
     /* Initialize LL HCI */
     ble_ll_hci_init();

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/controller/src/ble_ll_adv.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_adv.c b/net/nimble/controller/src/ble_ll_adv.c
index 203f13a..8240d7a 100644
--- a/net/nimble/controller/src/ble_ll_adv.c
+++ b/net/nimble/controller/src/ble_ll_adv.c
@@ -430,8 +430,14 @@ ble_ll_adv_tx_start_cb(struct ble_ll_sched_item *sch)
     assert(rc == 0);
 
     /* Set transmit start time. */
-    txstart = sch->start_time + os_cputime_usecs_to_ticks(XCVR_PROC_DELAY_USECS);
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    txstart = sch->start_time + g_ble_ll_sched_offset_ticks;
+    rc = ble_phy_tx_set_start_time(txstart, sch->remainder);
+#else
+    txstart = sch->start_time +
+        os_cputime_usecs_to_ticks(XCVR_TX_SCHED_DELAY_USECS);
     rc = ble_phy_tx_set_start_time(txstart);
+#endif
     if (rc) {
         STATS_INC(ble_ll_stats, adv_late_starts);
         goto adv_tx_done;
@@ -498,7 +504,7 @@ adv_tx_done:
 }
 
 static void
-ble_ll_adv_set_sched(struct ble_ll_adv_sm *advsm, int sched_new)
+ble_ll_adv_set_sched(struct ble_ll_adv_sm *advsm)
 {
     uint32_t max_usecs;
     struct ble_ll_sched_item *sch;
@@ -529,20 +535,15 @@ ble_ll_adv_set_sched(struct ble_ll_adv_sm *advsm, int sched_new)
      */
     max_usecs += XCVR_PROC_DELAY_USECS;
 
-    if (sched_new) {
-        /*
-         * We have to add the scheduling delay and tx start delay to the max
-         * time of the event since the pdu does not start at the scheduled start.
-         */
-        max_usecs += XCVR_TX_SCHED_DELAY_USECS;
-        sch->start_time = os_cputime_get32();
-        sch->end_time = sch->start_time + os_cputime_usecs_to_ticks(max_usecs);
-    } else {
-        sch->start_time = advsm->adv_pdu_start_time -
-            os_cputime_usecs_to_ticks(XCVR_TX_SCHED_DELAY_USECS);
-        sch->end_time = advsm->adv_pdu_start_time +
-            os_cputime_usecs_to_ticks(max_usecs);
-    }
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    sch->start_time = advsm->adv_pdu_start_time - g_ble_ll_sched_offset_ticks;
+    sch->remainder = 0;
+#else
+    sch->start_time = advsm->adv_pdu_start_time -
+        os_cputime_usecs_to_ticks(XCVR_TX_SCHED_DELAY_USECS);
+#endif
+    sch->end_time = advsm->adv_pdu_start_time +
+        os_cputime_usecs_to_ticks(max_usecs);
 }
 
 /**
@@ -745,6 +746,10 @@ ble_ll_adv_sm_stop(struct ble_ll_adv_sm *advsm)
             ble_ll_wfr_disable();
             ble_ll_state_set(BLE_LL_STATE_STANDBY);
             g_ble_ll_cur_adv_sm = NULL;
+            ble_ll_scan_chk_resume();
+#ifdef BLE_XCVR_RFCLK
+            ble_ll_sched_rfclk_chk_restart();
+#endif
         }
 #else
         if (ble_ll_state_get() == BLE_LL_STATE_ADV) {
@@ -752,6 +757,10 @@ ble_ll_adv_sm_stop(struct ble_ll_adv_sm *advsm)
             ble_ll_wfr_disable();
             ble_ll_state_set(BLE_LL_STATE_STANDBY);
             g_ble_ll_cur_adv_sm = NULL;
+            ble_ll_scan_chk_resume();
+#ifdef BLE_XCVR_RFCLK
+            ble_ll_sched_rfclk_chk_restart();
+#endif
         }
 #endif
         OS_EXIT_CRITICAL(sr);
@@ -872,10 +881,23 @@ ble_ll_adv_sm_start(struct ble_ll_adv_sm *advsm)
     advsm->adv_chan = adv_chan;
 
     /*
+     * XXX: while this may not be the most efficient, schedule the first
+     * advertising event some time in the future (5 msecs). This will give
+     * time to start up any clocks or anything and also avoid a bunch of code
+     * to check if we are currently doing anything. Just makes this simple.
+     *
+     * Might also want to align this on a slot in the future.
+     *
+     * NOTE: adv_event_start_time gets set by the sched_adv_new
+     */
+    advsm->adv_pdu_start_time = os_cputime_get32() +
+        os_cputime_usecs_to_ticks(BLE_LL_SCHED_MAX_TXRX_SLOT);
+
+    /*
      * Schedule advertising. We set the initial schedule start and end
      * times to the earliest possible start/end.
      */
-    ble_ll_adv_set_sched(advsm, 1);
+    ble_ll_adv_set_sched(advsm);
     ble_ll_sched_adv_new(&advsm->adv_sch);
 
     return BLE_ERR_SUCCESS;
@@ -884,9 +906,14 @@ ble_ll_adv_sm_start(struct ble_ll_adv_sm *advsm)
 void
 ble_ll_adv_scheduled(struct ble_ll_adv_sm *advsm, uint32_t sch_start)
 {
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    /* The event start time is when we start transmission of the adv PDU */
+    advsm->adv_event_start_time = sch_start + g_ble_ll_sched_offset_ticks;
+#else
     /* The event start time is when we start transmission of the adv PDU */
     advsm->adv_event_start_time = sch_start +
         os_cputime_usecs_to_ticks(XCVR_TX_SCHED_DELAY_USECS);
+#endif
 
     advsm->adv_pdu_start_time = advsm->adv_event_start_time;
 
@@ -1489,6 +1516,11 @@ ble_ll_adv_done(struct ble_ll_adv_sm *advsm)
         /* Check if we need to resume scanning */
         ble_ll_scan_chk_resume();
 
+        /* Turn off the clock if not doing anything else */
+#ifdef BLE_XCVR_RFCLK
+        ble_ll_sched_rfclk_chk_restart();
+#endif
+
         /* This event is over. Set adv channel to first one */
         advsm->adv_chan = ble_ll_adv_first_chan(advsm);
 
@@ -1511,8 +1543,12 @@ ble_ll_adv_done(struct ble_ll_adv_sm *advsm)
          * The scheduled time better be in the future! If it is not, we will
          * just keep advancing until we the time is in the future
          */
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+        start_time = advsm->adv_pdu_start_time - g_ble_ll_sched_offset_ticks;
+#else
         start_time = advsm->adv_pdu_start_time -
             os_cputime_usecs_to_ticks(XCVR_TX_SCHED_DELAY_USECS);
+#endif
 
         delta_t = (int32_t)(start_time - os_cputime_get32());
         if (delta_t < 0) {
@@ -1543,9 +1579,13 @@ ble_ll_adv_done(struct ble_ll_adv_sm *advsm)
          * We will transmit right away. Set next pdu start time to now
          * plus a xcvr start delay just so we dont count late adv starts
          */
-        advsm->adv_pdu_start_time = os_cputime_get32() +
+        advsm->adv_pdu_start_time = os_cputime_get32();
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+        advsm->adv_pdu_start_time += g_ble_ll_sched_offset_ticks;
+#else
+        advsm->adv_pdu_start_time +=
             os_cputime_usecs_to_ticks(XCVR_TX_SCHED_DELAY_USECS);
-
+#endif
         resched_pdu = 1;
     }
 
@@ -1571,7 +1611,7 @@ ble_ll_adv_done(struct ble_ll_adv_sm *advsm)
 #endif
 
     /* Schedule advertising transmit */
-    ble_ll_adv_set_sched(advsm, 0);
+    ble_ll_adv_set_sched(advsm);
 
     /*
      * In the unlikely event we cant reschedule this, just post a done
@@ -1580,9 +1620,15 @@ ble_ll_adv_done(struct ble_ll_adv_sm *advsm)
     if (resched_pdu) {
         rc = ble_ll_sched_adv_resched_pdu(&advsm->adv_sch);
     } else {
+        /* Reschedule advertising event */
         rc = ble_ll_sched_adv_reschedule(&advsm->adv_sch, &start_time,
                                          max_delay_ticks);
         if (!rc) {
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+            start_time += g_ble_ll_sched_offset_ticks;
+#else
+            start_time += os_cputime_usecs_to_ticks(XCVR_TX_SCHED_DELAY_USECS);
+#endif
             advsm->adv_event_start_time = start_time;
             advsm->adv_pdu_start_time = start_time;
         }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/controller/src/ble_ll_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn.c b/net/nimble/controller/src/ble_ll_conn.c
index c0cda6d..a32d8f8 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -95,15 +95,26 @@ extern void bletest_completed_pkt(uint16_t handle);
  * response. Well, it should. If this packet will overrun the next scheduled
  * event, what should we do? Transmit anyway? Not transmit? For now, we just
  * transmit.
+ *
+ * 32kHz crystal
+ * 1) When scheduling, I need to make sure I have time between
+ * this one and the next. Should I deal with this in the sched. Or
+ * is this basically accounted for given a slot? I really just need to
+ * make sure everything is over N ticks before the next sched start!
+ * Just add to end time?
+ *
+ * 2) I think one way to handle the problem of losing up to a microsecond
+ * every time we call ble_ll_conn_next_event in a loop is to do everything by
+ * keeping track of last anchor point. Would need last anchor usecs too. I guess
+ * we could also keep last anchor usecs as a uint32 or something and when we
+ * do the next event keep track of the residual using a different ticks to
+ * usecs calculation. Not sure.
  */
 
 /*
  * XXX: How should we deal with a late connection event? We need to determine
  * what we want to do under the following cases:
  *  1) The current connection event has not ended but a schedule item starts
- *  2) The connection event start cb is called but we are later than we
- *  expected. What to do? If we cant transmit at correct point in slot we
- *  are hosed. Well, anchor point can get really messed up!
  */
 
 /*
@@ -218,6 +229,25 @@ STATS_NAME_END(ble_ll_conn_stats)
 
 static void ble_ll_conn_event_end(struct os_event *ev);
 
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+static void
+ble_ll_conn_calc_itvl_ticks(struct ble_ll_conn_sm *connsm)
+{
+    uint32_t ticks;
+    uint32_t usecs;
+
+    /*
+     * Precalculate the number of ticks and remaining microseconds for
+     * the connection interval
+     */
+    usecs = connsm->conn_itvl * BLE_LL_CONN_ITVL_USECS;
+    ticks = os_cputime_usecs_to_ticks(usecs);
+    connsm->conn_itvl_ticks = ticks;
+    connsm->conn_itvl_usecs = (uint8_t)(usecs -
+                                        os_cputime_ticks_to_usecs(ticks));
+}
+#endif
+
 /**
  * Get the event buffer allocated to send the connection complete event
  * when we are initiating.
@@ -402,7 +432,6 @@ ble_ll_conn_calc_window_widening(struct ble_ll_conn_sm *connsm)
         window_widening = (total_sca_ppm * delta_msec) / 1000;
     }
 
-    /* XXX: spec gives 16 usecs error btw. Probably should add that in */
     return window_widening;
 }
 
@@ -689,7 +718,10 @@ ble_ll_conn_continue_rx_encrypt(void *arg)
  * the current connection event. The current connection event must end before
  * the next scheduled item. However, the current connection itself is not
  * in the scheduler list! Thus, we need to calculate the time at which the
- * next connection will start and not overrun it.
+ * next connection will start (the schedule start time; not the anchor point)
+ * and not overrun it.
+ *
+ * Context: Interrupt
  *
  * @param connsm
  *
@@ -698,13 +730,25 @@ ble_ll_conn_continue_rx_encrypt(void *arg)
 static uint32_t
 ble_ll_conn_get_next_sched_time(struct ble_ll_conn_sm *connsm)
 {
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) != 32768
     uint32_t itvl;
+#endif
     uint32_t ce_end;
     uint32_t next_sched_time;
 
     /* Calculate time at which next connection event will start */
-    itvl = connsm->conn_itvl * BLE_LL_CONN_ITVL_USECS;
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    /* NOTE: We dont care if this time is tick short. */
+    ce_end = connsm->anchor_point + connsm->conn_itvl_ticks -
+        g_ble_ll_sched_offset_ticks;
+    if ((connsm->anchor_point_usecs + connsm->conn_itvl_usecs) >= 31) {
+        ++ce_end;
+    }
+#else
+    itvl = (connsm->conn_itvl * BLE_LL_CONN_ITVL_USECS) -
+        XCVR_TX_SCHED_DELAY_USECS;
     ce_end = connsm->anchor_point + os_cputime_usecs_to_ticks(itvl);
+#endif
 
     if (ble_ll_sched_next_time(&next_sched_time)) {
         if (CPUTIME_LT(next_sched_time, ce_end)) {
@@ -1121,8 +1165,10 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch)
 {
     int rc;
     uint32_t usecs;
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) != 32768
     uint32_t wfr_time;
-    uint32_t txstart;
+#endif
+    uint32_t start;
     struct ble_ll_conn_sm *connsm;
 
     /* XXX: note that we can extend end time here if we want. Look at this */
@@ -1151,9 +1197,15 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch)
 #endif
 
     if (connsm->conn_role == BLE_LL_CONN_ROLE_MASTER) {
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+        /* Set start time of transmission */
+        start = sch->start_time + g_ble_ll_sched_offset_ticks;
+        rc = ble_phy_tx_set_start_time(start, sch->remainder);
+#else
         /* Set start time of transmission */
-        txstart = sch->start_time + os_cputime_usecs_to_ticks(XCVR_PROC_DELAY_USECS);
-        rc = ble_phy_tx_set_start_time(txstart);
+        start = sch->start_time + os_cputime_usecs_to_ticks(XCVR_TX_SCHED_DELAY_USECS);
+        rc = ble_phy_tx_set_start_time(start);
+#endif
         if (!rc) {
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION)
             if (CONN_F_ENCRYPTED(connsm)) {
@@ -1187,11 +1239,13 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch)
                 ble_phy_encrypt_disable();
             }
 #endif
-        /*
-         * XXX: make sure I dont care that I get here early to start receiving.
-         * I could use events compare and all that shit to start rx.
-         */
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+        /* XXX: what is this really for the slave? */
+        start = sch->start_time + g_ble_ll_sched_offset_ticks;
+        rc = ble_phy_rx_set_start_time(start, sch->remainder);
+#else
         rc = ble_phy_rx();
+#endif
         if (rc) {
             /* End the connection event as we have no more buffers */
             STATS_INC(ble_ll_conn_stats, slave_ce_failures);
@@ -1207,15 +1261,35 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch)
              * Set the wait for response time. The anchor point is when we
              * expect the master to start transmitting. Worst-case, we expect
              * to hear a reply within the anchor point plus:
-             *  -> the current tx window size
-             *  -> The current window widening amount
+             *  -> current tx window size
+             *  -> current window widening amount (includes +/- 16 usec jitter)
              *  -> Amount of time it takes to detect packet start.
+             *  -> Some extra time (16 usec) to insure timing is OK
              */
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+            /*
+             * For the 32 kHz crystal, the amount of usecs we have to wait
+             * is not from the anchor point; we have to account for the time
+             * from when the receiver is enabled until the anchor point. The
+             * time we start before the anchor point is this:
+             *   -> current window widening.
+             *   -> up to one 32 kHz tick since we discard remainder.
+             *   -> Up to one tick since the usecs to ticks calc can be off
+             *   by up to one tick.
+             * NOTES:
+             * 1) the 61 we add is for the two ticks mentioned above.
+             * 2) The address rx time and jitter is accounted for in the
+             * phy function
+             */
+            usecs = connsm->slave_cur_tx_win_usecs + 61 +
+                (2 * connsm->slave_cur_window_widening);
+            ble_phy_wfr_enable(BLE_PHY_WFR_ENABLE_RX, usecs);
+#else
             usecs = connsm->slave_cur_tx_win_usecs + BLE_LL_WFR_USECS +
                 connsm->slave_cur_window_widening;
             wfr_time = connsm->anchor_point + os_cputime_usecs_to_ticks(usecs);
             ble_ll_wfr_enable(wfr_time);
-
+#endif
             /* Set next wakeup time to connection event end time */
             rc = BLE_LL_SCHED_STATE_RUNNING;
         }
@@ -1246,15 +1320,20 @@ ble_ll_conn_event_start_cb(struct ble_ll_sched_item *sch)
  * @return int 0: not allowed to send 1: allowed to send
  */
 static int
-ble_ll_conn_can_send_next_pdu(struct ble_ll_conn_sm *connsm, uint32_t begtime)
+ble_ll_conn_can_send_next_pdu(struct ble_ll_conn_sm *connsm, uint32_t begtime,
+                              uint32_t add_usecs)
 {
     int rc;
     uint8_t rem_bytes;
     uint32_t ticks;
+    uint32_t usecs;
     uint32_t next_sched_time;
     struct os_mbuf *txpdu;
     struct os_mbuf_pkthdr *pkthdr;
     struct ble_mbuf_hdr *txhdr;
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    uint32_t allowed_usecs;
+#endif
 
     rc = 1;
     if (connsm->conn_role == BLE_LL_CONN_ROLE_MASTER) {
@@ -1277,16 +1356,25 @@ ble_ll_conn_can_send_next_pdu(struct ble_ll_conn_sm *connsm, uint32_t begtime)
             if (rem_bytes > connsm->eff_max_tx_octets) {
                 rem_bytes = connsm->eff_max_tx_octets;
             }
-            ticks = BLE_TX_DUR_USECS_M(rem_bytes);
+            usecs = BLE_TX_DUR_USECS_M(rem_bytes);
         } else {
             /* We will send empty pdu (just a LL header) */
-            ticks = BLE_TX_DUR_USECS_M(0);
+            usecs = BLE_TX_DUR_USECS_M(0);
         }
-        ticks += (BLE_LL_IFS * 2) + connsm->eff_max_rx_time;
-        ticks = os_cputime_usecs_to_ticks(ticks);
+        usecs += (BLE_LL_IFS * 2) + connsm->eff_max_rx_time;
+
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+        ticks = (uint32_t)(next_sched_time - begtime);
+        allowed_usecs = os_cputime_ticks_to_usecs(ticks);
+        if ((usecs + add_usecs) >= allowed_usecs) {
+            rc = 0;
+        }
+#else
+        ticks = os_cputime_usecs_to_ticks(usecs);
         if ((begtime + ticks) >= next_sched_time) {
             rc = 0;
         }
+#endif
     }
 
     return rc;
@@ -1347,7 +1435,15 @@ ble_ll_conn_master_init(struct ble_ll_conn_sm *connsm,
     connsm->conn_role = BLE_LL_CONN_ROLE_MASTER;
 
     /* Set default ce parameters */
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    /*
+     * XXX: for now, we need twice the transmit window as our calculations
+     * for the transmit window offset could be off.
+     */
+    connsm->tx_win_size = BLE_LL_CONN_TX_WIN_MIN + 1;
+#else
     connsm->tx_win_size = BLE_LL_CONN_TX_WIN_MIN;
+#endif
     connsm->tx_win_off = 0;
     connsm->master_sca = MYNEWT_VAL(BLE_LL_MASTER_SCA);
 
@@ -1482,6 +1578,10 @@ ble_ll_conn_sm_new(struct ble_ll_conn_sm *connsm)
                     connsm);
 #endif
 
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    ble_ll_conn_calc_itvl_ticks(connsm);
+#endif
+
     /* Add to list of active connections */
     SLIST_INSERT_HEAD(&g_ble_ll_conn_active_list, connsm, act_sle);
 }
@@ -1629,6 +1729,11 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
     uint32_t cur_ww;
     uint32_t max_ww;
     struct ble_ll_conn_upd_req *upd;
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    uint32_t ticks;
+    uint32_t usecs;
+#endif
+
 
     /* XXX: deal with connection request procedure here as well */
     ble_ll_conn_chk_csm_flags(connsm);
@@ -1647,7 +1752,24 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
     connsm->event_cntr += latency;
 
     /* Set next connection event start time */
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    /* We can use pre-calculated values for one interval if latency is 1. */
+    if (latency == 1) {
+        connsm->anchor_point += connsm->conn_itvl_ticks;
+        connsm->anchor_point_usecs += connsm->conn_itvl_usecs;
+    } else {
+        uint32_t ticks;
+        ticks = os_cputime_usecs_to_ticks(itvl);
+        connsm->anchor_point += ticks;
+        connsm->anchor_point_usecs += (itvl - os_cputime_ticks_to_usecs(ticks));
+    }
+    if (connsm->anchor_point_usecs >= 31) {
+        ++connsm->anchor_point;
+        connsm->anchor_point_usecs -= 31;
+    }
+#else
     connsm->anchor_point += os_cputime_usecs_to_ticks(itvl);
+#endif
 
     /*
      * If a connection update has been scheduled and the event counter
@@ -1669,15 +1791,30 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
             connsm->csmflags.cfbit.host_expects_upd_event = 1;
         }
 
-        connsm->conn_itvl = upd->interval;
         connsm->supervision_tmo = upd->timeout;
         connsm->slave_latency = upd->latency;
         connsm->tx_win_size = upd->winsize;
         connsm->slave_cur_tx_win_usecs =
             connsm->tx_win_size * BLE_LL_CONN_TX_WIN_USECS;
         connsm->tx_win_off = upd->winoffset;
+        connsm->conn_itvl = upd->interval;
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+        ble_ll_conn_calc_itvl_ticks(connsm);
+        if (upd->winoffset != 0) {
+            usecs = upd->winoffset * BLE_LL_CONN_ITVL_USECS;
+            ticks = os_cputime_usecs_to_ticks(usecs);
+            connsm->anchor_point += ticks;
+            usecs = usecs - os_cputime_ticks_to_usecs(ticks);
+            connsm->anchor_point_usecs += usecs;
+            if (connsm->anchor_point_usecs >= 31) {
+                ++connsm->anchor_point;
+                connsm->anchor_point_usecs -= 31;
+            }
+        }
+#else
         connsm->anchor_point +=
             os_cputime_usecs_to_ticks(upd->winoffset * BLE_LL_CONN_ITVL_USECS);
+#endif
 
         /* Reset the starting point of the connection supervision timeout */
         connsm->last_rxd_pdu_cputime = connsm->anchor_point;
@@ -1736,20 +1873,35 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
      * Calculate ce end time. For a slave, we need to add window widening and
      * the transmit window if we still have one.
      */
-    itvl = MYNEWT_VAL(BLE_LL_CONN_INIT_SLOTS) * BLE_LL_SCHED_USECS_PER_SLOT;
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    itvl = MYNEWT_VAL(BLE_LL_CONN_INIT_SLOTS) * BLE_LL_SCHED_32KHZ_TICKS_PER_SLOT;
     if (connsm->conn_role == BLE_LL_CONN_ROLE_SLAVE) {
         cur_ww = ble_ll_conn_calc_window_widening(connsm);
         max_ww = (connsm->conn_itvl * (BLE_LL_CONN_ITVL_USECS/2)) - BLE_LL_IFS;
         if (cur_ww >= max_ww) {
             return -1;
         }
+        cur_ww += BLE_LL_JITTER_USECS;
         connsm->slave_cur_window_widening = cur_ww;
+        itvl += os_cputime_usecs_to_ticks(cur_ww + connsm->slave_cur_tx_win_usecs);
+    }
+    itvl -= g_ble_ll_sched_offset_ticks;
+    connsm->ce_end_time = connsm->anchor_point + itvl;
+#else
+    itvl = MYNEWT_VAL(BLE_LL_CONN_INIT_SLOTS) * BLE_LL_SCHED_USECS_PER_SLOT;
+    if (connsm->conn_role == BLE_LL_CONN_ROLE_SLAVE) {
+        cur_ww = ble_ll_conn_calc_window_widening(connsm);
+        max_ww = (connsm->conn_itvl * (BLE_LL_CONN_ITVL_USECS/2)) - BLE_LL_IFS;
+        if (cur_ww >= max_ww) {
+            return -1;
+        }
+        connsm->slave_cur_window_widening = cur_ww + BLE_LL_JITTER_USECS;
         itvl += cur_ww + connsm->slave_cur_tx_win_usecs;
     } else {
-        /* We adjust end time for connection to end of time slot */
         itvl -= XCVR_TX_SCHED_DELAY_USECS;
     }
     connsm->ce_end_time = connsm->anchor_point + os_cputime_usecs_to_ticks(itvl);
+#endif
 
     return 0;
 }
@@ -1799,9 +1951,38 @@ ble_ll_conn_created(struct ble_ll_conn_sm *connsm, struct ble_mbuf_hdr *rxhdr)
      */
     rc = 1;
     if (connsm->conn_role == BLE_LL_CONN_ROLE_SLAVE) {
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+        /*
+         * With a 32.768 kHz crystal we dont care about the remaining usecs
+         * when setting last anchor point. The only thing last anchor is used
+         * for is to calculate window widening. The effect of this is
+         * negligible.
+         */
+        connsm->last_anchor_point = rxhdr->beg_cputime;
+
+        usecs = rxhdr->rem_usecs + 1250 +
+            (connsm->tx_win_off * BLE_LL_CONN_TX_WIN_USECS) +
+            BLE_TX_DUR_USECS_M(BLE_CONNECT_REQ_LEN);
+
+        /* Anchor point is cputime. */
+        endtime = os_cputime_usecs_to_ticks(usecs);
+        connsm->anchor_point = rxhdr->beg_cputime + endtime;
+        connsm->anchor_point_usecs = usecs - os_cputime_ticks_to_usecs(endtime);
+        if (connsm->anchor_point_usecs == 31) {
+            ++connsm->anchor_point;
+            connsm->anchor_point_usecs = 0;
+        }
+
+        connsm->slave_cur_tx_win_usecs =
+            connsm->tx_win_size * BLE_LL_CONN_TX_WIN_USECS;
+
+        connsm->ce_end_time = connsm->anchor_point +
+            (MYNEWT_VAL(BLE_LL_CONN_INIT_SLOTS) * BLE_LL_SCHED_32KHZ_TICKS_PER_SLOT)
+            + os_cputime_usecs_to_ticks(connsm->slave_cur_tx_win_usecs) + 1;
+#else
+        connsm->last_anchor_point = rxhdr->beg_cputime;
         endtime = rxhdr->beg_cputime +
             os_cputime_usecs_to_ticks(BLE_TX_DUR_USECS_M(BLE_CONNECT_REQ_LEN));
-        connsm->last_anchor_point = endtime;
         connsm->slave_cur_tx_win_usecs =
             connsm->tx_win_size * BLE_LL_CONN_TX_WIN_USECS;
         usecs = 1250 + (connsm->tx_win_off * BLE_LL_CONN_TX_WIN_USECS);
@@ -1810,7 +1991,8 @@ ble_ll_conn_created(struct ble_ll_conn_sm *connsm, struct ble_mbuf_hdr *rxhdr)
             (MYNEWT_VAL(BLE_LL_CONN_INIT_SLOTS) * BLE_LL_SCHED_USECS_PER_SLOT);
         connsm->ce_end_time = connsm->anchor_point +
             os_cputime_usecs_to_ticks(usecs);
-        connsm->slave_cur_window_widening = 0;
+#endif
+        connsm->slave_cur_window_widening = BLE_LL_JITTER_USECS;
 
         /* Start the scheduler for the first connection event */
         while (ble_ll_sched_slave_new(connsm)) {
@@ -1870,6 +2052,10 @@ ble_ll_conn_event_end(struct os_event *ev)
     /* Check if we need to resume scanning */
     ble_ll_scan_chk_resume();
 
+#ifdef BLE_XCVR_RFCLK
+    ble_ll_sched_rfclk_chk_restart();
+#endif
+
     /* If we have transmitted the terminate IND successfully, we are done */
     if ((connsm->csmflags.cfbit.terminate_ind_txd) ||
         (connsm->csmflags.cfbit.terminate_ind_rxd)) {
@@ -1958,6 +2144,7 @@ ble_ll_conn_event_end(struct os_event *ev)
     } else {
         tmo = connsm->supervision_tmo * BLE_HCI_CONN_SPVN_TMO_UNITS * 1000UL;
     }
+    /* XXX: Convert to ticks to usecs calculation instead??? */
     tmo = os_cputime_usecs_to_ticks(tmo);
     if ((int32_t)(connsm->anchor_point - connsm->last_rxd_pdu_cputime) >= tmo) {
         ble_ll_conn_end(connsm, BLE_ERR_CONN_SPVN_TMO);
@@ -2251,7 +2438,6 @@ ble_ll_init_rx_isr_end(uint8_t *rxbuf, uint8_t crcok,
     uint8_t *init_addr = NULL;
     uint8_t pyld_len;
     uint8_t inita_is_rpa;
-    uint32_t endtime;
     struct os_mbuf *rxpdu;
     struct ble_ll_conn_sm *connsm;
 
@@ -2366,10 +2552,7 @@ ble_ll_init_rx_isr_end(uint8_t *rxbuf, uint8_t crcok,
         }
 
         /* Attempt to schedule new connection. Possible that this might fail */
-        endtime = ble_hdr->beg_cputime +
-            os_cputime_usecs_to_ticks(BLE_TX_DUR_USECS_M(pyld_len));
-        if (!ble_ll_sched_master_new(connsm, endtime,
-                                     MYNEWT_VAL(BLE_LL_CONN_INIT_SLOTS))) {
+        if (!ble_ll_sched_master_new(connsm, ble_hdr, pyld_len)) {
             /* Setup to transmit the connect request */
             rc = ble_ll_conn_request_send(addr_type, adv_addr,
                                           connsm->tx_win_off, index);
@@ -2392,8 +2575,7 @@ init_rx_isr_exit:
      */
     rxpdu = ble_ll_rxpdu_alloc(pyld_len + BLE_LL_PDU_HDR_LEN);
     if (rxpdu == NULL) {
-        ble_phy_disable();
-        ble_phy_rx();
+        ble_phy_restart_rx();
         rc = 0;
     } else {
         ble_phy_rxpdu_copy(rxbuf, rxpdu);
@@ -2485,6 +2667,9 @@ ble_ll_conn_rx_isr_start(struct ble_mbuf_hdr *rxhdr, uint32_t aa)
             connsm->csmflags.cfbit.slave_set_last_anchor = 0;
             connsm->last_anchor_point = rxhdr->beg_cputime;
             connsm->anchor_point = connsm->last_anchor_point;
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+            connsm->anchor_point_usecs = rxhdr->rem_usecs;
+#endif
         }
     }
     return 1;
@@ -2646,6 +2831,7 @@ ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr)
     uint8_t opcode = 0;
     uint8_t rx_pyld_len;
     uint32_t endtime;
+    uint32_t add_usecs;
     struct os_mbuf *txpdu;
     struct ble_ll_conn_sm *connsm;
     struct os_mbuf *rxpdu;
@@ -2676,8 +2862,14 @@ ble_ll_conn_rx_isr_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr)
     }
 
     /* Calculate the end time of the received PDU */
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    endtime = rxhdr->beg_cputime;
+    add_usecs = rxhdr->rem_usecs + BLE_TX_DUR_USECS_M(rx_pyld_len);
+#else
     endtime = rxhdr->beg_cputime +
         os_cputime_usecs_to_ticks(BLE_TX_DUR_USECS_M(rx_pyld_len));
+    add_usecs = 0;
+#endif
 
     /*
      * Check the packet CRC. A connection event can continue even if the
@@ -2848,7 +3040,7 @@ chk_rx_terminate_ind:
     if (rx_pyld_len && CONN_F_ENCRYPTED(connsm)) {
         rx_pyld_len += BLE_LL_DATA_MIC_LEN;
     }
-    if (reply && ble_ll_conn_can_send_next_pdu(connsm, endtime)) {
+    if (reply && ble_ll_conn_can_send_next_pdu(connsm, endtime, add_usecs)) {
         rc = ble_ll_conn_tx_data_pdu(connsm);
     }
 
@@ -3032,7 +3224,6 @@ ble_ll_conn_set_global_chanmap(uint8_t num_used_chans, uint8_t *chanmap)
  * Context: Link Layer
  *
  * @param rxbuf Pointer to received Connect Request PDU
- * @param conn_req_end receive end time of connect request
  *
  * @return 0: connection not started; 1 connecton started
  */
@@ -3256,3 +3447,5 @@ ble_ll_conn_module_init(void)
     /* Call reset to finish reset of initialization */
     ble_ll_conn_module_reset();
 }
+
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/controller/src/ble_ll_conn_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn_priv.h b/net/nimble/controller/src/ble_ll_conn_priv.h
index 0913892..02cac60 100644
--- a/net/nimble/controller/src/ble_ll_conn_priv.h
+++ b/net/nimble/controller/src/ble_ll_conn_priv.h
@@ -42,12 +42,13 @@ extern "C" {
 #define BLE_LL_CONN_INITIAL_OFFSET          (1250)
 #define BLE_LL_CONN_ITVL_USECS              (1250)
 #define BLE_LL_CONN_TX_WIN_USECS            (1250)
+#define BLE_LL_CONN_TX_OFF_USECS            (1250)
 #define BLE_LL_CONN_CE_USECS                (625)
 #define BLE_LL_CONN_TX_WIN_MIN              (1)         /* in tx win units */
 #define BLE_LL_CONN_SLAVE_LATENCY_MAX       (499)
 
 /* Connection request duration (in usecs) */
-#define BLE_LL_CONN_REQ_DURATION            (352)
+#define BLE_LL_CONN_REQ_DURATION            (352)       /* 1 Mbps only */
 
 /* Connection handle range */
 #define BLE_LL_CONN_MAX_CONN_HANDLE         (0x0EFF)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/controller/src/ble_ll_scan.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_scan.c b/net/nimble/controller/src/ble_ll_scan.c
index f732753..f5eca7f 100644
--- a/net/nimble/controller/src/ble_ll_scan.c
+++ b/net/nimble/controller/src/ble_ll_scan.c
@@ -37,6 +37,7 @@
 #include "controller/ble_ll_hci.h"
 #include "controller/ble_ll_whitelist.h"
 #include "controller/ble_ll_resolv.h"
+#include "controller/ble_ll_xcvr.h"
 #include "hal/hal_gpio.h"
 
 /*
@@ -588,8 +589,14 @@ ble_ll_scan_start(struct ble_ll_scan_sm *scansm, uint8_t chan)
     }
 #endif
 
-    /* Start receiving */
-    rc = ble_phy_rx();
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+        /* XXX: probably need to make sure hfxo is running too */
+        /* XXX: can make this better; want to just start asap. */
+        rc = ble_phy_rx_set_start_time(os_cputime_get32() +
+                                       g_ble_ll_sched_offset_ticks, 0);
+#else
+        rc = ble_phy_rx();
+#endif
     if (!rc) {
         /* Enable/disable whitelisting */
         if (scansm->scan_filt_policy & 1) {
@@ -612,6 +619,37 @@ ble_ll_scan_start(struct ble_ll_scan_sm *scansm, uint8_t chan)
     }
 }
 
+#ifdef BLE_XCVR_RFCLK
+static void
+ble_ll_scan_rfclk_chk_stop(void)
+{
+    int stop;
+    int32_t time_till_next;
+    os_sr_t sr;
+    uint32_t next_time;
+
+    stop = 0;
+    OS_ENTER_CRITICAL(sr);
+    if (ble_ll_sched_next_time(&next_time)) {
+        /*
+         * If the time until the next event is too close, dont bother to turn
+         * off the clock
+         */
+        time_till_next = (int32_t)(next_time - os_cputime_get32());
+        if (time_till_next > g_ble_ll_data.ll_xtal_ticks) {
+            stop = 1;
+        }
+    } else {
+        stop = 1;
+    }
+    if (stop) {
+        ble_ll_log(BLE_LL_LOG_ID_RFCLK_SCAN_DIS, g_ble_ll_data.ll_rfclk_state,0,0);
+        ble_ll_xcvr_rfclk_disable();
+    }
+    OS_EXIT_CRITICAL(sr);
+}
+#endif
+
 /**
  * Called to determine if we are inside or outside the scan window. If we
  * are inside the scan window it means that the device should be receiving
@@ -629,6 +667,7 @@ ble_ll_scan_window_chk(struct ble_ll_scan_sm *scansm, uint32_t cputime)
     int rc;
     uint8_t chan;
     uint32_t itvl;
+    uint32_t dt;
     uint32_t win_start;
 
     itvl = os_cputime_usecs_to_ticks(scansm->scan_itvl * BLE_HCI_SCAN_ITVL);
@@ -645,7 +684,13 @@ ble_ll_scan_window_chk(struct ble_ll_scan_sm *scansm, uint32_t cputime)
     rc = 0;
     if (scansm->scan_window != scansm->scan_itvl) {
         itvl = os_cputime_usecs_to_ticks(scansm->scan_window * BLE_HCI_SCAN_ITVL);
-        if ((cputime - win_start) >= itvl) {
+        dt = cputime - win_start;
+        if (dt >= itvl) {
+#ifdef BLE_XCVR_RFCLK
+            if (dt < (scansm->scan_itvl - g_ble_ll_data.ll_xtal_ticks)) {
+                ble_ll_scan_rfclk_chk_stop();
+            }
+#endif
             rc = 1;
         }
     }
@@ -688,6 +733,11 @@ ble_ll_scan_sm_stop(int chk_disable)
 
             /* Set LL state to standby */
             ble_ll_state_set(BLE_LL_STATE_STANDBY);
+
+            /* May need to stop the rfclk */
+#ifdef BLE_XCVR_RFCLK
+            ble_ll_scan_rfclk_chk_stop();
+#endif
         }
         OS_EXIT_CRITICAL(sr);
     }
@@ -757,6 +807,9 @@ ble_ll_scan_event_proc(struct os_event *ev)
     uint32_t win_start;
     uint32_t scan_itvl;
     uint32_t next_event_time;
+#ifdef BLE_XCVR_RFCLK
+    uint32_t xtal_ticks;
+#endif
     struct ble_ll_scan_sm *scansm;
 
     /*
@@ -786,12 +839,19 @@ ble_ll_scan_event_proc(struct os_event *ev)
     dt = now - win_start;
     scansm->scan_chan = chan;
     scansm->scan_win_start_time = win_start;
+    if (scansm->scan_window != scansm->scan_itvl) {
+        win = os_cputime_usecs_to_ticks(scansm->scan_window * BLE_HCI_SCAN_ITVL);
+    } else {
+        win = 0;
+    }
 
     /* Determine on/off state based on scan window */
     rxstate = 1;
     next_event_time = win_start + scan_itvl;
-    if (scansm->scan_window != scansm->scan_itvl) {
-        win = os_cputime_usecs_to_ticks(scansm->scan_window * BLE_HCI_SCAN_ITVL);
+
+    OS_ENTER_CRITICAL(sr);
+
+    if (win != 0) {
         if (dt >= win) {
             rxstate = 0;
         } else {
@@ -799,7 +859,6 @@ ble_ll_scan_event_proc(struct os_event *ev)
         }
     }
 
-    OS_ENTER_CRITICAL(sr);
     /*
      * If we are not in the standby state it means that the scheduled
      * scanning event was overlapped in the schedule. In this case all we do
@@ -815,6 +874,9 @@ ble_ll_scan_event_proc(struct os_event *ev)
     case BLE_LL_STATE_SCANNING:
         /* Must disable PHY since we will move to a new channel */
         ble_phy_disable();
+        if (!rxstate) {
+            ble_ll_state_set(BLE_LL_STATE_STANDBY);
+        }
         break;
     case BLE_LL_STATE_STANDBY:
         break;
@@ -822,11 +884,70 @@ ble_ll_scan_event_proc(struct os_event *ev)
         assert(0);
         break;
     }
+
+#ifdef BLE_XCVR_RFCLK
+    if (rxstate == 0) {
+        /*
+         * We need to wake up before we need to start scanning in order
+         * to make sure the rfclock is on. If we are close to being on,
+         * enable the rfclock. If not, set wakeup time.
+         */
+        if (dt >= (scan_itvl - g_ble_ll_data.ll_xtal_ticks)) {
+            /* Start the clock if necessary */
+            if (start_scan) {
+                if (ble_ll_xcvr_rfclk_state() == BLE_RFCLK_STATE_OFF) {
+                    ble_ll_xcvr_rfclk_start_now(now);
+                    next_event_time = now + g_ble_ll_data.ll_xtal_ticks;
+                }
+            }
+        } else {
+            next_event_time -= g_ble_ll_data.ll_xtal_ticks;
+            if (start_scan) {
+                ble_ll_scan_rfclk_chk_stop();
+            }
+        }
+    }
+#endif
+
     if (start_scan && rxstate) {
+#ifdef BLE_XCVR_RFCLK
+        /* NOTE: reuse rxstate */
+        rxstate = ble_ll_xcvr_rfclk_state();
+        if (rxstate != BLE_RFCLK_STATE_SETTLED) {
+            if (rxstate == BLE_RFCLK_STATE_OFF) {
+                xtal_ticks = g_ble_ll_data.ll_xtal_ticks;
+            } else {
+                xtal_ticks = ble_ll_xcvr_rfclk_time_till_settled();
+            }
+
+            /*
+             * Only bother if we have enough time to receive anything
+             * here. The next event time will turn off the clock.
+             */
+            if (win != 0) {
+                if ((win - dt) <= xtal_ticks)  {
+                    goto rfclk_not_settled;
+                }
+            }
+
+            /*
+             * If clock off, start clock. Set next event time to now plus
+             * the clock setting time.
+             */
+            if (rxstate == BLE_RFCLK_STATE_OFF) {
+                ble_ll_xcvr_rfclk_start_now(now);
+            }
+            next_event_time = now + xtal_ticks;
+            goto rfclk_not_settled;
+        }
+#endif
         ble_ll_scan_start(scansm, scansm->scan_chan);
     }
-    OS_EXIT_CRITICAL(sr);
 
+#ifdef BLE_XCVR_RFCLK
+rfclk_not_settled:
+#endif
+    OS_EXIT_CRITICAL(sr);
     os_cputime_timer_start(&scansm->scan_timer, next_event_time);
 }
 
@@ -929,8 +1050,7 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
         if (scansm->scan_rsp_pending) {
             ble_ll_scan_req_backoff(scansm, 0);
         }
-        ble_phy_disable();
-        ble_phy_rx();
+        ble_phy_restart_rx();
         return 0;
     }
 
@@ -1081,8 +1201,6 @@ ble_ll_scan_wfr_timer_exp(void)
 {
     struct ble_ll_scan_sm *scansm;
 
-    ble_phy_disable();
-
     /*
      * If we timed out waiting for a response, the scan response pending
      * flag should be set. Deal with scan backoff. Put device back into rx.
@@ -1091,7 +1209,8 @@ ble_ll_scan_wfr_timer_exp(void)
     if (scansm->scan_rsp_pending) {
         ble_ll_scan_req_backoff(scansm, 0);
     }
-    ble_phy_rx();
+
+    ble_phy_restart_rx();
 }
 
 /**
@@ -1480,7 +1599,7 @@ ble_ll_scan_init(void)
     scansm->scan_itvl = BLE_HCI_SCAN_ITVL_DEF;
     scansm->scan_window = BLE_HCI_SCAN_WINDOW_DEF;
 
-    /* Initialize connection supervision timer */
+    /* Initialize scanning timer */
     os_cputime_timer_init(&scansm->scan_timer, ble_ll_scan_timer_cb, scansm);
 
     /* Get a scan request mbuf (packet header) and attach to state machine */


[07/50] [abbrv] incubator-mynewt-core git commit: This closes #203.

Posted by we...@apache.org.
This closes #203.

Merge branch 'fix-ctrl-c-win2' of https://github.com/mkiiskila/incubator-mynewt-core into develop


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/631db770
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/631db770
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/631db770

Branch: refs/heads/nrf_cputime
Commit: 631db770443b9f208ca37712e8f040c01c439fba
Parents: 2b3d6cc f6951e6
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Mar 10 13:28:54 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Mar 10 13:28:54 2017 -0800

----------------------------------------------------------------------
 hw/scripts/common.sh  | 14 ++++++++
 hw/scripts/jlink.sh   | 80 +++++++++++++++++++++++++++-------------------
 hw/scripts/openocd.sh | 36 +++++++++++++++------
 3 files changed, 89 insertions(+), 41 deletions(-)
----------------------------------------------------------------------



[09/50] [abbrv] incubator-mynewt-core git commit: bsp/stm32f429: Fix nvic vectors number to 16 + 91

Posted by we...@apache.org.
bsp/stm32f429: Fix nvic vectors number to 16 + 91

>From st datasheet page 24:

    The devices embed a nested vectored interrupt controller
    able to manage 16 priority levels, and handle up to 91
    maskable interrupt channels plus the 16 interrupt lines
    of the Cortex�-M4 with FPU core.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/37d85d86
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/37d85d86
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/37d85d86

Branch: refs/heads/nrf_cputime
Commit: 37d85d86ce4cba0cf80f36b6f6e0cdacd7c472e9
Parents: 7059298
Author: Louie Lu <me...@louie.lu>
Authored: Sat Mar 11 22:53:26 2017 +0800
Committer: Louie Lu <me...@louie.lu>
Committed: Sat Mar 11 22:53:26 2017 +0800

----------------------------------------------------------------------
 hw/bsp/stm32f429discovery/include/bsp/cmsis_nvic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/37d85d86/hw/bsp/stm32f429discovery/include/bsp/cmsis_nvic.h
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f429discovery/include/bsp/cmsis_nvic.h b/hw/bsp/stm32f429discovery/include/bsp/cmsis_nvic.h
index e9a9329..69f9b63 100644
--- a/hw/bsp/stm32f429discovery/include/bsp/cmsis_nvic.h
+++ b/hw/bsp/stm32f429discovery/include/bsp/cmsis_nvic.h
@@ -9,7 +9,7 @@
 
 #include <stdint.h>
 
-#define NVIC_NUM_VECTORS      (16 + 81)   // CORE + MCU Peripherals
+#define NVIC_NUM_VECTORS      (16 + 91)   // CORE + MCU Peripherals
 #define NVIC_USER_IRQ_OFFSET  16
 
 #include "stm32f429xx.h"


[26/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-677 NMP: Include next_index in log show rsp

Posted by we...@apache.org.
MYNEWT-677 NMP: Include next_index in log show rsp

The next_index value (index of next log entry to be written) is useful
for determining if a device's flash has been wiped since the last time
logs were scoured.

The new value is at the top-level of the log show response with the
following name: next_index.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d7a9e96a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d7a9e96a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d7a9e96a

Branch: refs/heads/nrf_cputime
Commit: d7a9e96a9f17270d371ce421697c4407b1647bf4
Parents: f23fbe7
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Mar 17 12:51:11 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Mar 17 12:51:11 2017 -0700

----------------------------------------------------------------------
 sys/log/full/src/log_nmgr.c | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d7a9e96a/sys/log/full/src/log_nmgr.c
----------------------------------------------------------------------
diff --git a/sys/log/full/src/log_nmgr.c b/sys/log/full/src/log_nmgr.c
index 00beeba..8615fb7 100644
--- a/sys/log/full/src/log_nmgr.c
+++ b/sys/log/full/src/log_nmgr.c
@@ -279,6 +279,8 @@ log_nmgr_read(struct mgmt_cbuf *cb)
         return rc;
     }
 
+    g_err |= cbor_encode_text_stringz(&cb->encoder, "next_index");
+    g_err |= cbor_encode_int(&cb->encoder, g_log_info.li_next_index);
 
     g_err |= cbor_encode_text_stringz(&cb->encoder, "logs");
     g_err |= cbor_encoder_create_array(&cb->encoder, &logs,


[36/50] [abbrv] incubator-mynewt-core git commit: nimble/controller: Minor fix to avoid magic number

Posted by we...@apache.org.
nimble/controller: Minor fix to avoid magic number


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/0f103799
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/0f103799
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/0f103799

Branch: refs/heads/nrf_cputime
Commit: 0f1037994bfd4d5007a50f9f80d5f544fc885bd7
Parents: b05acb1
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Tue Mar 21 11:50:35 2017 +0100
Committer: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Committed: Wed Mar 22 14:20:40 2017 +0100

----------------------------------------------------------------------
 net/nimble/controller/src/ble_ll_ctrl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0f103799/net/nimble/controller/src/ble_ll_ctrl.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_ctrl.c b/net/nimble/controller/src/ble_ll_ctrl.c
index 03f2836..1ba93bd 100644
--- a/net/nimble/controller/src/ble_ll_ctrl.c
+++ b/net/nimble/controller/src/ble_ll_ctrl.c
@@ -1722,7 +1722,7 @@ ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
 
     /* Free mbuf or send response */
 ll_ctrl_send_rsp:
-    if (rsp_opcode == 255) {
+    if (rsp_opcode == BLE_ERR_MAX) {
         os_mbuf_free_chain(om);
     } else {
         /*


[25/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-676 - Oops, fix broken apps.

Posted by we...@apache.org.
MYNEWT-676 - Oops, fix broken apps.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f23fbe77
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f23fbe77
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f23fbe77

Branch: refs/heads/nrf_cputime
Commit: f23fbe77dabe3226359c7790bbdd3d7847ee9a0a
Parents: d1f00e9
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Mar 17 12:23:58 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Mar 17 12:23:58 2017 -0700

----------------------------------------------------------------------
 apps/sensors_test/src/main.c   | 2 +-
 apps/slinky/src/main.c         | 2 +-
 apps/slinky_oic/src/main.c     | 2 +-
 apps/splitty/src/main.c        | 2 +-
 apps/testbench/src/testbench.c | 2 +-
 apps/testbench/src/testbench.h | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f23fbe77/apps/sensors_test/src/main.c
----------------------------------------------------------------------
diff --git a/apps/sensors_test/src/main.c b/apps/sensors_test/src/main.c
index 8ecbccd..ac694be 100755
--- a/apps/sensors_test/src/main.c
+++ b/apps/sensors_test/src/main.c
@@ -46,7 +46,7 @@
 #include <assert.h>
 #include <string.h>
 #include <flash_test/flash_test.h>
-#include <reboot/reboot_start.h>
+#include <reboot/log_reboot.h>
 #include <os/os_time.h>
 #include <id/id.h>
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f23fbe77/apps/slinky/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky/src/main.c b/apps/slinky/src/main.c
index 2e74801..d0fd099 100755
--- a/apps/slinky/src/main.c
+++ b/apps/slinky/src/main.c
@@ -41,7 +41,7 @@
 #include <assert.h>
 #include <string.h>
 #include <flash_test/flash_test.h>
-#include <reboot/reboot_start.h>
+#include <reboot/log_reboot.h>
 #include <os/os_time.h>
 #include <id/id.h>
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f23fbe77/apps/slinky_oic/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky_oic/src/main.c b/apps/slinky_oic/src/main.c
index 115fa33..d606295 100755
--- a/apps/slinky_oic/src/main.c
+++ b/apps/slinky_oic/src/main.c
@@ -37,7 +37,7 @@
 #include <oic/oc_api.h>
 #include <assert.h>
 #include <string.h>
-#include <reboot/reboot_start.h>
+#include <reboot/log_reboot.h>
 #include <os/os_time.h>
 
 #ifdef ARCH_sim

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f23fbe77/apps/splitty/src/main.c
----------------------------------------------------------------------
diff --git a/apps/splitty/src/main.c b/apps/splitty/src/main.c
index 6362187..80bcd54 100755
--- a/apps/splitty/src/main.c
+++ b/apps/splitty/src/main.c
@@ -34,7 +34,7 @@
 #include <imgmgr/imgmgr.h>
 #include <assert.h>
 #include <string.h>
-#include <reboot/reboot_start.h>
+#include <reboot/log_reboot.h>
 #include <os/os_time.h>
 #include <id/id.h>
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f23fbe77/apps/testbench/src/testbench.c
----------------------------------------------------------------------
diff --git a/apps/testbench/src/testbench.c b/apps/testbench/src/testbench.c
index 5345d6f..19b0ebf 100644
--- a/apps/testbench/src/testbench.c
+++ b/apps/testbench/src/testbench.c
@@ -43,7 +43,7 @@
 #include <assert.h>
 #include <string.h>
 #include <json/json.h>
-#include <reboot/reboot_start.h>
+#include <reboot/log_reboot.h>
 #include <os/os_time.h>
 #include <id/id.h>
 #include <os/os_eventq.h>

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f23fbe77/apps/testbench/src/testbench.h
----------------------------------------------------------------------
diff --git a/apps/testbench/src/testbench.h b/apps/testbench/src/testbench.h
index 8b39310..a94ee1c 100644
--- a/apps/testbench/src/testbench.h
+++ b/apps/testbench/src/testbench.h
@@ -46,7 +46,7 @@
 #include <assert.h>
 #include <string.h>
 #include <json/json.h>
-#include <reboot/reboot_start.h>
+#include <reboot/log_reboot.h>
 #include <os/os_time.h>
 #include <id/id.h>
 


[15/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-665 SensorAPI: Add TCS34725 Driver

Posted by we...@apache.org.
MYNEWT-665 SensorAPI: Add TCS34725 Driver

- reading from ATIME, control for AGAIN and ENABLE for state of the
  sensor instead of using varibales to store state.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/fd20bc93
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/fd20bc93
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/fd20bc93

Branch: refs/heads/nrf_cputime
Commit: fd20bc93e84b81cd9e4ff164f8ac976350c5bc50
Parents: 20ffb7e
Author: Vipul Rahane <vi...@apache.org>
Authored: Tue Mar 14 16:24:03 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Mar 14 16:24:03 2017 -0700

----------------------------------------------------------------------
 hw/drivers/sensors/tcs34725/src/tcs34725.c      | 78 +++++++++++++-------
 hw/drivers/sensors/tcs34725/src/tcs34725_priv.h | 21 +++---
 .../sensors/tcs34725/src/tcs34725_shell.c       | 29 +++++---
 3 files changed, 84 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd20bc93/hw/drivers/sensors/tcs34725/src/tcs34725.c
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/tcs34725/src/tcs34725.c b/hw/drivers/sensors/tcs34725/src/tcs34725.c
index e20ecde..e535512 100644
--- a/hw/drivers/sensors/tcs34725/src/tcs34725.c
+++ b/hw/drivers/sensors/tcs34725/src/tcs34725.c
@@ -91,10 +91,6 @@ static const struct sensor_driver g_tcs34725_sensor_driver = {
     tcs34725_sensor_get_config
 };
 
-uint8_t g_tcs34725_gain;
-uint8_t g_tcs34725_integration_time;
-uint8_t g_tcs34725_enabled;
-
 /**
  * Writes a single byte to the specified register
  *
@@ -332,8 +328,6 @@ tcs34725_enable(uint8_t enable)
         }
     }
 
-    g_tcs34725_enabled = enable;
-
     return 0;
 err:
     return rc;
@@ -399,12 +393,25 @@ err:
 /**
  * Indicates whether the sensor is enabled or not
  *
- * @return 1 if enabled, 0 if disabled
+ * @param ptr to is_enabled variable
+ * @return 0 on success, non-zero on failure
  */
-uint8_t
-tcs34725_get_enable (void)
+int
+tcs34725_get_enable (uint8_t *is_enabled)
 {
-    return g_tcs34725_enabled;
+    int rc;
+    uint8_t tmp;
+
+    rc = tcs34725_read8(TCS34725_REG_ENABLE, &tmp);
+    if (rc) {
+        goto err;
+    }
+
+    *is_enabled = tmp;
+
+    return 0;
+err:
+    return rc;
 }
 
 /**
@@ -418,14 +425,12 @@ tcs34725_set_integration_time(uint8_t int_time)
 {
     int rc;
 
-    rc = tcs34725_write8(TCS34725_REG_ATIME,
-                         int_time | g_tcs34725_gain);
+    rc = tcs34725_write8(TCS34725_REG_ATIME, int_time);
     if (rc) {
         goto err;
     }
 
-    g_tcs34725_integration_time = int_time;
-
+    return 0;
 err:
     return rc;
 }
@@ -433,12 +438,23 @@ err:
 /**
  * Gets integration time set earlier
  *
- * @return integration time
+ * @param ptr to integration time
+ * @return 0 on success, non-zero on failure
  */
-uint8_t
-tcs34725_get_integration_time(void)
+int
+tcs34725_get_integration_time(uint8_t *int_time)
 {
-    return g_tcs34725_integration_time;
+    int rc;
+    uint8_t tmp;
+
+    rc = tcs34725_read8(TCS34725_REG_ATIME, &tmp);
+    if (rc) {
+        goto err;
+    }
+
+    return 0;
+err:
+    return rc;
 }
 
 /**
@@ -458,14 +474,11 @@ tcs34725_set_gain(uint8_t gain)
         goto err;
     }
 
-    rc = tcs34725_write8(TCS34725_REG_CONTROL,
-                        g_tcs34725_integration_time | gain);
+    rc = tcs34725_write8(TCS34725_REG_CONTROL, gain);
     if (rc) {
         goto err;
     }
 
-    g_tcs34725_gain = gain;
-
 err:
     return rc;
 }
@@ -473,12 +486,25 @@ err:
 /**
  * Get gain of the sensor
  *
- * @return gain
+ * @param ptr to gain
+ * @return 0 on success, non-zero on failure
  */
-uint8_t
-tcs34725_get_gain(void)
+int
+tcs34725_get_gain(uint8_t *gain)
 {
-    return g_tcs34725_gain;
+    int rc;
+    uint8_t tmp;
+
+    rc = tcs34725_read8(TCS34725_REG_CONTROL, &tmp);
+    if (rc) {
+        goto err;
+    }
+
+    *gain = tmp;
+
+    return 0;
+err:
+    return rc;
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd20bc93/hw/drivers/sensors/tcs34725/src/tcs34725_priv.h
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/tcs34725/src/tcs34725_priv.h b/hw/drivers/sensors/tcs34725/src/tcs34725_priv.h
index 5d5448c..1dcfb13 100644
--- a/hw/drivers/sensors/tcs34725/src/tcs34725_priv.h
+++ b/hw/drivers/sensors/tcs34725/src/tcs34725_priv.h
@@ -179,10 +179,11 @@ tcs34725_get_chip_id(uint8_t *id);
 /**
  * Get gain of the sensor
  *
- * @return gain
+ * @param ptr to gain
+ * @return 0 on success, non-zero on failure
  */
-uint8_t
-tcs34725_get_gain(void);
+int
+tcs34725_get_gain(uint8_t *gain);
 
 /**
  * Set gain of the sensor
@@ -235,10 +236,11 @@ tcs34725_set_integration_time(uint8_t int_time);
 /**
  * Gets integration time set earlier
  *
- * @return integration time
+ * @param ptr to integration time
+ * @return 0 on success, non-zero on failure
  */
-uint8_t
-tcs34725_get_integration_time(void);
+int
+tcs34725_get_integration_time(uint8_t *int_time);
 
 /**
  *
@@ -253,10 +255,11 @@ tcs34725_enable(uint8_t enable);
 /**
  * Indicates whether the sensor is enabled or not
  *
- * @return 1 if enabled, 0 if disabled
+ * @param ptr to is_enabled variable
+ * @return 0 on success, non-zero on failure
  */
-uint8_t
-tcs34725_get_enable (void);
+int
+tcs34725_get_enable (uint8_t *is_enabled);
 
 /**
  * Reads the raw red, green, blue and clear channel values

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fd20bc93/hw/drivers/sensors/tcs34725/src/tcs34725_shell.c
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/tcs34725/src/tcs34725_shell.c b/hw/drivers/sensors/tcs34725/src/tcs34725_shell.c
index e15b4fc..d231d5f 100644
--- a/hw/drivers/sensors/tcs34725/src/tcs34725_shell.c
+++ b/hw/drivers/sensors/tcs34725/src/tcs34725_shell.c
@@ -27,9 +27,6 @@
 #include "defs/error.h"
 
 #if MYNEWT_VAL(TCS34725_CLI)
-extern uint8_t g_tcs34725_integration_time;
-extern uint8_t g_tcs34725_gain;
-
 static int tcs34725_shell_cmd(int argc, char **argv);
 
 static struct shell_cmd tcs34725_shell_cmd_struct = {
@@ -121,9 +118,6 @@ tcs34725_shell_cmd_read(int argc, char **argv)
 
     while(samples--) {
 
-        tcs34725.cfg.gain = g_tcs34725_gain;
-        tcs34725.cfg.integration_time = g_tcs34725_integration_time;
-
         rc = tcs34725_get_rawdata(&r, &g, &b, &c, &tcs34725);
         if (rc) {
             console_printf("Read failed: %d\n", rc);
@@ -150,7 +144,10 @@ tcs34725_shell_cmd_gain(int argc, char **argv)
 
     /* Display the gain */
     if (argc == 2) {
-        gain = tcs34725_get_gain();
+        rc = tcs34725_get_gain(&gain);
+        if (rc) {
+            goto err;
+        }
         console_printf("\tgain [0: 1|1: 4|2: 16|3: 60]\n");
         console_printf("%u\n", gain);
     }
@@ -189,7 +186,11 @@ tcs34725_shell_cmd_time(int argc, char **argv)
 
     /* Display the integration time */
     if (argc == 2) {
-        time = tcs34725_get_integration_time();
+        rc = tcs34725_get_integration_time(&time);
+        if (rc) {
+            goto err;
+        }
+
         switch (time) {
             case TCS34725_INTEGRATIONTIME_2_4MS:
                 console_printf("2.4\n");
@@ -338,14 +339,22 @@ tcs34725_shell_cmd_en(int argc, char **argv)
 {
     char *endptr;
     long lval;
+    int rc;
+    uint8_t is_enabled;
 
+    rc = 0;
     if (argc > 3) {
         return tcs34725_shell_err_too_many_args(argv[1]);
     }
 
     /* Display current enable state */
     if (argc == 2) {
-        console_printf("%u\n", tcs34725_get_enable());
+        rc = tcs34725_get_enable(&is_enabled);
+        if (rc) {
+            console_printf("Cannot get enable state of the sensor\n");
+            goto err;
+        }
+        console_printf("%u\n", is_enabled);
     }
 
     /* Update the enable state */
@@ -360,6 +369,8 @@ tcs34725_shell_cmd_en(int argc, char **argv)
     }
 
     return 0;
+err:
+    return rc;
 }
 
 static int


[34/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-678 SensorAPI: Shell:

Posted by we...@apache.org.
MYNEWT-678 SensorAPI: Shell:

- Add support for polling at a given interval for a
  specific duration(Use os_cputime instead of a dedicated HW hal_timer)

  "sensor read <sensor_name> <type> [-n nsamples] [-i poll_itvl] [-d duration]"


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/68265625
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/68265625
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/68265625

Branch: refs/heads/nrf_cputime
Commit: 68265625d5c27ebaddd5d4b1d64acbbb30d3db90
Parents: d23fab9
Author: Vipul Rahane <vi...@apache.org>
Authored: Tue Mar 21 11:37:54 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Mar 21 11:46:30 2017 -0700

----------------------------------------------------------------------
 hw/sensor/src/sensor_shell.c | 50 +++++++++++++--------------------------
 hw/sensor/syscfg.yml         |  8 -------
 2 files changed, 16 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/68265625/hw/sensor/src/sensor_shell.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_shell.c b/hw/sensor/src/sensor_shell.c
index 3b6dc43..8d96445 100644
--- a/hw/sensor/src/sensor_shell.c
+++ b/hw/sensor/src/sensor_shell.c
@@ -40,7 +40,7 @@
 #include "console/console.h"
 #include "shell/shell.h"
 #include "hal/hal_i2c.h"
-#include "hal/hal_timer.h"
+#include "os/os_cputime.h"
 
 static int sensor_cmd_exec(int, char **);
 static struct shell_cmd shell_sensor_cmd = {
@@ -51,7 +51,6 @@ static struct shell_cmd shell_sensor_cmd = {
 struct os_sem g_sensor_shell_sem;
 struct hal_timer g_sensor_shell_timer;
 uint32_t sensor_shell_timer_arg = 0xdeadc0de;
-uint8_t g_timer_is_config;
 
 struct sensor_poll_data {
     int spd_nsamples;
@@ -277,38 +276,22 @@ void
 sensor_shell_timer_cb(void *arg)
 {
     int timer_arg_val;
-    int rc;
 
     timer_arg_val = *(uint32_t *)arg;
+    os_cputime_timer_relative(&g_sensor_shell_timer, timer_arg_val);
     os_sem_release(&g_sensor_shell_sem);
-    rc = hal_timer_start(&g_sensor_shell_timer, timer_arg_val);
-    assert(rc == 0);
 }
 
-/* HAL timer configuration */
+/* os cputime timer configuration and initialization */
 static void
 sensor_shell_config_timer(struct sensor_poll_data *spd)
 {
-    int rc;
-
-    if (!g_timer_is_config) {
-        rc = hal_timer_config(MYNEWT_VAL(SENSOR_SHELL_TIMER_NUM),
-                 MYNEWT_VAL(SENSOR_SHELL_TIMER_FREQ));
-        assert(rc == 0);
-        g_timer_is_config = 1;
-    }
-
-    sensor_shell_timer_arg =
-        (spd->spd_poll_itvl * 1000000) / hal_timer_get_resolution(MYNEWT_VAL(SENSOR_SHELL_TIMER_NUM));
+    sensor_shell_timer_arg = os_cputime_usecs_to_ticks(spd->spd_poll_itvl * 1000);
 
-    rc = hal_timer_set_cb(MYNEWT_VAL(SENSOR_SHELL_TIMER_NUM),
-                          &g_sensor_shell_timer,
-                          sensor_shell_timer_cb,
+    os_cputime_timer_init(&g_sensor_shell_timer, sensor_shell_timer_cb,
                           &sensor_shell_timer_arg);
-    assert(rc == 0);
 
-    rc = hal_timer_start(&g_sensor_shell_timer, sensor_shell_timer_arg);
-    assert(rc == 0);
+    os_cputime_timer_relative(&g_sensor_shell_timer, sensor_shell_timer_arg);
 }
 
 /* Check for number of samples */
@@ -318,7 +301,7 @@ sensor_shell_chk_nsamples(struct sensor_poll_data *spd,
 {
     /* Condition for number of samples */
     if (spd->spd_nsamples && ctx->num_entries >= spd->spd_nsamples) {
-        hal_timer_stop(&g_sensor_shell_timer);
+        os_cputime_timer_stop(&g_sensor_shell_timer);
         return 0;
     }
 
@@ -338,7 +321,7 @@ sensor_shell_chk_escape_seq(void)
     rc = console_read(&ch, 1, &newline);
     /* ^C or q or Q gets it out of the sampling loop */
     if (rc || (ch == 3 || ch == 'q' || ch == 'Q')) {
-        hal_timer_stop(&g_sensor_shell_timer);
+        os_cputime_timer_stop(&g_sensor_shell_timer);
         console_printf("Sensor polling stopped rc:%u\n", rc);
         return 0;
     }
@@ -351,24 +334,23 @@ sensor_shell_chk_escape_seq(void)
  * os_time if interval is not specified and checking duration
  */
 static int
-sensor_shell_polling_done(struct sensor_poll_data *spd,
-                          int64_t *start_ts,
-                          int *duration)
+sensor_shell_polling_done(struct sensor_poll_data *spd, int64_t *duration,
+                          int64_t *start_ts)
 {
 
     if (spd->spd_poll_duration) {
         if (spd->spd_poll_itvl) {
-            *duration += spd->spd_poll_itvl;
+            *duration += spd->spd_poll_itvl * 1000;
         } else {
             if (!*start_ts) {
-                *start_ts = os_get_uptime_usec()/1000;
+                *start_ts = os_get_uptime_usec();
             } else {
-                *duration = os_get_uptime_usec()/1000 - *start_ts;
+                *duration = os_get_uptime_usec() - *start_ts;
             }
         }
 
-        if (*duration >= spd->spd_poll_duration) {
-            hal_timer_stop(&g_sensor_shell_timer);
+        if (*duration >= spd->spd_poll_duration * 1000) {
+            os_cputime_timer_stop(&g_sensor_shell_timer);
             console_printf("Sensor polling done\n");
             return 0;
         }
@@ -384,7 +366,7 @@ sensor_cmd_read(char *name, sensor_type_t type, struct sensor_poll_data *spd)
     struct sensor_listener listener;
     struct sensor_shell_read_ctx ctx;
     int rc;
-    int duration;
+    int64_t duration;
     int64_t start_ts;
 
     /* Look up sensor by name */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/68265625/hw/sensor/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/sensor/syscfg.yml b/hw/sensor/syscfg.yml
index a4b6ee9..879fbb2 100644
--- a/hw/sensor/syscfg.yml
+++ b/hw/sensor/syscfg.yml
@@ -26,11 +26,3 @@ syscfg.defs:
     SENSOR_CLI:
         description: 'Whether or not to enable the sensor shell support'
         value: 1
-
-    SENSOR_SHELL_TIMER_FREQ:
-        description: 'Frequency of sensor shell timer'
-        value: 100000
-
-    SENSOR_SHELL_TIMER_NUM:
-        description: 'Timer number to use for sensor shell, 1 by default.'
-        value: 1


[44/50] [abbrv] incubator-mynewt-core git commit: No jira ticket for this change. The structure used for spi configuration was not changed in all the bsps for the nrf51. This fixes that oversight.

Posted by we...@apache.org.
No jira ticket for this change. The structure used for spi configuration
was not changed in all the bsps for the nrf51. This fixes that oversight.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b35132ff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b35132ff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b35132ff

Branch: refs/heads/nrf_cputime
Commit: b35132ffe4c1d7807e70769fabbd3456312d6605
Parents: 22e0edd
Author: William San Filippo <wi...@runtime.io>
Authored: Thu Mar 23 15:47:40 2017 -0700
Committer: William San Filippo <wi...@runtime.io>
Committed: Thu Mar 23 15:48:32 2017 -0700

----------------------------------------------------------------------
 hw/bsp/bbc_microbit/src/hal_bsp.c    | 4 ++--
 hw/bsp/nrf51-blenano/src/hal_bsp.c   | 4 ++--
 hw/bsp/nrf51dk-16kbram/src/hal_bsp.c | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b35132ff/hw/bsp/bbc_microbit/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/bbc_microbit/src/hal_bsp.c b/hw/bsp/bbc_microbit/src/hal_bsp.c
index 23f5c84..3f47f78 100644
--- a/hw/bsp/bbc_microbit/src/hal_bsp.c
+++ b/hw/bsp/bbc_microbit/src/hal_bsp.c
@@ -50,7 +50,7 @@ static const struct nrf51_uart_cfg os_bsp_uart0_cfg = {
  * NOTE: Our HAL expects that the SS pin, if used, is treated as a gpio line
  * and is handled outside the SPI routines.
  */
-static const nrf_drv_spi_config_t os_bsp_spi0m_cfg = {
+static const struct nrf51_hal_spi_cfg os_bsp_spi0m_cfg = {
     .sck_pin      = 29,
     .mosi_pin     = 25,
     .miso_pin     = 28
@@ -58,7 +58,7 @@ static const nrf_drv_spi_config_t os_bsp_spi0m_cfg = {
 #endif
 
 #if MYNEWT_VAL(SPI_1_SLAVE)
-static const nrf_drv_spis_config_t os_bsp_spi1s_cfg = {
+static const struct nrf51_hal_spi_cfg os_bsp_spi1s_cfg = {
     .sck_pin      = 29,
     .mosi_pin     = 25,
     .miso_pin     = 28,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b35132ff/hw/bsp/nrf51-blenano/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51-blenano/src/hal_bsp.c b/hw/bsp/nrf51-blenano/src/hal_bsp.c
index 23f5c84..3f47f78 100644
--- a/hw/bsp/nrf51-blenano/src/hal_bsp.c
+++ b/hw/bsp/nrf51-blenano/src/hal_bsp.c
@@ -50,7 +50,7 @@ static const struct nrf51_uart_cfg os_bsp_uart0_cfg = {
  * NOTE: Our HAL expects that the SS pin, if used, is treated as a gpio line
  * and is handled outside the SPI routines.
  */
-static const nrf_drv_spi_config_t os_bsp_spi0m_cfg = {
+static const struct nrf51_hal_spi_cfg os_bsp_spi0m_cfg = {
     .sck_pin      = 29,
     .mosi_pin     = 25,
     .miso_pin     = 28
@@ -58,7 +58,7 @@ static const nrf_drv_spi_config_t os_bsp_spi0m_cfg = {
 #endif
 
 #if MYNEWT_VAL(SPI_1_SLAVE)
-static const nrf_drv_spis_config_t os_bsp_spi1s_cfg = {
+static const struct nrf51_hal_spi_cfg os_bsp_spi1s_cfg = {
     .sck_pin      = 29,
     .mosi_pin     = 25,
     .miso_pin     = 28,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b35132ff/hw/bsp/nrf51dk-16kbram/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/nrf51dk-16kbram/src/hal_bsp.c b/hw/bsp/nrf51dk-16kbram/src/hal_bsp.c
index 5db6490..366b060 100644
--- a/hw/bsp/nrf51dk-16kbram/src/hal_bsp.c
+++ b/hw/bsp/nrf51dk-16kbram/src/hal_bsp.c
@@ -49,7 +49,7 @@ static const struct nrf51_uart_cfg os_bsp_uart0_cfg = {
  * NOTE: Our HAL expects that the SS pin, if used, is treated as a gpio line
  * and is handled outside the SPI routines.
  */
-static const nrf_drv_spi_config_t os_bsp_spi0m_cfg = {
+static const struct  nrf51_hal_spi_cfg os_bsp_spi0m_cfg = {
     .sck_pin      = 29,
     .mosi_pin     = 25,
     .miso_pin     = 28
@@ -57,7 +57,7 @@ static const nrf_drv_spi_config_t os_bsp_spi0m_cfg = {
 #endif
 
 #if MYNEWT_VAL(SPI_1_SLAVE)
-static const nrf_drv_spis_config_t os_bsp_spi1s_cfg = {
+static const struct nrf51_hal_spi_cfg os_bsp_spi1s_cfg = {
     .sck_pin      = 29,
     .mosi_pin     = 25,
     .miso_pin     = 28,


[18/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-671 UART support in sim

Posted by we...@apache.org.
MYNEWT-671 UART support in sim

Add second UART to native BSP.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/4cf2e74f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/4cf2e74f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/4cf2e74f

Branch: refs/heads/nrf_cputime
Commit: 4cf2e74fb964af23b6b2fc2d82dd183b3a243006
Parents: 653a697
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Mar 15 11:43:52 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Mar 15 11:43:52 2017 -0700

----------------------------------------------------------------------
 hw/bsp/native/src/hal_bsp.c | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/4cf2e74f/hw/bsp/native/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/native/src/hal_bsp.c b/hw/bsp/native/src/hal_bsp.c
index 5f14e1e..b03d1fa 100644
--- a/hw/bsp/native/src/hal_bsp.c
+++ b/hw/bsp/native/src/hal_bsp.c
@@ -32,6 +32,7 @@
 #include "mcu/mcu_hal.h"
 
 static struct uart_dev os_bsp_uart0;
+static struct uart_dev os_bsp_uart1;
 
 const struct hal_flash *
 hal_bsp_flash_dev(uint8_t id)
@@ -59,4 +60,8 @@ hal_bsp_init(void)
     rc = os_dev_create((struct os_dev *) &os_bsp_uart0, "uart0",
             OS_DEV_INIT_PRIMARY, 0, uart_hal_init, (void *) NULL);
     assert(rc == 0);
+
+    rc = os_dev_create((struct os_dev *) &os_bsp_uart1, "uart1",
+            OS_DEV_INIT_PRIMARY, 0, uart_hal_init, (void *) NULL);
+    assert(rc == 0);
 }


[17/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-671 UART support in sim

Posted by we...@apache.org.
MYNEWT-671 UART support in sim

Currently, sim always maps UARTs to ptys. This change allows the
application to specify a file (e.g., /dev/...) to map a UART to.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/653a6974
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/653a6974
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/653a6974

Branch: refs/heads/nrf_cputime
Commit: 653a6974083f9918fc105b568559995dde6d7713
Parents: 7894657
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Mar 8 19:39:20 2017 -0800
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Mar 15 11:17:54 2017 -0700

----------------------------------------------------------------------
 hw/mcu/native/include/mcu/native_bsp.h   |   2 +
 hw/mcu/native/src/hal_uart.c             |  65 ++++++-
 hw/mcu/native/src/native_uart_cfg.c      | 234 ++++++++++++++++++++++++++
 hw/mcu/native/src/native_uart_cfg_priv.h |  12 ++
 4 files changed, 310 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/653a6974/hw/mcu/native/include/mcu/native_bsp.h
----------------------------------------------------------------------
diff --git a/hw/mcu/native/include/mcu/native_bsp.h b/hw/mcu/native/include/mcu/native_bsp.h
index c8b6e13..dd79487 100644
--- a/hw/mcu/native/include/mcu/native_bsp.h
+++ b/hw/mcu/native/include/mcu/native_bsp.h
@@ -25,6 +25,8 @@ extern "C" {
 
 extern const struct hal_flash native_flash_dev;
 
+int uart_set_dev(int port, const char *dev_str);
+
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/653a6974/hw/mcu/native/src/hal_uart.c
----------------------------------------------------------------------
diff --git a/hw/mcu/native/src/hal_uart.c b/hw/mcu/native/src/hal_uart.c
index 4c2c076..d9328aa 100644
--- a/hw/mcu/native/src/hal_uart.c
+++ b/hw/mcu/native/src/hal_uart.c
@@ -17,6 +17,7 @@
  * under the License.
  */
 
+#include "defs/error.h"
 #include "os/os.h"
 #include "hal/hal_uart.h"
 #include "bsp/bsp.h"
@@ -33,6 +34,10 @@
 #include <assert.h>
 #include <unistd.h>
 #include <string.h>
+#include <termios.h>
+#include <errno.h>
+
+#include "native_uart_cfg_priv.h"
 
 #define UART_CNT                2
 
@@ -51,6 +56,8 @@ struct uart {
     void *u_func_arg;
 };
 
+const char *native_uart_dev_strs[UART_CNT];
+
 /*
  * XXXX should try to use O_ASYNC/SIGIO for byte arrival notification,
  * so we wouldn't need an OS for pseudo ttys.
@@ -231,7 +238,7 @@ set_nonblock(int fd)
 }
 
 static int
-uart_set_attr(int fd)
+uart_pty_set_attr(int fd)
 {
     struct termios tios;
 
@@ -268,7 +275,7 @@ uart_pty(int port)
         return -1;
     }
 
-    if (uart_set_attr(loop_slave)) {
+    if (uart_pty_set_attr(loop_slave)) {
         goto err;
     }
 
@@ -281,6 +288,37 @@ err:
     return -1;
 }
 
+/**
+ * Opens an external device terminal (/dev/cu.<...>).
+ */
+static int
+uart_open_dev(int port, int32_t baudrate, uint8_t databits,
+              uint8_t stopbits, enum hal_uart_parity parity,
+              enum hal_uart_flow_ctl flow_ctl)
+{
+    const char *filename;
+    int fd;
+    int rc;
+
+    filename = native_uart_dev_strs[port];
+    assert(filename != NULL);
+
+    fd = open(filename, O_RDWR);
+    if (fd < 0) {
+        return -1;
+    }
+
+    rc = uart_dev_set_attr(fd, baudrate, databits,
+                           stopbits, parity, flow_ctl);
+    if (rc != 0) {
+        return rc;
+    }
+
+    dprintf(1, "uart%d at %s\n", port, filename);
+
+    return fd;
+}
+
 void
 hal_uart_start_tx(int port)
 {
@@ -363,12 +401,19 @@ hal_uart_config(int port, int32_t baudrate, uint8_t databits, uint8_t stopbits,
         return -1;
     }
 
-    uart->u_fd = uart_pty(port);
+    if (native_uart_dev_strs[port] == NULL) {
+        uart->u_fd = uart_pty(port);
+    } else {
+        uart->u_fd = uart_open_dev(port, baudrate, databits, stopbits,
+                                   parity, flow_ctl);
+    }
+
     if (uart->u_fd < 0) {
         return -1;
     }
     set_nonblock(uart->u_fd);
 
+
     uart_open_log();
     uart->u_open = 1;
     return 0;
@@ -405,4 +450,18 @@ hal_uart_init(int port, void *arg)
     return (0);
 }
 
+int
+uart_set_dev(int port, const char *dev_str)
+{
+    if (port < 0 || port >= UART_CNT) {
+        return SYS_EINVAL;
+    }
+
+    if (uarts[port].u_open) {
+        return SYS_EBUSY;
+    }
 
+    native_uart_dev_strs[port] = dev_str;
+
+    return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/653a6974/hw/mcu/native/src/native_uart_cfg.c
----------------------------------------------------------------------
diff --git a/hw/mcu/native/src/native_uart_cfg.c b/hw/mcu/native/src/native_uart_cfg.c
new file mode 100644
index 0000000..4f9dcef
--- /dev/null
+++ b/hw/mcu/native/src/native_uart_cfg.c
@@ -0,0 +1,234 @@
+/*
+ * 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 <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <termios.h>
+
+#include "defs/error.h"
+#include "native_uart_cfg_priv.h"
+
+/* uint64 is used here to accommodate speed_t, whatever that is. */
+static const uint64_t uart_baud_table[][2] = {
+#ifdef B50 
+    { 50, B50 },
+#endif
+#ifdef B75 
+    { 75, B75 },
+#endif
+#ifdef B110 
+    { 110, B110 },
+#endif
+#ifdef B134 
+    { 134, B134 },
+#endif
+#ifdef B150 
+    { 150, B150 },
+#endif
+#ifdef B200 
+    { 200, B200 },
+#endif
+#ifdef B300 
+    { 300, B300 },
+#endif
+#ifdef B600 
+    { 600, B600 },
+#endif
+#ifdef B1200 
+    { 1200, B1200 },
+#endif
+#ifdef B1800 
+    { 1800, B1800 },
+#endif
+#ifdef B2400 
+    { 2400, B2400 },
+#endif
+#ifdef B4800 
+    { 4800, B4800 },
+#endif
+#ifdef B9600 
+    { 9600, B9600 },
+#endif
+#ifdef B19200 
+    { 19200, B19200 },
+#endif
+#ifdef B38400 
+    { 38400, B38400 },
+#endif
+#ifdef B57600 
+    { 57600, B57600 },
+#endif
+#ifdef B115200 
+    { 115200, B115200 },
+#endif
+#ifdef B230400 
+    { 230400, B230400 },
+#endif
+#ifdef B460800 
+    { 460800, B460800 },
+#endif
+#ifdef B500000 
+    { 500000, B500000 },
+#endif
+#ifdef B576000 
+    { 576000, B576000 },
+#endif
+#ifdef B921600 
+    { 921600, B921600 },
+#endif
+#ifdef B1000000 
+    { 1000000, B1000000 },
+#endif
+#ifdef B1152000 
+    { 1152000, B1152000 },
+#endif
+#ifdef B1500000 
+    { 1500000, B1500000 },
+#endif
+#ifdef B2000000 
+    { 2000000, B2000000 },
+#endif
+#ifdef B2500000
+    { 2500000, B2500000 },
+#endif
+#ifdef B3000000
+    { 3000000, B3000000 },
+#endif
+#ifdef B3500000
+    { 3500000, B3500000 },
+#endif
+#ifdef B3710000
+    { 3710000, B3710000 },
+#endif
+#ifdef B4000000
+    { 4000000, B4000000 },
+#endif
+};
+#define UART_BAUD_TABLE_SZ (sizeof uart_baud_table / sizeof uart_baud_table[0])
+
+/**
+ * Returns 0 on failure.
+ */
+speed_t
+uart_baud_to_speed(int_least32_t baud)
+{
+    int i;
+
+    for (i = 0; i < UART_BAUD_TABLE_SZ; i++) {
+        if (uart_baud_table[i][0] == baud) {
+            return uart_baud_table[i][1];
+        }
+    }
+
+    return 0;
+}
+
+/**
+ * Configures an external device terminal (/dev/cu.<...>).
+ */
+int
+uart_dev_set_attr(int fd, int32_t baudrate, uint8_t databits,
+                  uint8_t stopbits, enum hal_uart_parity parity,
+                  enum hal_uart_flow_ctl flow_ctl)
+{
+    struct termios tty;
+    speed_t speed;
+    int rc;
+
+    assert(fd >= 0);
+
+    memset(&tty, 0, sizeof(tty));
+    cfmakeraw(&tty);
+
+    speed = uart_baud_to_speed(baudrate);
+    if (speed == 0) {
+        fprintf(stderr, "invalid baud rate: %d\n", (int)baudrate);
+        assert(0);
+    }
+
+    tty.c_cflag |= (speed | CLOCAL | CREAD);
+
+    /* Disable flow control. */
+    tty.c_cflag &= ~CRTSCTS;
+
+    errno = 0;
+    rc = cfsetospeed(&tty, speed);
+    if (rc != 0) {
+        fprintf(stderr, "cfsetospeed failed; %d (%s) baudrate=%d\n",
+                errno, strerror(errno), (int)baudrate);
+        return -1;
+    }
+
+    errno = 0;
+    rc = cfsetispeed(&tty, speed);
+    if (rc != 0) {
+        fprintf(stderr, "cfsetispeed failed; %d (%s) baudrate=%d\n",
+                errno, strerror(errno), (int)baudrate);
+        return -1;
+    }
+
+    switch (databits) {
+    case 7:
+        tty.c_cflag |= CS7;
+
+        switch (parity) {
+        case HAL_UART_PARITY_ODD:
+            tty.c_cflag |= PARENB;
+            tty.c_cflag |= PARODD;
+            tty.c_cflag &= ~CSTOPB;
+            tty.c_cflag &= ~CSIZE;
+            break;
+
+        case HAL_UART_PARITY_EVEN:
+            tty.c_cflag |= PARENB;
+            tty.c_cflag &= ~PARODD;
+            tty.c_cflag &= ~CSTOPB;
+            tty.c_cflag &= ~CSIZE;
+            break;
+
+        default:
+            return SYS_EINVAL;
+        }
+
+    case 8:
+        if (parity != HAL_UART_PARITY_NONE) {
+            return SYS_EINVAL;
+        }
+        tty.c_cflag |= CS8;
+        tty.c_cflag &= ~PARENB;
+        tty.c_cflag &= ~CSTOPB;
+        tty.c_cflag &= ~CSIZE;
+        break;
+
+    default:
+        return SYS_EINVAL;
+    }
+
+    rc = tcsetattr(fd, TCSANOW, &tty);
+    if (rc != 0) {
+        dprintf(1, "tcsetattr failed; %d (%s)\n", errno, strerror(errno));
+        return -1;
+    }
+
+    return 0;
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/653a6974/hw/mcu/native/src/native_uart_cfg_priv.h
----------------------------------------------------------------------
diff --git a/hw/mcu/native/src/native_uart_cfg_priv.h b/hw/mcu/native/src/native_uart_cfg_priv.h
new file mode 100644
index 0000000..243cd45
--- /dev/null
+++ b/hw/mcu/native/src/native_uart_cfg_priv.h
@@ -0,0 +1,12 @@
+#ifndef H_NATIVE_UART_CFG_PRIV_
+#define H_NATIVE_UART_CFG_PRIV_
+
+#include <termios.h>
+#include "hal/hal_uart.h"
+
+speed_t uart_baud_to_speed(int_least32_t baud);
+int uart_dev_set_attr(int fd, int32_t baudrate, uint8_t databits,
+                      uint8_t stopbits, enum hal_uart_parity parity,
+                      enum hal_uart_flow_ctl flow_ctl);
+
+#endif


[29/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-676 Reboot counter value inconsistent

Posted by we...@apache.org.
MYNEWT-676 Reboot counter value inconsistent

Always call conf_load() before initializing reboot log / reboot counter.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/63546eff
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/63546eff
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/63546eff

Branch: refs/heads/nrf_cputime
Commit: 63546eff51b42ab2c4329c22d27b43c66b1ed966
Parents: 35323c2
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Mar 17 15:20:56 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Mar 17 15:20:56 2017 -0700

----------------------------------------------------------------------
 apps/testbench/src/testbench.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/63546eff/apps/testbench/src/testbench.c
----------------------------------------------------------------------
diff --git a/apps/testbench/src/testbench.c b/apps/testbench/src/testbench.c
index bb96a7a..4029187 100644
--- a/apps/testbench/src/testbench.c
+++ b/apps/testbench/src/testbench.c
@@ -360,10 +360,10 @@ main(int argc, char **argv)
     cbmem_init(&cbmem, cbmem_buf, MAX_CBMEM_BUF);
     log_register("testlog", &testlog, &log_cbmem_handler, &cbmem, LOG_SYSLEVEL);
 
-    reboot_start(hal_reset_cause());
-
     conf_load();
 
+    reboot_start(hal_reset_cause());
+
     /*
      * Register the tests that can be run by lookup
      * - each test is added to the ts_suites slist


[37/50] [abbrv] incubator-mynewt-core git commit: nimble/controller: Fix handling incorrect LL opcode

Posted by we...@apache.org.
nimble/controller: Fix handling incorrect LL opcode

According to BT specification v5.0 Vol.6 Part B, 2.4.2

If an LL Control PDU is:
* not supported
* not used
* invalid i.e. set to value that is Reserved for Future use

or CtrlData is invalid, the Link Layer shall respond with an
LL_UNKNOWN_RSP PDU.

This closes #633


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f5b3bf68
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f5b3bf68
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f5b3bf68

Branch: refs/heads/nrf_cputime
Commit: f5b3bf68445d645866366bd8c25ce2031215770f
Parents: 0f10379
Author: \u0141ukasz Rymanowski <lu...@codecoup.pl>
Authored: Wed Mar 22 14:15:53 2017 +0100
Committer: William San Filippo <wi...@runtime.io>
Committed: Wed Mar 22 09:47:56 2017 -0700

----------------------------------------------------------------------
 net/nimble/controller/src/ble_ll_ctrl.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f5b3bf68/net/nimble/controller/src/ble_ll_ctrl.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_ctrl.c b/net/nimble/controller/src/ble_ll_ctrl.c
index 1ba93bd..f933922 100644
--- a/net/nimble/controller/src/ble_ll_ctrl.c
+++ b/net/nimble/controller/src/ble_ll_ctrl.c
@@ -1522,6 +1522,7 @@ ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
 #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
     int restart_encryption;
 #endif
+    int rc = 0;
 
     /* XXX: where do we validate length received and packet header length?
      * do this in LL task when received. Someplace!!! What I mean
@@ -1558,10 +1559,14 @@ ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
 
     ble_ll_log(BLE_LL_LOG_ID_LL_CTRL_RX, opcode, len, 0);
 
-    /* opcode must be good */
+    /* If opcode comes from reserved value or CtrlData fields is invalid
+     * we shall respond with LL_UNKNOWN_RSP
+     */
     if ((opcode >= BLE_LL_CTRL_OPCODES) ||
         (len != g_ble_ll_ctrl_pkt_lengths[opcode])) {
-        goto rx_malformed_ctrl;
+        rc = -1;
+        rsp_opcode = BLE_LL_CTRL_UNKNOWN_RSP;
+        goto ll_ctrl_send_rsp;
     }
 
 #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
@@ -1626,7 +1631,9 @@ ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
     case BLE_LL_CTRL_LENGTH_REQ:
         /* Extract parameters and check if valid */
         if (ble_ll_ctrl_len_proc(connsm, dptr)) {
-            goto rx_malformed_ctrl;
+            rc  = -1;
+            rsp_opcode = BLE_LL_CTRL_UNKNOWN_RSP;
+            goto ll_ctrl_send_rsp;
         }
 
         /*
@@ -1647,7 +1654,9 @@ ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
         if (connsm->cur_ctrl_proc == BLE_LL_CTRL_PROC_DATA_LEN_UPD) {
             /* Process the received data */
             if (ble_ll_ctrl_len_proc(connsm, dptr)) {
-                goto rx_malformed_ctrl;
+                rc = -1;
+                rsp_opcode = BLE_LL_CTRL_UNKNOWN_RSP;
+                goto ll_ctrl_send_rsp;
             }
 
             /* Stop the control procedure */
@@ -1743,11 +1752,7 @@ ll_ctrl_send_rsp:
         }
 #endif
     }
-    return 0;
-
-rx_malformed_ctrl:
-    os_mbuf_free_chain(om);
-    return -1;
+    return rc;
 }
 
 /**


[27/50] [abbrv] incubator-mynewt-core git commit: Log json test results and assume msg is null terminated

Posted by we...@apache.org.
Log json test results and assume msg is null terminated


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/fcb79cd9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/fcb79cd9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/fcb79cd9

Branch: refs/heads/nrf_cputime
Commit: fcb79cd91206aaebaf138f8c99fdd87e6aa30d40
Parents: d7a9e96
Author: spoonofpower <sp...@gmail.com>
Authored: Fri Mar 17 13:52:07 2017 -0700
Committer: spoonofpower <sp...@gmail.com>
Committed: Fri Mar 17 13:52:07 2017 -0700

----------------------------------------------------------------------
 apps/testbench/src/testbench.c            | 25 ++++++++++++++++---------
 apps/testbench/src/testbench.h            |  4 ++--
 test/testutil/include/testutil/testutil.h |  2 +-
 test/testutil/src/case.c                  |  9 +++------
 4 files changed, 22 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fcb79cd9/apps/testbench/src/testbench.c
----------------------------------------------------------------------
diff --git a/apps/testbench/src/testbench.c b/apps/testbench/src/testbench.c
index 19b0ebf..bb96a7a 100644
--- a/apps/testbench/src/testbench.c
+++ b/apps/testbench/src/testbench.c
@@ -124,24 +124,30 @@ extern uint32_t stack3_size;
 extern uint32_t stack4_size;
 
 void
-testbench_ts_pass(char *msg, int msg_len, void *arg)
+testbench_ts_result(char *msg, void *arg, bool passed)
 {
     TESTBENCH_UPDATE_TOD;
 
     total_tests++;
-    LOG_INFO(&testlog, LOG_MODULE_TEST, "%s test case %s PASSED %s %s",
-             buildID, tu_case_name, msg, runtest_token);
+    if (!passed) {
+        total_fails++;
+    }
+
+    LOG_INFO(&testlog, LOG_MODULE_TEST,
+            "{\"k\":\"%s\",\"n\":\"%s\",\"r\":%d,\"m\":\"%s\"}",
+             runtest_token, tu_case_name, passed, msg);
 }
 
 void
-testbench_ts_fail(char *msg, int msg_len, void *arg)
+testbench_ts_pass(char *msg, void *arg)
 {
-    TESTBENCH_UPDATE_TOD;
+    testbench_ts_result(msg, arg, true);
+}
 
-    total_tests++;
-    total_fails++;
-    LOG_INFO(&testlog, LOG_MODULE_TEST, "%s test case %s FAILED %s %s",
-             buildID, tu_case_name, msg, runtest_token);
+void
+testbench_ts_fail(char *msg, void *arg)
+{
+    testbench_ts_result(msg, arg, false);
 }
 
 #if 0
@@ -234,6 +240,7 @@ testbench_runtests(struct os_event *ev)
 static void
 testbench_test_complete()
 {
+    LOG_INFO(&testlog, LOG_MODULE_TEST, "%s Done", runtest_token);
     LOG_INFO(&testlog, LOG_MODULE_TEST,
              "%s TESTBENCH TEST %s - Tests run:%d pass:%d fail:%d %s",
              buildID,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fcb79cd9/apps/testbench/src/testbench.h
----------------------------------------------------------------------
diff --git a/apps/testbench/src/testbench.h b/apps/testbench/src/testbench.h
index a94ee1c..ad47ae3 100644
--- a/apps/testbench/src/testbench.h
+++ b/apps/testbench/src/testbench.h
@@ -156,8 +156,8 @@ extern os_stack_t *stack4;
 void testbench_ts_init(void *arg);
 void testbench_ts_pretest(void* arg);
 void testbench_ts_posttest(void* arg);
-void testbench_ts_pass(char *msg, int msg_len, void *arg);
-void testbench_ts_fail(char *msg, int msg_len, void *arg);
+void testbench_ts_pass(char *msg, void *arg);
+void testbench_ts_fail(char *msg, void *arg);
 
 void testbench_tc_pretest(void* arg);
 void testbench_tc_postest(void* arg);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fcb79cd9/test/testutil/include/testutil/testutil.h
----------------------------------------------------------------------
diff --git a/test/testutil/include/testutil/testutil.h b/test/testutil/include/testutil/testutil.h
index 1edfb03..56f8f64 100644
--- a/test/testutil/include/testutil/testutil.h
+++ b/test/testutil/include/testutil/testutil.h
@@ -48,7 +48,7 @@ extern "C" {
  *      tu_suite_complete -> ts_suite_complete_cb
  */
 
-typedef void tu_case_report_fn_t(char *msg, int msg_len, void *arg);
+typedef void tu_case_report_fn_t(char *msg, void *arg);
 typedef void tu_suite_restart_fn_t(void *arg);
 
 typedef void tu_init_test_fn_t(void *arg);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/fcb79cd9/test/testutil/src/case.c
----------------------------------------------------------------------
diff --git a/test/testutil/src/case.c b/test/testutil/src/case.c
index 060f00c..2727b99 100644
--- a/test/testutil/src/case.c
+++ b/test/testutil/src/case.c
@@ -169,8 +169,7 @@ tu_case_pass(void)
     tu_case_failed = 0;
 
     if (ts_config.ts_case_pass_cb != NULL) {
-        ts_config.ts_case_pass_cb(tu_case_buf, tu_case_buf_len,
-                                  ts_config.ts_case_pass_arg);
+        ts_config.ts_case_pass_cb(tu_case_buf, ts_config.ts_case_pass_arg);
     }
 }
 
@@ -192,8 +191,7 @@ tu_case_fail(void)
     tu_case_post_test();
 
     if (ts_config.ts_case_fail_cb != NULL) {
-        ts_config.ts_case_fail_cb(tu_case_buf, tu_case_buf_len,
-                                  ts_config.ts_case_fail_arg);
+        ts_config.ts_case_fail_cb(tu_case_buf, ts_config.ts_case_fail_arg);
     }
 }
 
@@ -232,8 +230,7 @@ tu_case_write_pass_buf(void)
     tu_case_reported = 1;
 
     if (ts_config.ts_case_pass_cb != NULL) {
-        ts_config.ts_case_pass_cb(tu_case_buf, tu_case_buf_len,
-                                  ts_config.ts_case_pass_arg);
+        ts_config.ts_case_pass_cb(tu_case_buf, ts_config.ts_case_pass_arg);
     }
 }
 


[33/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-678 SensorAPI: Shell:

Posted by we...@apache.org.
MYNEWT-678 SensorAPI: Shell:

- Add support for polling at a given interval for a
specific duration
- Add hal_timer config and clean up


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d23fab9e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d23fab9e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d23fab9e

Branch: refs/heads/nrf_cputime
Commit: d23fab9eea2d9edf61833a3ce22e8d9754cc3eb9
Parents: b5e0947
Author: Vipul Rahane <vi...@apache.org>
Authored: Sun Mar 19 22:52:53 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Mar 21 11:45:22 2017 -0700

----------------------------------------------------------------------
 hw/sensor/src/sensor_shell.c | 168 ++++++++++++++++++++++++--------------
 hw/sensor/syscfg.yml         |   8 ++
 2 files changed, 116 insertions(+), 60 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d23fab9e/hw/sensor/src/sensor_shell.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_shell.c b/hw/sensor/src/sensor_shell.c
index 250478e..3b6dc43 100644
--- a/hw/sensor/src/sensor_shell.c
+++ b/hw/sensor/src/sensor_shell.c
@@ -42,9 +42,6 @@
 #include "hal/hal_i2c.h"
 #include "hal/hal_timer.h"
 
-#define SENSOR_SHELL_TIMER_NUM        (1)
-#define SENSOR_SHELL_TIMER_CLOCK_FREQ (100000)
-
 static int sensor_cmd_exec(int, char **);
 static struct shell_cmd shell_sensor_cmd = {
     .sc_cmd = "sensor",
@@ -282,10 +279,102 @@ sensor_shell_timer_cb(void *arg)
     int timer_arg_val;
     int rc;
 
-    timer_arg_val = *(int *)arg;
+    timer_arg_val = *(uint32_t *)arg;
+    os_sem_release(&g_sensor_shell_sem);
     rc = hal_timer_start(&g_sensor_shell_timer, timer_arg_val);
     assert(rc == 0);
-    os_sem_release(&g_sensor_shell_sem);
+}
+
+/* HAL timer configuration */
+static void
+sensor_shell_config_timer(struct sensor_poll_data *spd)
+{
+    int rc;
+
+    if (!g_timer_is_config) {
+        rc = hal_timer_config(MYNEWT_VAL(SENSOR_SHELL_TIMER_NUM),
+                 MYNEWT_VAL(SENSOR_SHELL_TIMER_FREQ));
+        assert(rc == 0);
+        g_timer_is_config = 1;
+    }
+
+    sensor_shell_timer_arg =
+        (spd->spd_poll_itvl * 1000000) / hal_timer_get_resolution(MYNEWT_VAL(SENSOR_SHELL_TIMER_NUM));
+
+    rc = hal_timer_set_cb(MYNEWT_VAL(SENSOR_SHELL_TIMER_NUM),
+                          &g_sensor_shell_timer,
+                          sensor_shell_timer_cb,
+                          &sensor_shell_timer_arg);
+    assert(rc == 0);
+
+    rc = hal_timer_start(&g_sensor_shell_timer, sensor_shell_timer_arg);
+    assert(rc == 0);
+}
+
+/* Check for number of samples */
+static int
+sensor_shell_chk_nsamples(struct sensor_poll_data *spd,
+                          struct sensor_shell_read_ctx *ctx)
+{
+    /* Condition for number of samples */
+    if (spd->spd_nsamples && ctx->num_entries >= spd->spd_nsamples) {
+        hal_timer_stop(&g_sensor_shell_timer);
+        return 0;
+    }
+
+    return -1;
+}
+
+/* Check for escape sequence */
+static int
+sensor_shell_chk_escape_seq(void)
+{
+    char ch;
+    int newline;
+    int rc;
+
+    ch = 0;
+    /* Check for escape sequence */
+    rc = console_read(&ch, 1, &newline);
+    /* ^C or q or Q gets it out of the sampling loop */
+    if (rc || (ch == 3 || ch == 'q' || ch == 'Q')) {
+        hal_timer_stop(&g_sensor_shell_timer);
+        console_printf("Sensor polling stopped rc:%u\n", rc);
+        return 0;
+    }
+
+    return -1;
+}
+
+/*
+ * Incrementing duration based on interval if specified or
+ * os_time if interval is not specified and checking duration
+ */
+static int
+sensor_shell_polling_done(struct sensor_poll_data *spd,
+                          int64_t *start_ts,
+                          int *duration)
+{
+
+    if (spd->spd_poll_duration) {
+        if (spd->spd_poll_itvl) {
+            *duration += spd->spd_poll_itvl;
+        } else {
+            if (!*start_ts) {
+                *start_ts = os_get_uptime_usec()/1000;
+            } else {
+                *duration = os_get_uptime_usec()/1000 - *start_ts;
+            }
+        }
+
+        if (*duration >= spd->spd_poll_duration) {
+            hal_timer_stop(&g_sensor_shell_timer);
+            console_printf("Sensor polling done\n");
+            return 0;
+        }
+    }
+
+    return -1;
 }
 
 static int
@@ -297,8 +386,6 @@ sensor_cmd_read(char *name, sensor_type_t type, struct sensor_poll_data *spd)
     int rc;
     int duration;
     int64_t start_ts;
-    int newline;
-    char ch;
 
     /* Look up sensor by name */
     sensor = sensor_mgr_find_next_bydevname(name, NULL);
@@ -306,8 +393,7 @@ sensor_cmd_read(char *name, sensor_type_t type, struct sensor_poll_data *spd)
         console_printf("Sensor %s not found!\n", name);
     }
 
-    /* Register a listener and then trigger/read a bunch of samples.
-     */
+    /* Register a listener and then trigger/read a bunch of samples */
     memset(&ctx, 0, sizeof(ctx));
 
     if (!(type & sensor->s_types)) {
@@ -329,24 +415,14 @@ sensor_cmd_read(char *name, sensor_type_t type, struct sensor_poll_data *spd)
         return rc;
     }
 
-    if (spd->spd_poll_itvl) {
+    /* Initialize the semaphore*/
+    os_sem_init(&g_sensor_shell_sem, 0);
 
-        if (!g_timer_is_config) {
-            rc = hal_timer_config(SENSOR_SHELL_TIMER_NUM, SENSOR_SHELL_TIMER_CLOCK_FREQ);
-            assert(rc == 0);
-            g_timer_is_config = 1;
-        }
-
-        sensor_shell_timer_arg = 1000 * spd->spd_poll_itvl;
-        rc = hal_timer_set_cb(SENSOR_SHELL_TIMER_NUM, &g_sensor_shell_timer, sensor_shell_timer_cb,
-                              &sensor_shell_timer_arg);
-        assert(rc == 0);
-
-        rc = hal_timer_start(&g_sensor_shell_timer, sensor_shell_timer_arg);
-    }   assert(rc == 0);
+    if (spd->spd_poll_itvl) {
+        sensor_shell_config_timer(spd);
+    }
 
-    start_ts = 0;
-    duration = 0;
+    start_ts = duration = 0;
 
     while (1) {
         if (spd->spd_poll_itvl) {
@@ -364,46 +440,18 @@ sensor_cmd_read(char *name, sensor_type_t type, struct sensor_poll_data *spd)
             goto err;
         }
 
-        /* Condition for number of samples */
-        if (spd->spd_nsamples && ctx.num_entries >= spd->spd_nsamples) {
-            hal_timer_stop(&g_sensor_shell_timer);
+        /* Check number of samples if provided */
+        if (!sensor_shell_chk_nsamples(spd, &ctx)) {
             break;
         }
 
-        /*
-         * Incrementing duration based on interval if specified or
-         * os_time if interval is not specified and checking duration
-         */
-        if (spd->spd_poll_duration) {
-            if (spd->spd_poll_itvl) {
-                duration += spd->spd_poll_itvl;
-            } else {
-                if (!start_ts) {
-                    start_ts = os_get_uptime_usec()/1000;
-                } else {
-                    duration = os_get_uptime_usec()/1000 - start_ts;
-                }
-
-            }
-
-            if (duration >= spd->spd_poll_duration) {
-                hal_timer_stop(&g_sensor_shell_timer);
-                console_printf("Sensor polling done\n");
-                break;
-            }
+        /* Check duration if provided */
+        if (!sensor_shell_polling_done(spd, &start_ts, &duration)) {
+            break;
         }
 
-        ch = 0;
-        /* Check for escape sequence */
-        rc = console_read(&ch, 1, &newline);
-        if (rc) {
-            hal_timer_stop(&g_sensor_shell_timer);
-            goto err;
-        }
-        /* ^C or q or Q gets it out of the sampling loop */
-        if (ch == 3 || ch == 'q' || ch == 'Q') {
-            hal_timer_stop(&g_sensor_shell_timer);
-            console_printf("Sensor polling stopped\n");
+        /* Check escape sequence */
+        if(!sensor_shell_chk_escape_seq()) {
             break;
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d23fab9e/hw/sensor/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/sensor/syscfg.yml b/hw/sensor/syscfg.yml
index 879fbb2..a4b6ee9 100644
--- a/hw/sensor/syscfg.yml
+++ b/hw/sensor/syscfg.yml
@@ -26,3 +26,11 @@ syscfg.defs:
     SENSOR_CLI:
         description: 'Whether or not to enable the sensor shell support'
         value: 1
+
+    SENSOR_SHELL_TIMER_FREQ:
+        description: 'Frequency of sensor shell timer'
+        value: 100000
+
+    SENSOR_SHELL_TIMER_NUM:
+        description: 'Timer number to use for sensor shell, 1 by default.'
+        value: 1


[05/50] [abbrv] incubator-mynewt-core git commit: Re-add double cmd.exe invocation.

Posted by we...@apache.org.
Re-add double cmd.exe invocation.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f6951e68
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f6951e68
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f6951e68

Branch: refs/heads/nrf_cputime
Commit: f6951e6889d631e112d18514b891d98e42fca8ff
Parents: 9cd69a3
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Sat Mar 4 20:44:03 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Mar 10 13:10:54 2017 -0800

----------------------------------------------------------------------
 hw/scripts/jlink.sh   | 13 ++++++++++---
 hw/scripts/openocd.sh | 12 ++++++++----
 2 files changed, 18 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f6951e68/hw/scripts/jlink.sh
----------------------------------------------------------------------
diff --git a/hw/scripts/jlink.sh b/hw/scripts/jlink.sh
index 7b35017..5087ceb 100644
--- a/hw/scripts/jlink.sh
+++ b/hw/scripts/jlink.sh
@@ -17,6 +17,8 @@
 
 . $CORE_PATH/hw/scripts/common.sh
 
+JLINK_GDB_SERVER=JLinkGDBServer
+
 #
 # FILE_NAME is the file to load
 # FLASH_OFFSET is location in the flash
@@ -123,7 +125,7 @@ jlink_debug() {
             # Launch jlink server in a separate command interpreter, to make
             # sure it doesn't get killed by Ctrl-C signal from bash.
             #
-            $COMSPEC "/C start $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun"
+            $COMSPEC "/C start $COMSPEC /C $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun"
         else
             #
             # Block Ctrl-C from getting passed to jlink server.
@@ -141,8 +143,13 @@ jlink_debug() {
         fi
         echo "$EXTRA_GDB_CMDS" >> $GDB_CMD_FILE
 
-        arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
-        rm $GDB_CMD_FILE
+	if [ $WINDOWS -eq 1 ]; then
+	    FILE_NAME=`echo $FILE_NAME | sed 's/\//\\\\/g'`
+	    $COMSPEC "/C start $COMSPEC /C arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME"
+	else
+            arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
+            rm $GDB_CMD_FILE
+	fi
     else
         $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun
     fi

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f6951e68/hw/scripts/openocd.sh
----------------------------------------------------------------------
diff --git a/hw/scripts/openocd.sh b/hw/scripts/openocd.sh
index a20e451..12e5e32 100644
--- a/hw/scripts/openocd.sh
+++ b/hw/scripts/openocd.sh
@@ -84,8 +84,7 @@ openocd_debug () {
             # it doesn't get killed by Ctrl-C signal from bash.
             #
             CFG=`echo $CFG | sed 's/\//\\\\/g'`
-            echo $CFG
-            $COMSPEC "/C start openocd openocd $CFG -f $OCD_CMD_FILE -c init -c halt"
+            $COMSPEC "/C start $COMSPEC /C openocd -l openocd.log $CFG -f $OCD_CMD_FILE -c init -c halt"
         else
             #
             # Block Ctrl-C from getting passed to openocd.
@@ -101,8 +100,13 @@ openocd_debug () {
         if [ ! -z "$RESET" ]; then
             echo "mon reset halt" >> $GDB_CMD_FILE
         fi
-        arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
-        rm $GDB_CMD_FILE
+	if [ $WINDOWS -eq 1 ]; then
+	    FILE_NAME=`echo $FILE_NAME | sed 's/\//\\\\/g'`
+            $COMSPEC "/C start $COMSPEC /C arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME"
+	else
+            arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
+            rm $GDB_CMD_FILE
+	fi
     else
         # No GDB, wait for openocd to exit
         openocd $CFG -f $OCD_CMD_FILE -c init -c halt


[42/50] [abbrv] incubator-mynewt-core git commit: Add definition/value for MCU_FLASH_MIN_WRITE_SIZE

Posted by we...@apache.org.
Add definition/value for MCU_FLASH_MIN_WRITE_SIZE


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/88b87be0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/88b87be0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/88b87be0

Branch: refs/heads/nrf_cputime
Commit: 88b87be0dc3c576cc4ece38bbc0e46f3be731a8c
Parents: eed3250
Author: Fabio Utzig <ut...@utzig.org>
Authored: Thu Mar 23 19:28:58 2017 -0300
Committer: Fabio Utzig <ut...@utzig.org>
Committed: Thu Mar 23 19:28:58 2017 -0300

----------------------------------------------------------------------
 hw/mcu/stm/stm32f7xx/syscfg.yml | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/88b87be0/hw/mcu/stm/stm32f7xx/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f7xx/syscfg.yml b/hw/mcu/stm/stm32f7xx/syscfg.yml
new file mode 100644
index 0000000..d2cb541
--- /dev/null
+++ b/hw/mcu/stm/stm32f7xx/syscfg.yml
@@ -0,0 +1,24 @@
+# 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.
+#
+
+syscfg.defs:
+    MCU_FLASH_MIN_WRITE_SIZE:
+        description: >
+            Specifies the required alignment for internal flash writes.
+            Used internally by the newt tool.
+        value: 1


[46/50] [abbrv] incubator-mynewt-core git commit: This closes #214.

Posted by we...@apache.org.
This closes #214.

Merge branch 'fix-nucleo767-warning' of https://github.com/utzig/incubator-mynewt-core into develop


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/c6ad1e17
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c6ad1e17
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c6ad1e17

Branch: refs/heads/nrf_cputime
Commit: c6ad1e17c883c2a66346c18af77370b47f8061f7
Parents: 3c98680 88b87be
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Mar 23 17:05:11 2017 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Mar 23 17:05:11 2017 -0700

----------------------------------------------------------------------
 hw/mcu/stm/stm32f7xx/syscfg.yml | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
----------------------------------------------------------------------



[49/50] [abbrv] incubator-mynewt-core git commit: Low power timer. Only nrf52 right now.

Posted by we...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/controller/src/ble_ll_sched.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_sched.c b/net/nimble/controller/src/ble_ll_sched.c
index dd42c3f..ffe8ef3 100644
--- a/net/nimble/controller/src/ble_ll_sched.c
+++ b/net/nimble/controller/src/ble_ll_sched.c
@@ -21,24 +21,35 @@
 #include <string.h>
 #include "os/os.h"
 #include "os/os_cputime.h"
+#include "bsp.h"
 #include "ble/xcvr.h"
 #include "controller/ble_phy.h"
 #include "controller/ble_ll.h"
 #include "controller/ble_ll_sched.h"
 #include "controller/ble_ll_adv.h"
 #include "controller/ble_ll_scan.h"
+#include "controller/ble_ll_xcvr.h"
 #include "ble_ll_conn_priv.h"
 
 /* XXX: this is temporary. Not sure what I want to do here */
 struct hal_timer g_ble_ll_sched_timer;
 
+#ifdef BLE_XCVR_RFCLK
+/* Settling time of crystal, in ticks */
+uint8_t g_ble_ll_sched_xtal_ticks;
+#endif
+
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+uint8_t g_ble_ll_sched_offset_ticks;
+#endif
+
 #define BLE_LL_SCHED_ADV_WORST_CASE_USECS       \
     (BLE_LL_SCHED_MAX_ADV_PDU_USECS + BLE_LL_IFS + BLE_LL_SCHED_ADV_MAX_USECS \
      + XCVR_TX_SCHED_DELAY_USECS)
 
-
 #if (BLE_LL_SCHED_DEBUG == 1)
 int32_t g_ble_ll_sched_max_late;
+int32_t g_ble_ll_sched_max_early;
 #endif
 
 /* XXX: TODO:
@@ -155,6 +166,17 @@ ble_ll_sched_conn_reschedule(struct ble_ll_conn_sm *connsm)
     /* Get schedule element from connection */
     sch = &connsm->conn_sch;
 
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    /* Set schedule start and end times */
+    sch->start_time = connsm->anchor_point - g_ble_ll_sched_offset_ticks;
+    if (connsm->conn_role == BLE_LL_CONN_ROLE_SLAVE) {
+        usecs = connsm->slave_cur_window_widening;
+        sch->start_time -= (os_cputime_usecs_to_ticks(usecs) + 1);
+        sch->remainder = 0;
+    } else {
+        sch->remainder = connsm->anchor_point_usecs;
+    }
+#else
     /* Set schedule start and end times */
     if (connsm->conn_role == BLE_LL_CONN_ROLE_SLAVE) {
         usecs = XCVR_RX_SCHED_DELAY_USECS;
@@ -163,6 +185,7 @@ ble_ll_sched_conn_reschedule(struct ble_ll_conn_sm *connsm)
         usecs = XCVR_TX_SCHED_DELAY_USECS;
     }
     sch->start_time = connsm->anchor_point - os_cputime_usecs_to_ticks(usecs);
+#endif
     sch->end_time = connsm->ce_end_time;
 
     /* Better be past current time or we just leave */
@@ -236,8 +259,17 @@ ble_ll_sched_conn_reschedule(struct ble_ll_conn_sm *connsm)
         entry = start_overlap;
     }
 
+#ifdef BLE_XCVR_RFCLK
+    entry = TAILQ_FIRST(&g_ble_ll_sched_q);
+    if (entry == sch) {
+        ble_ll_xcvr_rfclk_timer_start(sch->start_time);
+    } else {
+        sch = entry;
+    }
+#else
     /* Get first on list */
     sch = TAILQ_FIRST(&g_ble_ll_sched_q);
+#endif
 
     OS_EXIT_CRITICAL(sr);
 
@@ -247,67 +279,108 @@ ble_ll_sched_conn_reschedule(struct ble_ll_conn_sm *connsm)
     return rc;
 }
 
+/**
+ * Called to schedule a connection when the current role is master.
+ *
+ * Context: Interrupt
+ *
+ * @param connsm
+ * @param ble_hdr
+ * @param pyld_len
+ *
+ * @return int
+ */
 int
-ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm, uint32_t adv_rxend,
-                        uint8_t req_slots)
+ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm,
+                        struct ble_mbuf_hdr *ble_hdr, uint8_t pyld_len)
 {
     int rc;
     os_sr_t sr;
-    uint32_t tps;
+    uint8_t req_slots;
     uint32_t initial_start;
     uint32_t earliest_start;
     uint32_t earliest_end;
     uint32_t dur;
     uint32_t itvl_t;
-    uint32_t ce_end_time;
+    uint32_t adv_rxend;
     struct ble_ll_sched_item *entry;
     struct ble_ll_sched_item *sch;
 
-    /* Better have a connsm */
-    assert(connsm != NULL);
-
     /* Get schedule element from connection */
     rc = -1;
     sch = &connsm->conn_sch;
-
+    req_slots = MYNEWT_VAL(BLE_LL_CONN_INIT_SLOTS);
+
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    /* XXX:
+     * The calculations for the 32kHz crystal bear alot of explanation. The
+     * earliest possible time that the master can start the connection with a
+     * slave is 1.25 msecs from the end of the connection request. The
+     * connection request is sent an IFS time from the end of the advertising
+     * packet that was received plus the time it takes to send the connection
+     * request. At 1 Mbps, this is 1752 usecs, or 57.41 ticks. Using 57 ticks
+     * makes us off ~13 usecs. Since we dont want to actually calculate the
+     * receive end time tick (this would take too long), we assume the end of
+     * the advertising PDU is 'now' (we call os_cputime_get32). We dont know
+     * how much time it will take to service the ISR but if we are more than the
+     * rx to tx time of the chip we will not be successful transmitting the
+     * connect request. All this means is that we presume that the slave will
+     * receive the connect request later than we expect but no earlier than
+     * 13 usecs before (this is important).
+     *
+     * The code then attempts to schedule the connection at the
+     * earliest time although this may not be possible. When the actual
+     * schedule start time is determined, the master has to determine if this
+     * time is more than a transmit window offset interval (1.25 msecs). The
+     * master has to tell the slave how many transmit window offsets there are
+     * from the earliest possible time to when the actual transmit start will
+     * occur. Later in this function you will see the calculation. The actual
+     * transmission start has to occur within the transmit window. The transmit
+     * window interval is in units of 1.25 msecs and has to be at least 1. To
+     * make things a bit easier (but less power efficient for the slave), we
+     * use a transmit window of 2. We do this because we dont quite know the
+     * exact start of the transmission and if we are too early or too late we
+     * could miss the transmit window. A final note: the actual transmission
+     * start (the anchor point) is sched offset ticks from the schedule start
+     * time. We dont add this to the calculation when calculating the window
+     * offset. The reason we dont do this is we want to insure we transmit
+     * after the window offset we tell the slave. For example, say we think
+     * we are transmitting 1253 usecs from the earliest start. This would cause
+     * us to send a transmit window offset of 1. Since we are actually
+     * transmitting earlier than the slave thinks we could end up transmitting
+     * before the window offset. Transmitting later is fine since we have the
+     * transmit window to do so. Transmitting before is bad, since the slave
+     * wont be listening. We could do better calculation if we wanted to use
+     * a transmit window of 1 as opposed to 2, but for now we dont care.
+     */
+    dur = req_slots * BLE_LL_SCHED_32KHZ_TICKS_PER_SLOT;
+    adv_rxend = os_cputime_get32();
+    earliest_start = adv_rxend + 57;    /* XXX: only works for 1 Mbps */
+    earliest_end = earliest_start + dur;
+    itvl_t = connsm->conn_itvl_ticks;
+#else
+    adv_rxend = ble_hdr->beg_cputime +
+        os_cputime_usecs_to_ticks(BLE_TX_DUR_USECS_M(pyld_len));
     /*
      * The earliest start time is 1.25 msecs from the end of the connect
      * request transmission. Note that adv_rxend is the end of the received
      * advertisement, so we need to add an IFS plus the time it takes to send
-     * the connection request
+     * the connection request. The 1.25 msecs starts from the end of the conn
+     * request.
      */
     dur = os_cputime_usecs_to_ticks(req_slots * BLE_LL_SCHED_USECS_PER_SLOT);
     earliest_start = adv_rxend +
         os_cputime_usecs_to_ticks(BLE_LL_IFS + BLE_LL_CONN_REQ_DURATION +
                                   BLE_LL_CONN_INITIAL_OFFSET);
     earliest_end = earliest_start + dur;
-
     itvl_t = os_cputime_usecs_to_ticks(connsm->conn_itvl * BLE_LL_CONN_ITVL_USECS);
+#endif
 
     /* We have to find a place for this schedule */
     OS_ENTER_CRITICAL(sr);
 
     /* The schedule item must occur after current running item (if any) */
     sch->start_time = earliest_start;
-
-    /*
-     * If we are currently in a connection, we add one slot time to the
-     * earliest start so we can end the connection reasonably.
-     */
-    if (ble_ll_state_get() == BLE_LL_STATE_CONNECTION) {
-        tps = os_cputime_usecs_to_ticks(BLE_LL_SCHED_USECS_PER_SLOT);
-        ce_end_time = ble_ll_conn_get_ce_end_time();
-        while ((int32_t)(ce_end_time - os_cputime_get32()) < 0) {
-            ce_end_time += tps;
-        }
-
-        /* Start at next slot boundary past earliest */
-        while ((int32_t)(ce_end_time - earliest_start) < 0) {
-            ce_end_time += tps;
-        }
-        earliest_start = ce_end_time;
-        earliest_end = earliest_start + dur;
-    }
     initial_start = earliest_start;
 
     if (!ble_ll_sched_insert_if_empty(sch)) {
@@ -338,6 +411,7 @@ ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm, uint32_t adv_rxend,
             }
         }
 
+        /* Must be able to schedule within one connection interval */
         if (!entry) {
             if ((earliest_start - initial_start) <= itvl_t) {
                 rc = 0;
@@ -346,18 +420,38 @@ ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm, uint32_t adv_rxend,
         }
 
         if (!rc) {
-            /* calculate number of connection intervals before start */
+            /* calculate number of window offsets. Each offset is 1.25 ms */
             sch->enqueued = 1;
-            connsm->tx_win_off = (earliest_start - initial_start) /
-                os_cputime_usecs_to_ticks(BLE_LL_CONN_ITVL_USECS);
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+            /*
+             * NOTE: we dont add sched offset ticks as we want to under-estimate
+             * the transmit window slightly since the window size is currently
+             * 2 when using a 32768 crystal.
+             */
+            dur = os_cputime_ticks_to_usecs(earliest_start - initial_start);
+            connsm->tx_win_off = dur / BLE_LL_CONN_TX_OFF_USECS;
+#else
+            dur = os_cputime_ticks_to_usecs(earliest_start - initial_start);
+            dur += XCVR_TX_SCHED_DELAY_USECS;
+            connsm->tx_win_off = dur / BLE_LL_CONN_TX_OFF_USECS;
+#endif
         }
     }
 
     if (!rc) {
         sch->start_time = earliest_start;
         sch->end_time = earliest_end;
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+        /*
+         * Since we have the transmit window to transmit in, we dont need
+         * to set the anchor point usecs; just transmit to the nearest tick.
+         */
+        connsm->anchor_point = earliest_start + g_ble_ll_sched_offset_ticks;
+        connsm->anchor_point_usecs = 0;
+#else
         connsm->anchor_point = earliest_start +
             os_cputime_usecs_to_ticks(XCVR_TX_SCHED_DELAY_USECS);
+#endif
         connsm->ce_end_time = earliest_end;
     }
 
@@ -371,6 +465,15 @@ ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm, uint32_t adv_rxend,
     return rc;
 }
 
+/**
+ * Schedules a slave connection for the first time.
+ *
+ * Context: Link Layer
+ *
+ * @param connsm
+ *
+ * @return int
+ */
 int
 ble_ll_sched_slave_new(struct ble_ll_conn_sm *connsm)
 {
@@ -380,15 +483,32 @@ ble_ll_sched_slave_new(struct ble_ll_conn_sm *connsm)
     struct ble_ll_sched_item *next_sch;
     struct ble_ll_sched_item *sch;
 
+#ifdef BLE_XCVR_RFCLK
+    int first;
+    first = 0;
+#endif
+
     /* Get schedule element from connection */
     rc = -1;
     sch = &connsm->conn_sch;
 
     /* Set schedule start and end times */
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    /*
+     * XXX: for now, we dont care about anchor point usecs for the slave. It
+     * does not matter if we turn on the receiver up to one tick before w
+     * need to. We also subtract one extra tick since the conversion from
+     * usecs to ticks could be off by up to 1 tick.
+     */
+    sch->start_time = connsm->anchor_point - g_ble_ll_sched_offset_ticks -
+        os_cputime_usecs_to_ticks(connsm->slave_cur_window_widening) - 1;
+#else
     sch->start_time = connsm->anchor_point -
         os_cputime_usecs_to_ticks(XCVR_RX_SCHED_DELAY_USECS +
                                   connsm->slave_cur_window_widening);
+#endif
     sch->end_time = connsm->ce_end_time;
+    sch->remainder = 0;
 
     /* We have to find a place for this schedule */
     OS_ENTER_CRITICAL(sr);
@@ -403,6 +523,9 @@ ble_ll_sched_slave_new(struct ble_ll_conn_sm *connsm)
     if (!entry) {
         /* Nothing in schedule. Schedule as soon as possible */
         rc = 0;
+#ifdef BLE_XCVR_RFCLK
+        first = 1;
+#endif
     } else {
         os_cputime_timer_stop(&g_ble_ll_sched_timer);
         while (1) {
@@ -435,9 +558,24 @@ ble_ll_sched_slave_new(struct ble_ll_conn_sm *connsm)
         if (!rc) {
             sch->enqueued = 1;
         }
+#ifdef BLE_XCVR_RFCLK
+        next_sch = TAILQ_FIRST(&g_ble_ll_sched_q);
+        if (next_sch == sch) {
+            first = 1;
+        } else {
+            sch = next_sch;
+        }
+#else
         sch = TAILQ_FIRST(&g_ble_ll_sched_q);
+#endif
     }
 
+#ifdef BLE_XCVR_RFCLK
+    if (first) {
+        ble_ll_xcvr_rfclk_timer_start(sch->start_time);
+    }
+#endif
+
     OS_EXIT_CRITICAL(sr);
 
     os_cputime_timer_start(&g_ble_ll_sched_timer, sch->start_time);
@@ -450,9 +588,6 @@ ble_ll_sched_adv_new(struct ble_ll_sched_item *sch)
 {
     int rc;
     os_sr_t sr;
-    uint8_t ll_state;
-    int32_t ticks;
-    uint32_t ce_end_time;
     uint32_t adv_start;
     uint32_t duration;
     struct ble_ll_sched_item *entry;
@@ -463,39 +598,12 @@ ble_ll_sched_adv_new(struct ble_ll_sched_item *sch)
     orig = sch;
 
     OS_ENTER_CRITICAL(sr);
-
-    /*
-     * If we are currently in a connection, we add one slot time to the
-     * earliest start so we can end the connection reasonably.
-     */
-    ll_state = ble_ll_state_get();
-    if (ll_state == BLE_LL_STATE_CONNECTION) {
-        ticks = (int32_t)os_cputime_usecs_to_ticks(BLE_LL_SCHED_MAX_TXRX_SLOT);
-        ce_end_time = ble_ll_conn_get_ce_end_time();
-        if ((int32_t)(ce_end_time - sch->start_time) < ticks) {
-            ce_end_time += ticks;
-        }
-        sch->start_time = ce_end_time;
-        sch->end_time = ce_end_time + duration;
-    }
-#if MYNEWT_VAL(BLE_MULTI_ADV_SUPPORT)
-    else if ((ll_state == BLE_LL_STATE_ADV) && (BLE_LL_ADV_INSTANCES > 1)) {
-        /*
-         * Since we currently dont know how long this item might be scheduled
-         * for we add what we think the worst-case time for the advertising
-         * scheduled item to be over. We add in a IFS for good measure.
-         */
-        sch->start_time += BLE_LL_SCHED_MAX_ADV_PDU_USECS + BLE_LL_IFS +
-            BLE_LL_SCHED_ADV_MAX_USECS + XCVR_TX_SCHED_DELAY_USECS;
-        sch->end_time = sch->start_time + duration;
-    }
-#endif
-
     entry = ble_ll_sched_insert_if_empty(sch);
     if (!entry) {
         rc = 0;
         adv_start = sch->start_time;
     } else {
+        /* XXX: no need to stop timer if not first on list. Modify code? */
         os_cputime_timer_stop(&g_ble_ll_sched_timer);
         TAILQ_FOREACH(entry, &g_ble_ll_sched_q, link) {
             /* We can insert if before entry in list */
@@ -529,13 +637,13 @@ ble_ll_sched_adv_new(struct ble_ll_sched_item *sch)
 
     ble_ll_adv_scheduled((struct ble_ll_adv_sm *)orig->cb_arg, adv_start);
 
-    OS_EXIT_CRITICAL(sr);
+#ifdef BLE_XCVR_RFCLK
+    if (orig == sch) {
+        ble_ll_xcvr_rfclk_timer_start(sch->start_time);
+    }
+#endif
 
-    /* XXX: some things to test. I am not sure that if we are passed the
-       output compare that we actually get the interrupt. */
-    /* XXX: I am not sure that if we receive a packet while scanning
-     * that we actually go back to scanning. I need to make sure
-       we re-enable the receive. Put an event in the log! */
+    OS_EXIT_CRITICAL(sr);
 
     os_cputime_timer_start(&g_ble_ll_sched_timer, sch->start_time);
 
@@ -653,6 +761,12 @@ ble_ll_sched_adv_reschedule(struct ble_ll_sched_item *sch, uint32_t *start,
         }
         sch->end_time = sch->start_time + duration;
         *start = sch->start_time;
+
+#ifdef BLE_XCVR_RFCLK
+        if (sch == TAILQ_FIRST(&g_ble_ll_sched_q)) {
+            ble_ll_xcvr_rfclk_timer_start(sch->start_time);
+        }
+#endif
     }
 
     OS_EXIT_CRITICAL(sr);
@@ -784,26 +898,33 @@ ble_ll_sched_execute_item(struct ble_ll_sched_item *sch)
 void
 ble_ll_sched_run(void *arg)
 {
-    int32_t dt;
     struct ble_ll_sched_item *sch;
 
     /* Look through schedule queue */
-    while ((sch = TAILQ_FIRST(&g_ble_ll_sched_q)) != NULL) {
+    sch = TAILQ_FIRST(&g_ble_ll_sched_q);
+    if (sch) {
+#if (BLE_LL_SCHED_DEBUG == 1)
+        int32_t dt;
+
         /* Make sure we have passed the start time of the first event */
         dt = (int32_t)(os_cputime_get32() - sch->start_time);
-        if (dt >= 0) {
-#if (BLE_LL_SCHED_DEBUG == 1)
-            if (dt > g_ble_ll_sched_max_late) {
-                g_ble_ll_sched_max_late = dt;
-            }
+        if (dt > g_ble_ll_sched_max_late) {
+            g_ble_ll_sched_max_late = dt;
+        }
+        if (dt < g_ble_ll_sched_max_early) {
+            g_ble_ll_sched_max_early = dt;
+        }
 #endif
-            /* Remove schedule item and execute the callback */
-            TAILQ_REMOVE(&g_ble_ll_sched_q, sch, link);
-            sch->enqueued = 0;
-            ble_ll_sched_execute_item(sch);
-        } else {
+
+        /* Remove schedule item and execute the callback */
+        TAILQ_REMOVE(&g_ble_ll_sched_q, sch, link);
+        sch->enqueued = 0;
+        ble_ll_sched_execute_item(sch);
+
+        /* Restart if there is an item on the schedule */
+        sch = TAILQ_FIRST(&g_ble_ll_sched_q);
+        if (sch) {
             os_cputime_timer_start(&g_ble_ll_sched_timer, sch->start_time);
-            break;
         }
     }
 }
@@ -837,6 +958,55 @@ ble_ll_sched_next_time(uint32_t *next_event_time)
     return rc;
 }
 
+#ifdef BLE_XCVR_RFCLK
+/**
+ * Checks to see if we need to restart the cputime timer which starts the
+ * rf clock settling.
+ *
+ * NOTE: Should only be called from the Link Layer task!
+ *
+ * Context: Link-Layer task.
+ *
+ */
+void
+ble_ll_sched_rfclk_chk_restart(void)
+{
+    int stop;
+    os_sr_t sr;
+    uint8_t ll_state;
+    int32_t time_till_next;
+    uint32_t next_time;
+
+    stop = 0;
+    OS_ENTER_CRITICAL(sr);
+    ll_state = ble_ll_state_get();
+    if (ble_ll_sched_next_time(&next_time)) {
+        /*
+         * If the time until the next event is too close, no need to start
+         * the timer. Leave clock on.
+         */
+        time_till_next = (int32_t)(next_time - os_cputime_get32());
+        if (time_till_next > g_ble_ll_data.ll_xtal_ticks) {
+            /* Stop the clock */
+            stop = 1;
+            ble_ll_xcvr_rfclk_timer_start(next_time);
+        }
+    } else {
+        stop = 1;
+    }
+
+    /* Only disable the rfclk if doing nothing */
+    if (stop && (ll_state == BLE_LL_STATE_STANDBY)) {
+        ble_ll_log(BLE_LL_LOG_ID_RFCLK_SCHED_DIS, g_ble_ll_data.ll_rfclk_state,
+                   0, 0);
+        ble_ll_xcvr_rfclk_disable();
+    }
+    OS_EXIT_CRITICAL(sr);
+}
+
+#endif
+
+
 /**
  * Stop the scheduler
  *
@@ -857,6 +1027,24 @@ ble_ll_sched_stop(void)
 int
 ble_ll_sched_init(void)
 {
+    /*
+     * Initialize max early to large negative number. This is used
+     * to determine the worst-case "early" time the schedule was called. Dont
+     * expect this to be less than -3 or -4.
+     */
+#if (BLE_LL_SCHED_DEBUG == 1)
+    g_ble_ll_sched_max_early = -50000;
+#endif
+
+    /*
+     * This is the offset from the start of the scheduled item until the actual
+     * tx/rx should occur, in ticks. We also "round up" to the nearest tick.
+     */
+#if MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768
+    g_ble_ll_sched_offset_ticks =
+        os_cputime_usecs_to_ticks(XCVR_TX_SCHED_DELAY_USECS + 30);
+#endif
+
     /* Initialize cputimer for the scheduler */
     os_cputime_timer_init(&g_ble_ll_sched_timer, ble_ll_sched_run, NULL);
     return 0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/controller/src/ble_ll_xcvr.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_xcvr.c b/net/nimble/controller/src/ble_ll_xcvr.c
new file mode 100644
index 0000000..50ab32e
--- /dev/null
+++ b/net/nimble/controller/src/ble_ll_xcvr.c
@@ -0,0 +1,153 @@
+/*
+ * 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 <stdint.h>
+#include <assert.h>
+#include "syscfg/syscfg.h"
+#include "os/os_cputime.h"
+#include "controller/ble_phy.h"
+#include "controller/ble_ll.h"
+#include "controller/ble_ll_xcvr.h"
+
+#ifdef BLE_XCVR_RFCLK
+int
+ble_ll_xcvr_rfclk_state(void)
+{
+    uint32_t expiry;
+
+    if (g_ble_ll_data.ll_rfclk_state == BLE_RFCLK_STATE_ON) {
+        expiry = g_ble_ll_data.ll_rfclk_start_time;
+        if ((int32_t)(os_cputime_get32() - expiry) >
+                g_ble_ll_data.ll_xtal_ticks) {
+            g_ble_ll_data.ll_rfclk_state = BLE_RFCLK_STATE_SETTLED;
+        }
+    }
+    return g_ble_ll_data.ll_rfclk_state;
+}
+
+void
+ble_ll_xcvr_rfclk_enable(void)
+{
+    g_ble_ll_data.ll_rfclk_state = BLE_RFCLK_STATE_ON;
+    ble_phy_rfclk_enable();
+}
+
+void
+ble_ll_xcvr_rfclk_disable(void)
+{
+    ble_phy_rfclk_disable();
+    g_ble_ll_data.ll_rfclk_state = BLE_RFCLK_STATE_OFF;
+}
+
+void
+ble_ll_xcvr_rfclk_stop(void)
+{
+    ble_ll_log(BLE_LL_LOG_ID_RFCLK_STOP, g_ble_ll_data.ll_rfclk_state, 0,0);
+    os_cputime_timer_stop(&g_ble_ll_data.ll_rfclk_timer);
+    ble_ll_xcvr_rfclk_disable();
+}
+
+uint32_t
+ble_ll_xcvr_rfclk_time_till_settled(void)
+{
+    int32_t dt;
+    uint32_t rc;
+
+    rc = 0;
+    if (g_ble_ll_data.ll_rfclk_state == BLE_RFCLK_STATE_ON) {
+        dt = (int32_t)(os_cputime_get32() - g_ble_ll_data.ll_rfclk_start_time);
+        assert(dt >= 0);
+        if (dt < g_ble_ll_data.ll_xtal_ticks) {
+            rc = g_ble_ll_data.ll_xtal_ticks - (uint32_t)dt;
+        }
+    }
+
+    return rc;
+}
+
+/**
+ * Called when the timer to turn on the RF CLOCK expires. This function checks
+ * the state of the clock. If the clock is off, the clock is turned on.
+ * Otherwise, we just exit.
+ *
+ * Context: Interrupt
+ *
+ * @param arg
+ */
+void
+ble_ll_xcvr_rfclk_timer_exp(void *arg)
+{
+    if (g_ble_ll_data.ll_rfclk_state == BLE_RFCLK_STATE_OFF) {
+        ble_ll_xcvr_rfclk_start_now(os_cputime_get32());
+    }
+}
+
+/**
+ * This API is used to turn on the rfclock without setting the cputime timer to
+ * start the clock at some later point.
+ *
+ * NOTE: presumes that the state of the rf clock was checked prior to calling.
+ *
+ * @param now
+ */
+void
+ble_ll_xcvr_rfclk_start_now(uint32_t now)
+{
+    ble_ll_xcvr_rfclk_enable();
+    g_ble_ll_data.ll_rfclk_start_time = now;
+    ble_ll_log(BLE_LL_LOG_ID_RFCLK_ENABLE, 0, 0, now);
+}
+
+/**
+ * Starts the timer that will turn the rf clock on. The 'cputime' is
+ * the time at which the clock needs to be settled.
+ *
+ * @param cputime   Time at which rfclock should be on and settled.
+ */
+void
+ble_ll_xcvr_rfclk_timer_start(uint32_t cputime)
+{
+    /*
+     * If we are currently in an advertising event or a connection event,
+     * no need to start the cputime timer
+     */
+    if ((g_ble_ll_data.ll_state == BLE_LL_STATE_ADV) ||
+        (g_ble_ll_data.ll_state == BLE_LL_STATE_CONNECTION)) {
+        return;
+    }
+
+    /* Account for the settling time */
+    cputime -= g_ble_ll_data.ll_xtal_ticks;
+
+    /*
+     * If the timer is on the list, we need to see if its expiry is before
+     * 'cputime'. If the expiry is before, no need to do anything. If it
+     * is after, we need to stop the timer and start at new time.
+     */
+    if (g_ble_ll_data.ll_rfclk_timer.link.tqe_prev != NULL) {
+        if ((int32_t)(cputime - g_ble_ll_data.ll_rfclk_timer.expiry) >= 0) {
+            return;
+        }
+        os_cputime_timer_stop(&g_ble_ll_data.ll_rfclk_timer);
+    }
+    os_cputime_timer_start(&g_ble_ll_data.ll_rfclk_timer, cputime);
+    ble_ll_log(BLE_LL_LOG_ID_RFCLK_START, g_ble_ll_data.ll_rfclk_state, 0,
+               g_ble_ll_data.ll_rfclk_timer.expiry);
+}
+#endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/controller/syscfg.yml
----------------------------------------------------------------------
diff --git a/net/nimble/controller/syscfg.yml b/net/nimble/controller/syscfg.yml
index 357decc..569010f 100644
--- a/net/nimble/controller/syscfg.yml
+++ b/net/nimble/controller/syscfg.yml
@@ -137,6 +137,14 @@ syscfg.defs:
             material often.
         value: '32'
 
+    # Crystal setting time
+    BLE_XTAL_SETTLE_TIME:
+        description: >
+            The settling time of the high-frequency oscillator. This is
+            used to turn on/off the clock used for the radio (assuming
+            the HW supports this). This value is in microseconds.
+        value: '0'
+
     # Configuration for LL supported features.
     #
     # There are a total 8 features that the LL can support. These can be found

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/host/src/ble_hs_hci_evt.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_hci_evt.c b/net/nimble/host/src/ble_hs_hci_evt.c
index cd98f7f..a9655e3 100644
--- a/net/nimble/host/src/ble_hs_hci_evt.c
+++ b/net/nimble/host/src/ble_hs_hci_evt.c
@@ -6,7 +6,7 @@
  * 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,
@@ -624,8 +624,8 @@ ble_hs_hci_evt_acl_process(struct os_mbuf *om)
 #if (BLETEST_THROUGHPUT_TEST == 0)
     BLE_HS_LOG(DEBUG, "ble_hs_hci_evt_acl_process(): conn_handle=%u pb=%x "
                       "len=%u data=",
-               BLE_HCI_DATA_HANDLE(hci_hdr.hdh_handle_pb_bc), 
-               BLE_HCI_DATA_PB(hci_hdr.hdh_handle_pb_bc), 
+               BLE_HCI_DATA_HANDLE(hci_hdr.hdh_handle_pb_bc),
+               BLE_HCI_DATA_PB(hci_hdr.hdh_handle_pb_bc),
                hci_hdr.hdh_len);
     ble_hs_log_mbuf(om);
     BLE_HS_LOG(DEBUG, "\n");

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/34d90190/net/nimble/include/nimble/ble.h
----------------------------------------------------------------------
diff --git a/net/nimble/include/nimble/ble.h b/net/nimble/include/nimble/ble.h
index b514131..6f29fd4 100644
--- a/net/nimble/include/nimble/ble.h
+++ b/net/nimble/include/nimble/ble.h
@@ -96,6 +96,9 @@ struct ble_mbuf_hdr
         struct ble_mbuf_hdr_txinfo txinfo;
     };
     uint32_t beg_cputime;
+#if (MYNEWT_VAL(OS_CPUTIME_FREQ) == 32768)
+    uint32_t rem_usecs;
+#endif
 };
 
 #define BLE_MBUF_HDR_CRC_OK(hdr)        \


[14/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-669 SensorAPI: Change UNUSED_DATA indicator

Posted by we...@apache.org.
MYNEWT-669 SensorAPI: Change UNUSED_DATA indicator

- Please see description of the ticket for details
  Adding bitfields to indicate validity of data


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/20ffb7e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/20ffb7e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/20ffb7e4

Branch: refs/heads/nrf_cputime
Commit: 20ffb7e4e23f9d3d78dde0dff27f326354f71a28
Parents: 699ca15
Author: Vipul Rahane <vi...@apache.org>
Authored: Tue Mar 14 12:24:04 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Mar 14 12:24:04 2017 -0700

----------------------------------------------------------------------
 hw/drivers/sensors/bno055/src/bno055.c         | 22 ++++++++++++++
 hw/drivers/sensors/lsm303dlhc/src/lsm303dlhc.c |  8 ++++++
 hw/drivers/sensors/sim/src/generic_accel.c     |  8 ++++--
 hw/drivers/sensors/sim/src/generic_mag.c       |  8 ++++--
 hw/drivers/sensors/tcs34725/src/tcs34725.c     | 14 ++++-----
 hw/drivers/sensors/tsl2561/src/tsl2561.c       |  4 +++
 hw/sensor/include/sensor/accel.h               | 10 +++----
 hw/sensor/include/sensor/color.h               |  2 +-
 hw/sensor/include/sensor/euler.h               |  9 +++---
 hw/sensor/include/sensor/light.h               |  9 +++---
 hw/sensor/include/sensor/mag.h                 |  9 +++---
 hw/sensor/include/sensor/quat.h                | 10 +++----
 hw/sensor/src/sensor_shell.c                   | 32 ++++++++++-----------
 13 files changed, 91 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/20ffb7e4/hw/drivers/sensors/bno055/src/bno055.c
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/bno055/src/bno055.c b/hw/drivers/sensors/bno055/src/bno055.c
index 6f50563..2ee775e 100644
--- a/hw/drivers/sensors/bno055/src/bno055.c
+++ b/hw/drivers/sensors/bno055/src/bno055.c
@@ -849,6 +849,11 @@ bno055_get_quat_data(void *datastruct)
     sqd->sqd_y = ((((uint16_t)buffer[5]) << 8) | ((uint16_t)buffer[4])) * scale;
     sqd->sqd_z = ((((uint16_t)buffer[7]) << 8) | ((uint16_t)buffer[6])) * scale;
 
+    sqd->sqd_w_is_valid = 1;
+    sqd->sqd_x_is_valid = 1;
+    sqd->sqd_y_is_valid = 1;
+    sqd->sqd_z_is_valid = 1;
+
     return 0;
 err:
     return rc;
@@ -954,6 +959,11 @@ bno055_get_vector_data(void *datastruct, int type)
             smd->smd_x = ((double)x)/16.0;
             smd->smd_y = ((double)y)/16.0;
             smd->smd_z = ((double)z)/16.0;
+
+            smd->smd_x_is_valid = 1;
+            smd->smd_y_is_valid = 1;
+            smd->smd_z_is_valid = 1;
+
             break;
         case SENSOR_TYPE_GYROSCOPE:
             sad = datastruct;
@@ -961,6 +971,10 @@ bno055_get_vector_data(void *datastruct, int type)
             sad->sad_x = ((double)x)/gyro_div;
             sad->sad_y = ((double)y)/gyro_div;
             sad->sad_z = ((double)z)/gyro_div;
+
+            sad->sad_x_is_valid = 1;
+            sad->sad_y_is_valid = 1;
+            sad->sad_z_is_valid = 1;
             break;
         case SENSOR_TYPE_EULER:
             sad = datastruct;
@@ -968,6 +982,10 @@ bno055_get_vector_data(void *datastruct, int type)
             sed->sed_h = ((double)x)/euler_div;
             sed->sed_r = ((double)y)/euler_div;
             sed->sed_p = ((double)z)/euler_div;
+
+            sed->sed_h_is_valid = 1;
+            sed->sed_r_is_valid = 1;
+            sed->sed_p_is_valid = 1;
             break;
         case SENSOR_TYPE_ACCELEROMETER:
         case SENSOR_TYPE_LINEAR_ACCEL:
@@ -977,6 +995,10 @@ bno055_get_vector_data(void *datastruct, int type)
             sad->sad_x = ((double)x)/acc_div;
             sad->sad_y = ((double)y)/acc_div;
             sad->sad_z = ((double)z)/acc_div;
+
+            sad->sad_x_is_valid = 1;
+            sad->sad_y_is_valid = 1;
+            sad->sad_z_is_valid = 1;
             break;
         default:
             BNO055_ERR("Not supported sensor type: %d\n", type);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/20ffb7e4/hw/drivers/sensors/lsm303dlhc/src/lsm303dlhc.c
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/lsm303dlhc/src/lsm303dlhc.c b/hw/drivers/sensors/lsm303dlhc/src/lsm303dlhc.c
index 1d5af6c..6151f5d 100644
--- a/hw/drivers/sensors/lsm303dlhc/src/lsm303dlhc.c
+++ b/hw/drivers/sensors/lsm303dlhc/src/lsm303dlhc.c
@@ -425,6 +425,10 @@ lsm303dlhc_sensor_read(struct sensor *sensor, sensor_type_t type,
         sad.sad_y = (float)y * mg_lsb * 9.80665F;
         sad.sad_z = (float)z * mg_lsb * 9.80665F;
 
+        sad.sad_x_is_valid = 1;
+        sad.sad_y_is_valid = 1;
+        sad.sad_z_is_valid = 1;
+
         /* Call data function */
         rc = data_func(sensor, data_arg, &sad);
         if (rc != 0) {
@@ -511,6 +515,10 @@ lsm303dlhc_sensor_read(struct sensor *sensor, sensor_type_t type,
         smd.smd_y = (float)y / gauss_lsb_xy * 100.0F;
         smd.smd_z = (float)z / gauss_lsb_z * 100.0F;
 
+        smd.smd_x_is_valid = 1;
+        smd.smd_y_is_valid = 1;
+        smd.smd_z_is_valid = 1;
+
         /* Call data function */
         rc = data_func(sensor, data_arg, &smd);
         if (rc != 0) {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/20ffb7e4/hw/drivers/sensors/sim/src/generic_accel.c
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/sim/src/generic_accel.c b/hw/drivers/sensors/sim/src/generic_accel.c
index df7316a..4481c19 100644
--- a/hw/drivers/sensors/sim/src/generic_accel.c
+++ b/hw/drivers/sensors/sim/src/generic_accel.c
@@ -135,8 +135,12 @@ sim_accel_sensor_read(struct sensor *sensor, sensor_type_t type,
      * returned.
      */
     sad.sad_x = 0.0;
-    sad.sad_y = SENSOR_ACCEL_DATA_UNUSED;
-    sad.sad_z = SENSOR_ACCEL_DATA_UNUSED;
+    sad.sad_y = 0.0;
+    sad.sad_z = 0.0;
+
+    sad.sad_x_is_valid = 1;
+    sad.sad_y_is_valid = 0;
+    sad.sad_z_is_valid = 0;
 
     if (sa->sa_cfg.sac_nr_axises > 1) {
         sad.sad_y = 0.0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/20ffb7e4/hw/drivers/sensors/sim/src/generic_mag.c
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/sim/src/generic_mag.c b/hw/drivers/sensors/sim/src/generic_mag.c
index f4eb385..49e9337 100644
--- a/hw/drivers/sensors/sim/src/generic_mag.c
+++ b/hw/drivers/sensors/sim/src/generic_mag.c
@@ -135,8 +135,12 @@ sim_mag_sensor_read(struct sensor *sensor, sensor_type_t type,
      * returned.
      */
     smd.smd_x = 0.0;
-    smd.smd_y = SENSOR_MAG_DATA_UNUSED;
-    smd.smd_z = SENSOR_MAG_DATA_UNUSED;
+    smd.smd_y = 0.0;
+    smd.smd_z = 0.0;
+
+    smd.smd_x_is_valid = 1;
+    smd.smd_y_is_valid = 0;
+    smd.smd_z_is_valid = 0;
 
     if (sm->sm_cfg.smc_nr_axises > 1) {
         smd.smd_y = 0.0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/20ffb7e4/hw/drivers/sensors/tcs34725/src/tcs34725.c
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/tcs34725/src/tcs34725.c b/hw/drivers/sensors/tcs34725/src/tcs34725.c
index d67ecd9..e20ecde 100644
--- a/hw/drivers/sensors/tcs34725/src/tcs34725.c
+++ b/hw/drivers/sensors/tcs34725/src/tcs34725.c
@@ -705,10 +705,6 @@ tcs34725_calc_colortemp_lux(struct sensor_color_data *scd, struct tcs34725 *tcs3
 
     scd->scd_lux = (-0.32466F * scd->scd_r) + (1.57837F * scd->scd_g) + (-0.73191F * scd->scd_b);
 
-    scd->scd_r_is_valid = 1;
-    scd->scd_g_is_valid = 1;
-    scd->scd_b_is_valid = 1;
-    scd->scd_c_is_valid = 1;
     scd->scd_colortemp_is_valid = 1;
     scd->scd_lux_is_valid = 1;
 
@@ -809,10 +805,6 @@ tcs34725_calc_colortemp_lux(struct sensor_color_data *scd, struct tcs34725 *tcs3
 
     scd->scd_colortemp = TCS34725_CT_COEF * (float)b_comp / (float)r_comp + TCS34725_CT_OFFSET;
 
-    scd->scd_r_is_valid = 1;
-    scd->scd_g_is_valid = 1;
-    scd->scd_b_is_valid = 1;
-    scd->scd_c_is_valid = 1;
     scd->scd_lux_is_valid = 1;
     scd->scd_colortemp_is_valid = 1;
     scd->scd_saturation_is_valid = 1;
@@ -860,6 +852,12 @@ tcs34725_sensor_read(struct sensor *sensor, sensor_type_t type,
         scd.scd_g = g;
         scd.scd_b = b;
         scd.scd_c = c;
+
+        scd.scd_r_is_valid = 1;
+        scd.scd_g_is_valid = 1;
+        scd.scd_b_is_valid = 1;
+        scd.scd_c_is_valid = 1;
+
         rc = tcs34725_calc_colortemp_lux(&scd, tcs34725);
         if (rc) {
             goto err;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/20ffb7e4/hw/drivers/sensors/tsl2561/src/tsl2561.c
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/tsl2561/src/tsl2561.c b/hw/drivers/sensors/tsl2561/src/tsl2561.c
index 8ea8ad3..27cd96e 100644
--- a/hw/drivers/sensors/tsl2561/src/tsl2561.c
+++ b/hw/drivers/sensors/tsl2561/src/tsl2561.c
@@ -672,6 +672,10 @@ tsl2561_sensor_read(struct sensor *sensor, sensor_type_t type,
         sld.sld_ir = ir;
         sld.sld_lux = lux;
 
+        sld.sld_full_is_valid = 1;
+        sld.sld_ir_is_valid   = 1;
+        sld.sld_lux_is_valid  = 1;
+
         /* Call data function */
         rc = data_func(sensor, data_arg, &sld);
         if (rc != 0) {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/20ffb7e4/hw/sensor/include/sensor/accel.h
----------------------------------------------------------------------
diff --git a/hw/sensor/include/sensor/accel.h b/hw/sensor/include/sensor/accel.h
index 17e3561..564888b 100644
--- a/hw/sensor/include/sensor/accel.h
+++ b/hw/sensor/include/sensor/accel.h
@@ -35,12 +35,12 @@ struct sensor_accel_data {
     float sad_x;
     float sad_y;
     float sad_z;
-} __attribute__((packed));
 
-/**
- * Accelerometer data is unused for this field.
- */
-#define SENSOR_ACCEL_DATA_UNUSED (-1)
+    /* Validity */
+    uint8_t sad_x_is_valid:1;
+    uint8_t sad_y_is_valid:1;
+    uint8_t sad_z_is_valid:1;
+} __attribute__((packed));
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/20ffb7e4/hw/sensor/include/sensor/color.h
----------------------------------------------------------------------
diff --git a/hw/sensor/include/sensor/color.h b/hw/sensor/include/sensor/color.h
index 46f3436..2cc40ca 100644
--- a/hw/sensor/include/sensor/color.h
+++ b/hw/sensor/include/sensor/color.h
@@ -43,7 +43,7 @@ struct sensor_color_data {
      */
     uint16_t scd_saturation;   /* Saturation        */
     uint16_t scd_saturation75; /* Saturation75      */
-    uint8_t scd_is_sat;        /* Sensor saturrated */
+    uint8_t scd_is_sat;        /* Sensor saturated  */
     float scd_cratio;          /* C Ratio           */
     uint16_t scd_maxlux;       /* Max Lux value     */
     uint16_t scd_ir;           /* Infrared value    */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/20ffb7e4/hw/sensor/include/sensor/euler.h
----------------------------------------------------------------------
diff --git a/hw/sensor/include/sensor/euler.h b/hw/sensor/include/sensor/euler.h
index 0b23ad1..0c95c56 100644
--- a/hw/sensor/include/sensor/euler.h
+++ b/hw/sensor/include/sensor/euler.h
@@ -36,13 +36,12 @@ struct sensor_euler_data {
     float sed_h;
     float sed_r;
     float sed_p;
+    /* Validity */
+    uint8_t sed_h_is_valid:1;
+    uint8_t sed_r_is_valid:1;
+    uint8_t sed_p_is_valid:1;
 } __attribute__((packed));
 
-/**
- * Euler angles data is unused for this field.
- */
-#define SENSOR_EULER_DATA_UNUSED (-1)
-
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/20ffb7e4/hw/sensor/include/sensor/light.h
----------------------------------------------------------------------
diff --git a/hw/sensor/include/sensor/light.h b/hw/sensor/include/sensor/light.h
index 677f5c4..c9cdf91 100644
--- a/hw/sensor/include/sensor/light.h
+++ b/hw/sensor/include/sensor/light.h
@@ -35,13 +35,12 @@ struct sensor_light_data {
     uint16_t sld_full;
     uint16_t sld_ir;
     uint32_t sld_lux;
+    /* Validity */
+    uint8_t sld_full_is_valid:1;
+    uint8_t sld_ir_is_valid:1;
+    uint8_t sld_lux_is_valid:1;
 } __attribute__((packed));
 
-/**
- * Luminosity Sensor data is unused for this field.
- */
-#define SENSOR_LIGHT_DATA_UNUSED (-1)
-
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/20ffb7e4/hw/sensor/include/sensor/mag.h
----------------------------------------------------------------------
diff --git a/hw/sensor/include/sensor/mag.h b/hw/sensor/include/sensor/mag.h
index 8387568..d43a28e 100644
--- a/hw/sensor/include/sensor/mag.h
+++ b/hw/sensor/include/sensor/mag.h
@@ -35,13 +35,12 @@ struct sensor_mag_data {
     float smd_x;
     float smd_y;
     float smd_z;
+    /* Validity */
+    uint8_t smd_x_is_valid:1;
+    uint8_t smd_y_is_valid:1;
+    uint8_t smd_z_is_valid:1;
 } __attribute__((packed));
 
-/**
- * Magnetometer data is unused for this field.
- */
-#define SENSOR_MAG_DATA_UNUSED (-1)
-
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/20ffb7e4/hw/sensor/include/sensor/quat.h
----------------------------------------------------------------------
diff --git a/hw/sensor/include/sensor/quat.h b/hw/sensor/include/sensor/quat.h
index 3abb132..77f96b7 100644
--- a/hw/sensor/include/sensor/quat.h
+++ b/hw/sensor/include/sensor/quat.h
@@ -36,13 +36,13 @@ struct sensor_quat_data {
     float sqd_y;
     float sqd_z;
     float sqd_w;
+    /* Validity */
+    uint8_t sqd_x_is_valid:1;
+    uint8_t sqd_y_is_valid:1;
+    uint8_t sqd_z_is_valid:1;
+    uint8_t sqd_w_is_valid:1;
 } __attribute__((packed));
 
-/**
- * Quaternion data is unused for this field.
- */
-#define SENSOR_QUAT_DATA_UNUSED (-1)
-
 #ifdef __cplusplus
 }
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/20ffb7e4/hw/sensor/src/sensor_shell.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_shell.c b/hw/sensor/src/sensor_shell.c
index 5fe0109..8fe2b21 100644
--- a/hw/sensor/src/sensor_shell.c
+++ b/hw/sensor/src/sensor_shell.c
@@ -132,13 +132,13 @@ sensor_shell_read_listener(struct sensor *sensor, void *arg, void *data)
         ctx->type == SENSOR_TYPE_GRAVITY) {
 
         sad = (struct sensor_accel_data *) data;
-        if (sad->sad_x != SENSOR_ACCEL_DATA_UNUSED) {
+        if (sad->sad_x_is_valid) {
             console_printf("x = %s ", sensor_ftostr(sad->sad_x, tmpstr, 13));
         }
-        if (sad->sad_y != SENSOR_ACCEL_DATA_UNUSED) {
+        if (sad->sad_y_is_valid) {
             console_printf("y = %s ", sensor_ftostr(sad->sad_y, tmpstr, 13));
         }
-        if (sad->sad_z != SENSOR_ACCEL_DATA_UNUSED) {
+        if (sad->sad_z_is_valid) {
             console_printf("z = %s", sensor_ftostr(sad->sad_z, tmpstr, 13));
         }
         console_printf("\n");
@@ -146,13 +146,13 @@ sensor_shell_read_listener(struct sensor *sensor, void *arg, void *data)
 
     if (ctx->type == SENSOR_TYPE_MAGNETIC_FIELD) {
         smd = (struct sensor_mag_data *) data;
-        if (smd->smd_x != SENSOR_MAG_DATA_UNUSED) {
+        if (smd->smd_x_is_valid) {
             console_printf("x = %s ", sensor_ftostr(smd->smd_x, tmpstr, 13));
         }
-        if (smd->smd_y != SENSOR_MAG_DATA_UNUSED) {
+        if (smd->smd_y_is_valid) {
             console_printf("y = %s ", sensor_ftostr(smd->smd_y, tmpstr, 13));
         }
-        if (smd->smd_z != SENSOR_MAG_DATA_UNUSED) {
+        if (smd->smd_z_is_valid) {
             console_printf("z = %s ", sensor_ftostr(smd->smd_z, tmpstr, 13));
         }
         console_printf("\n");
@@ -160,13 +160,13 @@ sensor_shell_read_listener(struct sensor *sensor, void *arg, void *data)
 
     if (ctx->type == SENSOR_TYPE_LIGHT) {
         sld = (struct sensor_light_data *) data;
-        if (sld->sld_full != SENSOR_LIGHT_DATA_UNUSED) {
+        if (sld->sld_full_is_valid) {
             console_printf("Full = %u, ", sld->sld_full);
         }
-        if (sld->sld_ir != SENSOR_LIGHT_DATA_UNUSED) {
+        if (sld->sld_ir_is_valid) {
             console_printf("IR = %u, ", sld->sld_ir);
         }
-        if (sld->sld_lux != SENSOR_LIGHT_DATA_UNUSED) {
+        if (sld->sld_lux_is_valid) {
             console_printf("Lux = %u, ", (unsigned int)sld->sld_lux);
         }
         console_printf("\n");
@@ -180,13 +180,13 @@ sensor_shell_read_listener(struct sensor *sensor, void *arg, void *data)
 
     if (ctx->type == SENSOR_TYPE_EULER) {
         sed = (struct sensor_euler_data *) data;
-        if (sed->sed_h != SENSOR_EULER_DATA_UNUSED) {
+        if (sed->sed_h_is_valid) {
             console_printf("h = %s", sensor_ftostr(sed->sed_h, tmpstr, 13));
         }
-        if (sed->sed_r != SENSOR_EULER_DATA_UNUSED) {
+        if (sed->sed_r_is_valid) {
             console_printf("r = %s", sensor_ftostr(sed->sed_r, tmpstr, 13));
         }
-        if (sed->sed_p != SENSOR_EULER_DATA_UNUSED) {
+        if (sed->sed_p_is_valid) {
             console_printf("p = %s", sensor_ftostr(sed->sed_p, tmpstr, 13));
         }
         console_printf("\n");
@@ -194,16 +194,16 @@ sensor_shell_read_listener(struct sensor *sensor, void *arg, void *data)
 
     if (ctx->type == SENSOR_TYPE_ROTATION_VECTOR) {
         sqd = (struct sensor_quat_data *) data;
-        if (sqd->sqd_x != SENSOR_QUAT_DATA_UNUSED) {
+        if (sqd->sqd_x_is_valid) {
             console_printf("x = %s ", sensor_ftostr(sqd->sqd_x, tmpstr, 13));
         }
-        if (sqd->sqd_y != SENSOR_QUAT_DATA_UNUSED) {
+        if (sqd->sqd_y_is_valid) {
             console_printf("y = %s ", sensor_ftostr(sqd->sqd_y, tmpstr, 13));
         }
-        if (sqd->sqd_z != SENSOR_QUAT_DATA_UNUSED) {
+        if (sqd->sqd_z_is_valid) {
             console_printf("z = %s ", sensor_ftostr(sqd->sqd_z, tmpstr, 13));
         }
-        if (sqd->sqd_w != SENSOR_QUAT_DATA_UNUSED) {
+        if (sqd->sqd_w_is_valid) {
             console_printf("w = %s ", sensor_ftostr(sqd->sqd_w, tmpstr, 13));
         }
         console_printf("\n");


[35/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-679 SensorAPI: Shell: Add "type" command

Posted by we...@apache.org.
MYNEWT-679 SensorAPI: Shell: Add "type" command


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b05acb19
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b05acb19
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b05acb19

Branch: refs/heads/nrf_cputime
Commit: b05acb191c26083e4577e074809d1cf795b64170
Parents: 6826562
Author: Vipul Rahane <vi...@apache.org>
Authored: Tue Mar 21 15:37:19 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Mar 21 15:37:19 2017 -0700

----------------------------------------------------------------------
 hw/sensor/src/sensor_shell.c | 97 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 97 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b05acb19/hw/sensor/src/sensor_shell.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_shell.c b/hw/sensor/src/sensor_shell.c
index 8d96445..b1917ce 100644
--- a/hw/sensor/src/sensor_shell.c
+++ b/hw/sensor/src/sensor_shell.c
@@ -92,6 +92,98 @@ sensor_cmd_display_sensor(struct sensor *sensor)
     console_printf("\n");
 }
 
+static int
+sensor_cmd_display_type(char **argv)
+{
+    int i;
+    int rc;
+    struct sensor *sensor;
+    unsigned int type;
+
+    /* Look up sensor by name */
+    sensor = sensor_mgr_find_next_bydevname(argv[2], NULL);
+    if (!sensor) {
+        console_printf("Sensor %s not found!\n", argv[2]);
+        rc = SYS_EINVAL;
+        goto err;
+    }
+
+    console_printf("sensor dev = %s, \ntype =\n", argv[2]);
+
+    for (i = 0; i < 32; i++) {
+        type = (0x1 << i) & sensor->s_types;
+        if (!type) {
+            continue;
+        }
+
+        switch (type) {
+            case SENSOR_TYPE_NONE:
+                console_printf("    no type: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_ACCELEROMETER:
+                console_printf("    accelerometer: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_MAGNETIC_FIELD:
+                console_printf("    magnetic field: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_GYROSCOPE:
+                console_printf("    gyroscope: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_LIGHT:
+                console_printf("    light: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_TEMPERATURE:
+                console_printf("    temperature: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_AMBIENT_TEMPERATURE:
+                console_printf("    ambient temperature: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_PRESSURE:
+                console_printf("    pressure: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_PROXIMITY:
+                console_printf("    proximity: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_RELATIVE_HUMIDITY:
+                console_printf("    humidity: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_ROTATION_VECTOR:
+                console_printf("    vector: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_ALTITUDE:
+                console_printf("    altitude: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_WEIGHT:
+                console_printf("    weight: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_LINEAR_ACCEL:
+                console_printf("    accel: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_GRAVITY:
+                console_printf("    gravity: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_EULER:
+                console_printf("    euler: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_COLOR:
+                console_printf("    color: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_USER_DEFINED_1:
+                console_printf("    user defined 1: 0x%x\n", type);
+                break;
+            case SENSOR_TYPE_USER_DEFINED_2:
+                console_printf("    user defined 2: 0x%x\n", type);
+                break;
+            default:
+                console_printf("    unknown type: 0x%x\n", type);
+                break;
+        }
+    }
+
+err:
+    return rc;
+}
+
 static void
 sensor_cmd_list_sensors(void)
 {
@@ -559,6 +651,11 @@ sensor_cmd_exec(int argc, char **argv)
         if (rc) {
             goto err;
         }
+    } else if (!strcmp(argv[1], "type")) {
+        rc = sensor_cmd_display_type(argv);
+        if (rc) {
+            goto err;
+        }
     } else {
         console_printf("Unknown sensor command %s\n", subcmd);
         rc = SYS_EINVAL;


[21/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-672 json encode test assumes buffer is 0ed

Posted by we...@apache.org.
MYNEWT-672 json encode test assumes buffer is 0ed


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/c87fac5c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c87fac5c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c87fac5c

Branch: refs/heads/nrf_cputime
Commit: c87fac5c7da225d1aaab6965109ebe1ec9a00c57
Parents: 90b34f8
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Mar 15 18:53:05 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Mar 15 18:53:05 2017 -0700

----------------------------------------------------------------------
 encoding/json/test/src/testcases/json_simple_encode.c | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c87fac5c/encoding/json/test/src/testcases/json_simple_encode.c
----------------------------------------------------------------------
diff --git a/encoding/json/test/src/testcases/json_simple_encode.c b/encoding/json/test/src/testcases/json_simple_encode.c
index 3aee7a6..79a77b4 100644
--- a/encoding/json/test/src/testcases/json_simple_encode.c
+++ b/encoding/json/test/src/testcases/json_simple_encode.c
@@ -79,6 +79,8 @@ TEST_CASE(test_json_simple_encode)
     rc = json_encode_object_finish(&encoder);
     TEST_ASSERT(rc == 0);
 
+    bigbuf[buf_index] = '\0';
+
     /* does it match what we expect it to */
     rc = strcmp(bigbuf, output);
     TEST_ASSERT(rc == 0);


[12/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-667 SensorAPI: Shell:

Posted by we...@apache.org.
 MYNEWT-667 SensorAPI: Shell:

- Invalid type in read crashes device and print type in user friendly manner
- Error handling was not taken care of Sensor type is bit field, printing it
  out as individual bits is better than printing the entire bitmap
- Also allow printing accepting type in hex, use strtol() instead of atoi()
  for parsing type


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/3f4a64d4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3f4a64d4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3f4a64d4

Branch: refs/heads/nrf_cputime
Commit: 3f4a64d442d513cb39bbd7ae265a5c9c4da38318
Parents: c9fbdfc
Author: Vipul Rahane <vi...@apache.org>
Authored: Mon Mar 13 14:44:45 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Mon Mar 13 14:47:02 2017 -0700

----------------------------------------------------------------------
 hw/drivers/sensors/tcs34725/src/tcs34725.c |  2 +-
 hw/sensor/src/sensor_shell.c               | 40 +++++++++++++++++++++----
 2 files changed, 35 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3f4a64d4/hw/drivers/sensors/tcs34725/src/tcs34725.c
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/tcs34725/src/tcs34725.c b/hw/drivers/sensors/tcs34725/src/tcs34725.c
index 7a4c07f..d67ecd9 100644
--- a/hw/drivers/sensors/tcs34725/src/tcs34725.c
+++ b/hw/drivers/sensors/tcs34725/src/tcs34725.c
@@ -753,7 +753,7 @@ tcs34725_calc_colortemp_lux(struct sensor_color_data *scd, struct tcs34725 *tcs3
         }
 
         /* Shock absorber */
-        os_time_delay((256 - (uint16_t)agc_list[agc_cur].ta_time) * 2.4 * 2 * OS_TICKS_PER_SEC);
+        os_time_delay((256 - ((uint16_t)agc_list[agc_cur].ta_time) * 2.4 * 2 * OS_TICKS_PER_SEC)/1000 + 1);
 
         rc = tcs34725_get_rawdata(&scd->scd_r, &scd->scd_g, &scd->scd_b, &scd->scd_c, tcs34725);
         if (rc) {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3f4a64d4/hw/sensor/src/sensor_shell.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_shell.c b/hw/sensor/src/sensor_shell.c
index fbddd96..8e65752 100644
--- a/hw/sensor/src/sensor_shell.c
+++ b/hw/sensor/src/sensor_shell.c
@@ -59,8 +59,19 @@ sensor_display_help(void)
 static void
 sensor_cmd_display_sensor(struct sensor *sensor)
 {
-    console_printf("sensor dev = %s, type = 0x%llx\n", sensor->s_dev->od_name,
-            sensor->s_types);
+    int type;
+    int i;
+
+    console_printf("sensor dev = %s, type = ", sensor->s_dev->od_name);
+
+    for (i = 0; i < 32; i++) {
+        type = (0x1 << i) & sensor->s_types;
+        if (type) {
+            console_printf("0x%x ", type);
+        }
+    }
+
+    console_printf("\n");
 }
 
 static void
@@ -243,7 +254,7 @@ sensor_shell_read_listener(struct sensor *sensor, void *arg, void *data)
     return (0);
 }
 
-static void
+static int
 sensor_cmd_read(char *name, sensor_type_t type, int nsamples)
 {
     struct sensor *sensor;
@@ -261,6 +272,14 @@ sensor_cmd_read(char *name, sensor_type_t type, int nsamples)
      */
     memset(&ctx, 0, sizeof(ctx));
 
+    if (!(type & sensor->s_types)) {
+        rc = SYS_EINVAL;
+        /* Directly return without trying to unregister */
+        console_printf("Read req for wrng type 0x%x from selected sensor: %s\n",
+                       (int)type, name);
+        return rc;
+    }
+
     ctx.type = type;
 
     listener.sl_sensor_type = type;
@@ -269,11 +288,14 @@ sensor_cmd_read(char *name, sensor_type_t type, int nsamples)
 
     rc = sensor_register_listener(sensor, &listener);
     if (rc != 0) {
-        goto err;
+        return rc;
     }
 
     while (1) {
         rc = sensor_read(sensor, type, NULL, NULL, OS_TIMEOUT_NEVER);
+        if (rc) {
+            goto err;
+        }
         if (ctx.num_entries >= nsamples) {
             break;
         }
@@ -281,8 +303,10 @@ sensor_cmd_read(char *name, sensor_type_t type, int nsamples)
 
     sensor_unregister_listener(sensor, &listener);
 
+    return 0;
 err:
-    return;
+    sensor_unregister_listener(sensor, &listener);
+    return rc;
 }
 
 int
@@ -370,7 +394,11 @@ sensor_cmd_exec(int argc, char **argv)
             rc = SYS_EINVAL;
             goto err;
         }
-        sensor_cmd_read(argv[2], (sensor_type_t) atoi(argv[3]), atoi(argv[4]));
+
+        rc = sensor_cmd_read(argv[2], (sensor_type_t) strtol(argv[3], NULL, 0), atoi(argv[4]));
+        if (rc) {
+            goto err;
+        }
     } else if (!strcmp(argv[1], "i2cscan")) {
         rc = sensor_cmd_i2cscan(argc, argv);
         if (rc) {


[20/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-671 Allow bletiny to be run from sim.

Posted by we...@apache.org.
MYNEWT-671 Allow bletiny to be run from sim.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/90b34f81
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/90b34f81
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/90b34f81

Branch: refs/heads/nrf_cputime
Commit: 90b34f810bc19662a317643d7b1b06f599002a83
Parents: 5490c39
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Mar 15 11:47:41 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Mar 15 11:47:41 2017 -0700

----------------------------------------------------------------------
 apps/bletiny/src/main.c | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/90b34f81/apps/bletiny/src/main.c
----------------------------------------------------------------------
diff --git a/apps/bletiny/src/main.c b/apps/bletiny/src/main.c
index c0177c0..8ee724e 100755
--- a/apps/bletiny/src/main.c
+++ b/apps/bletiny/src/main.c
@@ -1851,6 +1851,10 @@ main(void)
 {
     int rc;
 
+#ifdef ARCH_sim
+    mcu_sim_parse_args(argc, argv);
+#endif
+
     /* Initialize OS */
     sysinit();
 


[47/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-687: Reduce encryption scratchpad size on nrf51

Posted by we...@apache.org.
MYNEWT-687: Reduce encryption scratchpad size on nrf51

The nrf51 only required the maximum encrypted packet length (plus 16)
for its encryption scratchpad register. The code was using the max
PDU length of 251. The nrf51 can only support 27 byte encrypted frames.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/e7934faf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/e7934faf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/e7934faf

Branch: refs/heads/nrf_cputime
Commit: e7934fafce21fd27138fd9e15373ce44e30da682
Parents: c6ad1e1
Author: William San Filippo <wi...@runtime.io>
Authored: Fri Mar 24 14:02:31 2017 -0700
Committer: William San Filippo <wi...@runtime.io>
Committed: Fri Mar 24 14:04:04 2017 -0700

----------------------------------------------------------------------
 hw/drivers/nimble/nrf51/src/ble_phy.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e7934faf/hw/drivers/nimble/nrf51/src/ble_phy.c
----------------------------------------------------------------------
diff --git a/hw/drivers/nimble/nrf51/src/ble_phy.c b/hw/drivers/nimble/nrf51/src/ble_phy.c
index a18e73c..d6ca388 100644
--- a/hw/drivers/nimble/nrf51/src/ble_phy.c
+++ b/hw/drivers/nimble/nrf51/src/ble_phy.c
@@ -161,9 +161,8 @@ STATS_NAME_END(ble_phy_stats)
  */
 
 #if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
-/* XXX: test this. only needs 43 bytes. Should just not use the macro for this*/
-/* Per nordic, the number of bytes needed for scratch is 16 + MAX_PKT_SIZE */
-#define NRF_ENC_SCRATCH_WORDS   (((MYNEWT_VAL(BLE_LL_MAX_PKT_SIZE) + 16) + 3) / 4)
+/* Per nordic, the number of bytes needed for scratch is 16 + MAX_PKT_SIZE. */
+#define NRF_ENC_SCRATCH_WORDS   (((NRF_MAX_ENCRYPTED_PYLD_LEN + 16) + 3) / 4)
 
 uint32_t g_nrf_encrypt_scratchpad[NRF_ENC_SCRATCH_WORDS];
 


[16/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-669 NMP: Make max chunk size configurable.

Posted by we...@apache.org.
MYNEWT-669 NMP: Make max chunk size configurable.

Currently, the largest image or file chunk that a Mynewt device can
receive is hardcoded at 400 bytes. Furthermore, the largets CBOR
attribute that we can decode is 300 bytes long.This is not great because
this number is independent of the transport MTU, so the client has no
way of knowing the limit.

The fix is to create three new compile-time settings:

    * CBORATTR_MAX_SIZE
    * FS_UPLOAD_MAX_CHUNK_SIZE
    * IMGMGR_MAX_CHUNK_SIZE

and set them to 512 by default. This value is large enough to
accommodate full-size BLE packets.

This is still not a perfect solution because these values are not tied
to the MTU in any way. One way to truly solve this would be to have an
"NMP MTU" that the client can discover. That would be a pretty big
change.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/78946572
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/78946572
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/78946572

Branch: refs/heads/nrf_cputime
Commit: 78946572ddbf9489b47206ab42bb9bc348b7f008
Parents: fd20bc9
Author: Christopher Collins <cc...@apache.org>
Authored: Tue Mar 14 18:18:07 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Tue Mar 14 19:13:48 2017 -0700

----------------------------------------------------------------------
 encoding/cborattr/include/cborattr/cborattr.h |  3 ---
 encoding/cborattr/src/cborattr.c              |  5 +++--
 encoding/cborattr/syscfg.yml                  | 24 ++++++++++++++++++++++
 fs/fs/include/fs/fs.h                         |  1 -
 fs/fs/src/fs_nmgr.c                           |  4 ++--
 fs/fs/syscfg.yml                              |  6 ++++++
 mgmt/imgmgr/include/imgmgr/imgmgr.h           |  1 -
 mgmt/imgmgr/src/imgmgr.c                      |  2 +-
 mgmt/imgmgr/src/imgmgr_coredump.c             |  2 +-
 mgmt/imgmgr/syscfg.yml                        |  5 +++++
 10 files changed, 42 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/78946572/encoding/cborattr/include/cborattr/cborattr.h
----------------------------------------------------------------------
diff --git a/encoding/cborattr/include/cborattr/cborattr.h b/encoding/cborattr/include/cborattr/cborattr.h
index 7142df6..9e69ca9 100644
--- a/encoding/cborattr/include/cborattr/cborattr.h
+++ b/encoding/cborattr/include/cborattr/cborattr.h
@@ -38,9 +38,6 @@ extern "C" {
  * is a key/value pair.  keys are always text strings, but values can be
  * many different things (enumerated below) */
 
-    /* maximum size of the string attribute name for this decoder */
-#define CBOR_ATTR_MAX (128)
-
 typedef enum CborAttrType {
     CborAttrIntegerType = 1,
     CborAttrUnsignedIntegerType,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/78946572/encoding/cborattr/src/cborattr.c
----------------------------------------------------------------------
diff --git a/encoding/cborattr/src/cborattr.c b/encoding/cborattr/src/cborattr.c
index e78c8f9..d2e731a 100644
--- a/encoding/cborattr/src/cborattr.c
+++ b/encoding/cborattr/src/cborattr.c
@@ -17,6 +17,7 @@
  * under the License.
  */
 
+#include <syscfg/syscfg.h>
 #include <cborattr/cborattr.h>
 #include <tinycbor/cbor.h>
 #include <tinycbor/cbor_buf_reader.h>
@@ -139,7 +140,7 @@ cbor_internal_read_object(CborValue *root_value,
                           int offset)
 {
     const struct cbor_attr_t *cursor, *best_match;
-    char attrbuf[CBOR_ATTR_MAX + 1];
+    char attrbuf[MYNEWT_VAL(CBORATTR_MAX_SIZE) + 1];
     void *lptr;
     CborValue cur_value;
     CborError err = 0;
@@ -189,7 +190,7 @@ cbor_internal_read_object(CborValue *root_value,
         /* get the attribute */
         if (cbor_value_is_text_string(&cur_value)) {
             if (cbor_value_calculate_string_length(&cur_value, &len) == 0) {
-                if (len > CBOR_ATTR_MAX) {
+                if (len > MYNEWT_VAL(CBORATTR_MAX_SIZE)) {
                     err |= CborErrorDataTooLarge;
                     goto err_return;
                 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/78946572/encoding/cborattr/syscfg.yml
----------------------------------------------------------------------
diff --git a/encoding/cborattr/syscfg.yml b/encoding/cborattr/syscfg.yml
new file mode 100644
index 0000000..cc93c26
--- /dev/null
+++ b/encoding/cborattr/syscfg.yml
@@ -0,0 +1,24 @@
+# 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.
+#
+
+# Package: mgmt/imgmgr
+
+syscfg.defs:
+    CBORATTR_MAX_SIZE:
+        description: 'The maximum size of a CBOR attribute during decoding'
+        value: 512

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/78946572/fs/fs/include/fs/fs.h
----------------------------------------------------------------------
diff --git a/fs/fs/include/fs/fs.h b/fs/fs/include/fs/fs.h
index ce5da94..7fb85ec 100644
--- a/fs/fs/include/fs/fs.h
+++ b/fs/fs/include/fs/fs.h
@@ -81,7 +81,6 @@ int fs_dirent_is_dir(const struct fs_dirent *);
 
 #define FS_NMGR_ID_FILE     0
 
-#define FS_NMGR_MAX_MSG     400
 #define FS_NMGR_MAX_NAME    64
 
 #ifdef __cplusplus

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/78946572/fs/fs/src/fs_nmgr.c
----------------------------------------------------------------------
diff --git a/fs/fs/src/fs_nmgr.c b/fs/fs/src/fs_nmgr.c
index bd87697..15dd8bd 100644
--- a/fs/fs/src/fs_nmgr.c
+++ b/fs/fs/src/fs_nmgr.c
@@ -71,7 +71,7 @@ fs_nmgr_file_download(struct mgmt_cbuf *cb)
 {
     long long unsigned int off = UINT_MAX;
     char tmp_str[FS_NMGR_MAX_NAME + 1];
-    uint8_t img_data[FS_NMGR_MAX_MSG];
+    uint8_t img_data[MYNEWT_VAL(FS_UPLOAD_MAX_CHUNK_SIZE)];
     const struct cbor_attr_t dload_attr[3] = {
         [0] = {
             .attribute = "off",
@@ -141,7 +141,7 @@ err_close:
 static int
 fs_nmgr_file_upload(struct mgmt_cbuf *cb)
 {
-    uint8_t img_data[FS_NMGR_MAX_MSG];
+    uint8_t img_data[MYNEWT_VAL(FS_UPLOAD_MAX_CHUNK_SIZE)];
     char file_name[FS_NMGR_MAX_NAME + 1];
     size_t img_len;
     long long unsigned int off = UINT_MAX;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/78946572/fs/fs/syscfg.yml
----------------------------------------------------------------------
diff --git a/fs/fs/syscfg.yml b/fs/fs/syscfg.yml
index 3cf5a35..af9e4c3 100644
--- a/fs/fs/syscfg.yml
+++ b/fs/fs/syscfg.yml
@@ -28,3 +28,9 @@ syscfg.defs:
     FS_NMGR:
         description: 'Enables file system newtmgr commands.'
         value: 0
+
+    FS_UPLOAD_MAX_CHUNK_SIZE:
+        description: >
+            The maximum amount of file data that can fit in a
+            single NMP upload request
+        value: 512

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/78946572/mgmt/imgmgr/include/imgmgr/imgmgr.h
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/include/imgmgr/imgmgr.h b/mgmt/imgmgr/include/imgmgr/imgmgr.h
index bae9a94..3fb3fb1 100644
--- a/mgmt/imgmgr/include/imgmgr/imgmgr.h
+++ b/mgmt/imgmgr/include/imgmgr/imgmgr.h
@@ -32,7 +32,6 @@ extern "C" {
 #define IMGMGR_NMGR_ID_CORELIST     3
 #define IMGMGR_NMGR_ID_CORELOAD     4
 
-#define IMGMGR_NMGR_MAX_MSG         400
 #define IMGMGR_NMGR_MAX_NAME		64
 #define IMGMGR_NMGR_MAX_VER         25  /* 255.255.65535.4294967295\0 */
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/78946572/mgmt/imgmgr/src/imgmgr.c
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/src/imgmgr.c b/mgmt/imgmgr/src/imgmgr.c
index 7b4431e..b6f0a4c 100644
--- a/mgmt/imgmgr/src/imgmgr.c
+++ b/mgmt/imgmgr/src/imgmgr.c
@@ -225,7 +225,7 @@ imgr_find_by_hash(uint8_t *find, struct image_version *ver)
 static int
 imgr_upload(struct mgmt_cbuf *cb)
 {
-    uint8_t img_data[IMGMGR_NMGR_MAX_MSG];
+    uint8_t img_data[MYNEWT_VAL(IMGMGR_MAX_CHUNK_SIZE)];
     long long unsigned int off = UINT_MAX;
     long long unsigned int size = UINT_MAX;
     size_t data_len = 0;

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/78946572/mgmt/imgmgr/src/imgmgr_coredump.c
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/src/imgmgr_coredump.c b/mgmt/imgmgr/src/imgmgr_coredump.c
index 48058c9..26b9ea0 100644
--- a/mgmt/imgmgr/src/imgmgr_coredump.c
+++ b/mgmt/imgmgr/src/imgmgr_coredump.c
@@ -76,7 +76,7 @@ imgr_core_load(struct mgmt_cbuf *cb)
     int rc;
     int sz;
     const struct flash_area *fa;
-    uint8_t data[IMGMGR_NMGR_MAX_MSG];
+    uint8_t data[MYNEWT_VAL(IMGMGR_MAX_CHUNK_SIZE)];
     struct coredump_header *hdr;
     CborError g_err = CborNoError;
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/78946572/mgmt/imgmgr/syscfg.yml
----------------------------------------------------------------------
diff --git a/mgmt/imgmgr/syscfg.yml b/mgmt/imgmgr/syscfg.yml
index da42801..4f3c95d 100644
--- a/mgmt/imgmgr/syscfg.yml
+++ b/mgmt/imgmgr/syscfg.yml
@@ -27,3 +27,8 @@ syscfg.defs:
         value: 0
         restrictions:
             - SHELL_TASK
+    IMGMGR_MAX_CHUNK_SIZE:
+        description: >
+            The maximum amount of image or core data that can fit in a
+            single NMP message
+        value: 512


[41/50] [abbrv] incubator-mynewt-core git commit: Expose I2C0 on STM32F4 Discovery board

Posted by we...@apache.org.
Expose I2C0 on STM32F4 Discovery board


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/e82d1fc2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/e82d1fc2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/e82d1fc2

Branch: refs/heads/nrf_cputime
Commit: e82d1fc242bb6b041cb15a8e4c9dea997228298f
Parents: f5b3bf6
Author: Antoine Albertelli <an...@antoinealb.net>
Authored: Thu Mar 23 23:16:48 2017 +0100
Committer: Antoine Albertelli <an...@antoinealb.net>
Committed: Thu Mar 23 23:19:36 2017 +0100

----------------------------------------------------------------------
 hw/bsp/stm32f4discovery/src/hal_bsp.c | 22 ++++++++++++++++++++++
 hw/bsp/stm32f4discovery/syscfg.yml    |  4 ++++
 2 files changed, 26 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e82d1fc2/hw/bsp/stm32f4discovery/src/hal_bsp.c
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f4discovery/src/hal_bsp.c b/hw/bsp/stm32f4discovery/src/hal_bsp.c
index 5e5c3bd..a8d611a 100644
--- a/hw/bsp/stm32f4discovery/src/hal_bsp.c
+++ b/hw/bsp/stm32f4discovery/src/hal_bsp.c
@@ -34,6 +34,8 @@
 #include <stm32f407xx.h>
 #include <stm32f4xx_hal_gpio_ex.h>
 #include <mcu/stm32f4_bsp.h>
+#include "mcu/stm32f4xx_mynewt_hal.h"
+#include "hal/hal_i2c.h"
 
 #include "bsp/bsp.h"
 
@@ -55,6 +57,20 @@ static const struct stm32f4_uart_cfg uart_cfg[UART_CNT] = {
 };
 #endif
 
+#if MYNEWT_VAL(I2C_0)
+static struct stm32f4_hal_i2c_cfg i2c_cfg0 = {
+    .hic_i2c = I2C1,
+    .hic_rcc_reg = &RCC->APB1ENR,
+    .hic_rcc_dev = RCC_APB1ENR_I2C1EN,
+    .hic_pin_sda = MCU_GPIO_PORTB(9),		/* PB9 */
+    .hic_pin_scl = MCU_GPIO_PORTB(8),		/* PB8 */
+    .hic_pin_af = GPIO_AF4_I2C1,
+    .hic_10bit = 0,
+    .hic_speed = 100000				/* 100kHz */
+};
+#endif
+
+
 static const struct hal_bsp_mem_dump dump_cfg[] = {
     [0] = {
         .hbmd_start = &_ram_start,
@@ -100,6 +116,12 @@ hal_bsp_init(void)
 #if MYNEWT_VAL(TIMER_0)
     hal_timer_init(0, TIM9);
 #endif
+
+#if MYNEWT_VAL(I2C_0)
+    rc = hal_i2c_init(0, &i2c_cfg0);
+    assert(rc == 0);
+#endif
+
 }
 
 /**

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e82d1fc2/hw/bsp/stm32f4discovery/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f4discovery/syscfg.yml b/hw/bsp/stm32f4discovery/syscfg.yml
index 5df91a7..2cddf03 100644
--- a/hw/bsp/stm32f4discovery/syscfg.yml
+++ b/hw/bsp/stm32f4discovery/syscfg.yml
@@ -24,6 +24,10 @@ syscfg.defs:
     TIMER_0:
         description: 'Timer 0'
         value:  0
+    I2C_0:
+        description: 'I2C 0'
+        value:  0
+
 
 syscfg.vals:
     REBOOT_LOG_FLASH_AREA: FLASH_AREA_REBOOT_LOG


[43/50] [abbrv] incubator-mynewt-core git commit: This closes #213.

Posted by we...@apache.org.
This closes #213.

Merge branch 'stm32f4-discovery-i2c0' of https://github.com/antoinealb/incubator-mynewt-core into develop


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/22e0edd1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/22e0edd1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/22e0edd1

Branch: refs/heads/nrf_cputime
Commit: 22e0edd108aef57138be36be971f0d0cea519904
Parents: eed3250 e82d1fc
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Mar 23 15:31:33 2017 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Mar 23 15:31:33 2017 -0700

----------------------------------------------------------------------
 hw/bsp/stm32f4discovery/src/hal_bsp.c | 22 ++++++++++++++++++++++
 hw/bsp/stm32f4discovery/syscfg.yml    |  4 ++++
 2 files changed, 26 insertions(+)
----------------------------------------------------------------------



[38/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-633: Controller does not respond on LL_PHY_REQ

Posted by we...@apache.org.
MYNEWT-633: Controller does not respond on LL_PHY_REQ

Fix uninitialized local variable.

This closes #211.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/ded20e11
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ded20e11
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ded20e11

Branch: refs/heads/nrf_cputime
Commit: ded20e11444d67e6b040a50ab2623002cd513727
Parents: f5b3bf6
Author: William San Filippo <wi...@runtime.io>
Authored: Wed Mar 22 10:17:30 2017 -0700
Committer: William San Filippo <wi...@runtime.io>
Committed: Wed Mar 22 10:17:30 2017 -0700

----------------------------------------------------------------------
 net/nimble/controller/src/ble_ll_ctrl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ded20e11/net/nimble/controller/src/ble_ll_ctrl.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_ctrl.c b/net/nimble/controller/src/ble_ll_ctrl.c
index f933922..55f58e8 100644
--- a/net/nimble/controller/src/ble_ll_ctrl.c
+++ b/net/nimble/controller/src/ble_ll_ctrl.c
@@ -1559,6 +1559,10 @@ ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
 
     ble_ll_log(BLE_LL_LOG_ID_LL_CTRL_RX, opcode, len, 0);
 
+#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
+    restart_encryption = 0;
+#endif
+
     /* If opcode comes from reserved value or CtrlData fields is invalid
      * we shall respond with LL_UNKNOWN_RSP
      */
@@ -1569,10 +1573,6 @@ ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
         goto ll_ctrl_send_rsp;
     }
 
-#if (MYNEWT_VAL(BLE_LL_CFG_FEAT_LE_ENCRYPTION) == 1)
-    restart_encryption = 0;
-#endif
-
     /* Check if the feature is supported. */
     switch (opcode) {
     case BLE_LL_CTRL_LENGTH_REQ:


[45/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-683 SensorAPI: Add BNO055 driver

Posted by we...@apache.org.
MYNEWT-683 SensorAPI: Add BNO055 driver

- Add SensorAPI support
- Add interrupt support for bno055


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/3c986800
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3c986800
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3c986800

Branch: refs/heads/nrf_cputime
Commit: 3c98680026390d6e85da609aa2a63ba239c7f64b
Parents: b35132f
Author: Vipul Rahane <vi...@apache.org>
Authored: Thu Mar 23 15:58:05 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Thu Mar 23 15:59:11 2017 -0700

----------------------------------------------------------------------
 hw/drivers/sensors/bno055/src/bno055.c      | 553 +++++++++++++++++++++++
 hw/drivers/sensors/bno055/src/bno055_priv.h |  45 +-
 2 files changed, 595 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3c986800/hw/drivers/sensors/bno055/src/bno055.c
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/bno055/src/bno055.c b/hw/drivers/sensors/bno055/src/bno055.c
index 2ee775e..5f2993c 100644
--- a/hw/drivers/sensors/bno055/src/bno055.c
+++ b/hw/drivers/sensors/bno055/src/bno055.c
@@ -1478,6 +1478,559 @@ err:
     return rc;
 }
 
+/**
+ * Get threshold for interrupts
+ *
+ * @param ptr to threshold
+ * @return 0 on success, non-zero on failure
+ */
+int
+bno055_get_int_thresh(uint32_t intr, uint8_t *thresh)
+{
+    int rc;
+    uint8_t val;
+    uint8_t mask;
+    uint8_t reg;
+
+    mask = 0;
+    switch(intr) {
+        case BNO055_INT_ACC_HG:
+            reg = BNO055_ACCEL_HIGH_G_THRES_ADDR;
+            break;
+        case BNO055_INT_ACC_SM:
+        case BNO055_INT_ACC_NM:
+            reg = BNO055_ACCEL_NO_MOTION_THRES_ADDR;
+            break;
+        case BNO055_INT_ACC_AM:
+            reg = BNO055_ACCEL_ANY_MOTION_THRES_ADDR;
+            break;
+        case BNO055_INT_GYR_AM:
+            reg = BNO055_GYRO_ANY_MOTION_THRES_ADDR;
+            mask = 0x3F;
+            break;
+        case BNO055_INT_GYR_HR_X_AXIS:
+            reg = BNO055_GYRO_HIGHRATE_X_SET_ADDR;
+            mask = 0x1F;
+            break;
+        case BNO055_INT_GYR_HR_Y_AXIS:
+            reg = BNO055_GYRO_HIGHRATE_Y_SET_ADDR;
+            mask = 0x1F;
+            break;
+        case BNO055_INT_GYR_HR_Z_AXIS:
+            reg = BNO055_GYRO_HIGHRATE_Z_SET_ADDR;
+            mask = 0x1F;
+            break;
+        default:
+            rc = SYS_EINVAL;
+            goto err;
+    }
+
+    rc = bno055_read8(reg, &val);
+    if (rc) {
+        goto err;
+    }
+
+    *thresh = val | mask;
+
+    return 0;
+err:
+    return rc;
+}
+
+/**
+ * Set threshold for interrupts
+ *
+ * @param threshold
+ * @return 0 on success, non-zero on failure
+ */
+int
+bno055_set_int_thresh(uint32_t intr, uint8_t thresh)
+{
+    int rc;
+    uint8_t mask;
+    uint8_t val;
+    uint8_t reg;
+
+    mask = val = 0;
+    switch(intr) {
+        case BNO055_INT_ACC_HG:
+            reg = BNO055_ACCEL_HIGH_G_THRES_ADDR;
+            break;
+        case BNO055_INT_ACC_SM:
+        case BNO055_INT_ACC_NM:
+            reg = BNO055_ACCEL_NO_MOTION_THRES_ADDR;
+            break;
+        case BNO055_INT_ACC_AM:
+            reg = BNO055_ACCEL_ANY_MOTION_THRES_ADDR;
+            break;
+        case BNO055_INT_GYR_AM:
+            reg = BNO055_GYRO_ANY_MOTION_THRES_ADDR;
+            mask = 0x3F;
+            break;
+        case BNO055_INT_GYR_HR_X_AXIS:
+            reg = BNO055_GYRO_HIGHRATE_X_SET_ADDR;
+            mask = 0x1F;
+            break;
+        case BNO055_INT_GYR_HR_Y_AXIS:
+            reg = BNO055_GYRO_HIGHRATE_Y_SET_ADDR;
+            mask = 0x1F;
+            break;
+        case BNO055_INT_GYR_HR_Z_AXIS:
+            reg = BNO055_GYRO_HIGHRATE_Z_SET_ADDR;
+            mask = 0x1F;
+            break;
+        default:
+            rc = SYS_EINVAL;
+            goto err;
+    }
+
+    if (mask && thresh > mask) {
+        rc = SYS_EINVAL;
+        goto err;
+    }
+
+    if (mask) {
+        rc = bno055_read8(reg, &val);
+        if (rc) {
+            goto err;
+        }
+    }
+
+    thresh = thresh | val;
+
+    rc = bno055_write8(reg, thresh);
+    if (rc) {
+        goto err;
+    }
+
+    return 0;
+err:
+    return rc;
+}
+
+/**
+ * Get interrupt trigger delay
+ *
+ * @param ptr to duration
+ * @return 0 on success, non-zero on failure
+ */
+int
+bno055_get_int_duration(uint32_t intr, uint8_t *duration)
+{
+    int rc;
+    uint8_t val;
+    uint8_t mask;
+    uint8_t shift;
+    uint8_t reg;
+
+    mask = val = shift = 0;
+    switch(intr) {
+      case BNO055_INT_GYR_HR_X_AXIS:
+          reg = BNO055_GYRO_DURN_X_ADDR;
+          break;
+      case BNO055_INT_GYR_HR_Y_AXIS:
+          reg = BNO055_GYRO_DURN_Y_ADDR;
+          break;
+      case BNO055_INT_GYR_HR_Z_AXIS:
+          reg = BNO055_GYRO_DURN_Z_ADDR;
+          break;
+      case BNO055_INT_ACC_HG:
+          reg = BNO055_ACCEL_HIGH_G_DURN_ADDR;
+          break;
+      case BNO055_INT_ACC_NM:
+          reg = BNO055_ACCEL_NO_MOTION_SET_ADDR;
+          mask = 0x3F;
+          shift = 1;
+          break;
+      case BNO055_INT_ACC_AM:
+          reg = BNO055_ACCEL_INTR_SETTINGS_ADDR;
+          mask = 0x3;
+          break;
+      case BNO055_INT_GYR_AM:
+          reg = BNO055_GYRO_INTR_SETTINGS_ADDR;
+          mask = 0xc;
+          shift = 2;
+          break;
+      default:
+          rc = SYS_EINVAL;
+          goto err;
+    }
+
+    rc = bno055_read8(reg, &val);
+    if (rc) {
+        goto err;
+    }
+
+    *duration = val | mask;
+
+    if (shift) {
+        *duration >>= shift;
+    }
+
+    return 0;
+err:
+    return rc;
+}
+
+/**
+ * Set interrupt trigger delay
+ *
+ * @param ptr to duration
+ * @return 0 on success, non-zero on failure
+ */
+int
+bno055_set_int_duration(uint32_t intr, uint8_t duration)
+{
+    int rc;
+    uint8_t val;
+    uint8_t mask;
+    uint8_t shift;
+    uint8_t reg;
+
+    val = mask = shift = 0;
+    switch(intr) {
+      case BNO055_INT_GYR_HR_X_AXIS:
+          reg = BNO055_GYRO_DURN_X_ADDR;
+          break;
+      case BNO055_INT_GYR_HR_Y_AXIS:
+          reg = BNO055_GYRO_DURN_Y_ADDR;
+          break;
+      case BNO055_INT_GYR_HR_Z_AXIS:
+          reg = BNO055_GYRO_DURN_Z_ADDR;
+          break;
+      case BNO055_INT_ACC_HG:
+          reg = BNO055_ACCEL_HIGH_G_DURN_ADDR;
+          break;
+      case BNO055_INT_ACC_NM:
+          reg = BNO055_ACCEL_NO_MOTION_SET_ADDR;
+          mask = 0x3F;
+          shift = 1;
+          break;
+      case BNO055_INT_ACC_AM:
+          reg = BNO055_ACCEL_INTR_SETTINGS_ADDR;
+          mask = 0x3;
+          break;
+      case BNO055_INT_GYR_AM:
+          reg = BNO055_GYRO_INTR_SETTINGS_ADDR;
+          mask = 0x3;
+          shift = 2;
+          break;
+      default:
+          rc = SYS_EINVAL;
+          goto err;
+    }
+
+    if (mask && duration > mask) {
+        rc = SYS_EINVAL;
+        goto err;
+    }
+
+    rc = bno055_read8(reg, &val);
+    if (rc) {
+        goto err;
+    }
+
+    if (shift) {
+        duration <<= shift;
+    }
+
+    if (mask) {
+        rc = bno055_read8(reg, &val);
+        if (rc) {
+            goto err;
+        }
+    }
+
+    val |= duration;
+
+    rc = bno055_write8(reg, duration);
+    if (rc) {
+        goto err;
+    }
+
+    return 0;
+err:
+    return rc;
+}
+
+/**
+ * Enable axis interrupt,
+ *
+ * @param interrupt axis
+ * @return 0 on success, non-zero on failure
+ */
+int
+bno055_enable_int_axis(uint32_t intr_axis, uint8_t enable)
+{
+    int rc;
+    uint8_t reg;
+    uint8_t val;
+    uint8_t intr;
+
+    intr = 0;
+    if (intr_axis & BNO055_INT_ACC_AM || intr_axis & BNO055_INT_ACC_NM) {
+        reg = BNO055_ACCEL_INTR_SETTINGS_ADDR;
+        intr = (intr_axis >> BNO055_INT_ACC_AM_POS) & 0xFF;
+    }
+
+    if (intr_axis & BNO055_INT_ACC_HG) {
+        reg = BNO055_ACCEL_INTR_SETTINGS_ADDR;
+        intr = (intr_axis >> BNO055_INT_ACC_HG_POS) & 0xFF;
+    }
+
+    rc = bno055_read8(reg, &val);
+    if (rc) {
+        goto err;
+    }
+
+    intr = enable ? intr | val : intr & val;
+
+    rc = bno055_write8(reg, intr);
+    if (rc) {
+        goto err;
+    }
+
+    if (intr_axis & BNO055_INT_GYR_AM) {
+        reg = BNO055_GYRO_INTR_SETTINGS_ADDR;
+        intr = (intr_axis >> BNO055_INT_GYR_AM_POS) & 0xFF;
+    }
+
+    if (intr_axis & BNO055_INT_GYR_HR) {
+        reg = BNO055_GYRO_INTR_SETTINGS_ADDR;
+        intr = (intr_axis >> BNO055_INT_GYR_HR_POS) & 0xFF;
+    }
+
+    rc = bno055_read8(reg, &val);
+    if (rc) {
+        goto err;
+    }
+
+    intr = enable ? intr | val : intr & val;
+
+    rc = bno055_write8(reg, intr);
+    if (rc) {
+        goto err;
+    }
+
+    return 0;
+err:
+    return rc;
+}
+
+/**
+ * Get acc int settings
+ *
+ * @param ptr to int settings
+ * @return 0 on success, non-zero on failure
+ */
+int
+bno055_get_acc_int_settings(uint8_t *settings)
+{
+    int rc;
+    uint8_t val;
+
+    rc = bno055_read8(BNO055_ACCEL_INTR_SETTINGS_ADDR, &val);
+    if (rc) {
+        goto err;
+    }
+
+    *settings = val;
+err:
+    return rc;
+}
+
+/**
+ * Set acc int settings
+ *
+ * @param int settings
+ * @return 0 on success, non-zero on failure
+ */
+int
+bno055_set_acc_int_settings(uint8_t settings)
+{
+    int rc;
+
+    rc = bno055_write8(BNO055_ACCEL_INTR_SETTINGS_ADDR, settings);
+    if (rc) {
+        goto err;
+    }
+
+err:
+    return rc;
+}
+
+/**
+ * Get enabled/disabled interrupts
+ *
+ * @param ptr to interrupt mask
+ * @return 0 on success, non-zero on failure
+ */
+int
+bno055_get_int_enable(uint8_t *intr)
+{
+    int rc;
+    uint8_t val;
+    uint8_t mask;
+
+    rc = bno055_read8(BNO055_INT_EN_ADDR, &val);
+    if (rc) {
+        goto err;
+    }
+
+    mask |= (val & BNO055_INT_EN_ACC_AM ? BNO055_INT_ACC_AM : 0);
+    mask |= (val & BNO055_INT_EN_ACC_HG ? BNO055_INT_ACC_HG : 0);
+    mask |= (val & BNO055_INT_EN_GYR_HR ? BNO055_INT_GYR_HR : 0);
+    mask |= (val & BNO055_INT_EN_GYR_AM ? BNO055_INT_GYR_AM : 0);
+
+    if (val & BNO055_INT_EN_ACC_NM) {
+        val = 0;
+        rc = bno055_read8(BNO055_ACCEL_NO_MOTION_SET_ADDR, &val);
+        if (rc) {
+            goto err;
+        }
+
+        mask |= (val & BNO055_ACCEL_SMNM ? BNO055_INT_ACC_SM : BNO055_INT_ACC_NM);
+    }
+
+    return 0;
+err:
+    return rc;
+}
+
+/**
+ * Enable/Disable interrupts
+ *
+ * @param Interrupt mask
+ * @return 0 on success, non-zero on failure
+ */
+int
+bno055_set_int_enable(uint8_t intr, uint8_t enable)
+{
+    int rc;
+    uint8_t mask;
+    uint8_t smnm;
+    uint8_t val;
+
+    mask  = (intr & BNO055_INT_ACC_AM ? BNO055_INT_EN_ACC_AM : 0);
+    mask |= (intr & BNO055_INT_ACC_HG ? BNO055_INT_EN_ACC_HG : 0);
+    mask |= (intr & BNO055_INT_GYR_HR ? BNO055_INT_EN_GYR_HR : 0);
+    mask |= (intr & BNO055_INT_GYR_AM ? BNO055_INT_EN_GYR_AM : 0);
+
+    /* Both of them can't be set */
+    if (intr & BNO055_INT_ACC_NM && intr & BNO055_INT_ACC_SM) {
+        rc = SYS_EINVAL;
+        goto err;
+    }
+
+    smnm = 0;
+    if (intr & BNO055_INT_ACC_SM) {
+        smnm = 0xF0 | BNO055_ACCEL_SMNM;
+        mask |= BNO055_INT_EN_ACC_NM;
+    } else if (intr & BNO055_INT_ACC_NM) {
+        smnm = 0xF0;
+        mask |= BNO055_INT_EN_ACC_NM;
+    }
+
+    if (smnm) {
+        smnm &= 0x0F;
+        rc = bno055_read8(BNO055_ACCEL_NO_MOTION_SET_ADDR, &val);
+        if (rc) {
+            goto err;
+        }
+
+        val |= smnm;
+        rc = bno055_write8(BNO055_ACCEL_NO_MOTION_SET_ADDR, val);
+        if (rc) {
+            goto err;
+        }
+    }
+
+    val = 0;
+    rc = bno055_read8(BNO055_INT_EN_ADDR, &val);
+    if (rc) {
+        goto err;
+    }
+
+    if (enable) {
+        val |= mask;
+    } else {
+        val &= ~mask;
+    }
+
+    rc = bno055_write8(BNO055_INT_EN_ADDR, val);
+    if (rc) {
+        goto err;
+    }
+
+    return 0;
+err:
+    return rc;
+}
+
+/**
+ * Get interrupt status
+ *
+ * @param ptr to interrupt status to fill up
+ * @return 0 on success, non-zero on failure
+ */
+int
+bno055_get_int_status(uint8_t *int_mask)
+{
+    int rc;
+    uint8_t val;
+
+    rc = bno055_read8(BNO055_INTR_STAT_ADDR, &val);
+    if (rc) {
+        goto err;
+    }
+
+    *int_mask = val;
+err:
+    return rc;
+}
+
+/**
+ * Set interrupt mask
+ *
+ * @param Interrupt mask
+ * @return 0 on success, non-zero on failure
+ */
+int
+bno055_set_int_mask(uint8_t int_mask)
+{
+    int rc;
+
+    rc = bno055_write8(BNO055_INT_MASK_ADDR, int_mask);
+    if (rc) {
+        goto err;
+    }
+
+err:
+    return rc;
+}
+
+/**
+ * Get interrupt mask
+ *
+ * @param ptr to interrupt mask
+ * @return 0 on success, non-zero on failure
+ */
+int
+bno055_get_int_mask(uint8_t *int_mask)
+{
+    int rc;
+    uint8_t val;
+
+    rc = bno055_read8(BNO055_INT_MASK_ADDR, &val);
+    if (rc) {
+        goto err;
+    }
+
+    *int_mask = val;
+err:
+    return rc;
+}
+
 static void *
 bno055_sensor_get_interface(struct sensor *sensor, sensor_type_t type)
 {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3c986800/hw/drivers/sensors/bno055/src/bno055_priv.h
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/bno055/src/bno055_priv.h b/hw/drivers/sensors/bno055/src/bno055_priv.h
index b912a52..5e78b51 100644
--- a/hw/drivers/sensors/bno055/src/bno055_priv.h
+++ b/hw/drivers/sensors/bno055/src/bno055_priv.h
@@ -201,14 +201,24 @@
 
 /* Interrupt Registers */
 #define BNO055_INT_MASK_ADDR                                    0X0F
-#define BNO055_INT_ADDR                                         0X10
+
+#define BNO055_INT_EN_ADDR                                      0X10
+#define BNO055_INT_EN_ACC_NM                                (1 << 7)
+#define BNO055_INT_EN_ACC_AM                                (1 << 6)
+#define BNO055_INT_EN_ACC_HG                                (1 << 5)
+#define BNO055_INT_EN_GYR_HR                                (1 << 3)
+#define BNO055_INT_EN_GYR_AM                                (1 << 2)
+
 #define BNO055_ACCEL_ANY_MOTION_THRES_ADDR                      0X11
 #define BNO055_ACCEL_INTR_SETTINGS_ADDR                         0X12
 #define BNO055_ACCEL_HIGH_G_DURN_ADDR                           0X13
 #define BNO055_ACCEL_HIGH_G_THRES_ADDR                          0X14
+
 #define BNO055_ACCEL_NO_MOTION_THRES_ADDR                       0X15
+#define BNO055_ACCEL_SMNM                                   (1 << 0)
+
 #define BNO055_ACCEL_NO_MOTION_SET_ADDR                         0X16
-#define BNO055_GYRO_INTR_SETING_ADDR                            0X17
+#define BNO055_GYRO_INTR_SETTINGS_ADDR                          0X17
 #define BNO055_GYRO_HIGHRATE_X_SET_ADDR                         0X18
 #define BNO055_GYRO_DURN_X_ADDR                                 0X19
 #define BNO055_GYRO_HIGHRATE_Y_SET_ADDR                         0X1A
@@ -218,6 +228,35 @@
 #define BNO055_GYRO_ANY_MOTION_THRES_ADDR                       0X1E
 #define BNO055_GYRO_ANY_MOTION_SET_ADDR                         0X1F
 
-#define BNO055_NUM_OFFSET_REGISTERS                             22
+#define BNO055_NUM_OFFSET_REGISTERS                               22
+
+#define BNO055_INT_ACC_AM_POS                                      0
+#define BNO055_INT_ACC_HG_POS                                      8
+#define BNO055_INT_GYR_HR_POS                                     16
+#define BNO055_INT_GYR_AM_POS                                     24
+
+#define BNO055_INT_ACC_AM                                          1
+#define BNO055_INT_ACC_AM_X_AXIS   (1 << 2) << BNO055_INT_ACC_AM_POS
+#define BNO055_INT_ACC_AM_Y_AXIS   (1 << 3) << BNO055_INT_ACC_AM_POS
+#define BNO055_INT_ACC_AM_Z_AXIS   (1 << 4) << BNO055_INT_ACC_AM_POS
+
+#define BNO055_INT_ACC_HG                                          2
+#define BNO055_INT_ACC_HG_X_AXIS   (1 << 5) << BNO055_INT_ACC_HG_POS
+#define BNO055_INT_ACC_HG_Y_AXIS   (1 << 6) << BNO055_INT_ACC_HG_POS
+#define BNO055_INT_ACC_HG_Z_AXIS   (1 << 7) << BNO055_INT_ACC_HG_POS
+
+#define BNO055_INT_GYR_HR                                          4
+#define BNO055_INT_GYR_HR_X_AXIS   (1 << 3) << BNO055_INT_GYR_HR_POS
+#define BNO055_INT_GYR_HR_Y_AXIS   (1 << 4) << BNO055_INT_GYR_HR_POS
+#define BNO055_INT_GYR_HR_Z_AXIS   (1 << 5) << BNO055_INT_GYR_HR_POS
+
+#define BNO055_INT_GYR_AM                                          8
+#define BNO055_INT_GYR_AM_X_AXIS   (1 << 0) << BNO055_INT_GYR_AM_POS
+#define BNO055_INT_GYR_AM_Y_AXIS   (1 << 1) << BNO055_INT_GYR_AM_POS
+#define BNO055_INT_GYR_AM_Z_AXIS   (1 << 2) << BNO055_INT_GYR_AM_POS
+
+#define BNO055_INT_ACC_NM                                         16
+
+#define BNO055_INT_ACC_SM                                         32
 
 #define BNO055_ID                                               0xA0


[30/50] [abbrv] incubator-mynewt-core git commit: LICENSE; mention 3-clause BSD for LwIP, tinycrypt, and STM32CubeF7.

Posted by we...@apache.org.
LICENSE; mention 3-clause BSD for LwIP, tinycrypt, and STM32CubeF7.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/ea98953d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ea98953d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ea98953d

Branch: refs/heads/nrf_cputime
Commit: ea98953df698a6ae2c462a5487b5150bb77392dc
Parents: 63546ef
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Mar 21 10:34:23 2017 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Mar 21 10:34:23 2017 -0700

----------------------------------------------------------------------
 LICENSE | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/ea98953d/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index 2aa2fd9..0473ed5 100644
--- a/LICENSE
+++ b/LICENSE
@@ -289,6 +289,13 @@ This product bundles parts of STM32CubeF4 1.5, which is available under the
     * hw/bsp/stm32f4discovery/include/bsp/stm32f4xx_hal_conf.h
     * hw/bsp/stm32f4discovery/src/system_stm32f4xx.c
 
+This product bundles parts of STM32CubeF7, which is available under the
+"3-clause BSD" license.  Bundled files are:
+    * hw/mcu/stm/stm32f7xx/src/ext
+    * hw/bsp/stm32f767-nucleo/include/bsp/stm32f7xx_hal_conf.h
+    * hw/bsp/stm32f767-nucleo/src/system_stm32f7xx.c
+    * hw/bsp/stm32f767-nucleo/src/arch/cortex_m7/startup_stm32f767xx.s
+
 This product bundles parts of mbed, which is available under the
 "3-clause BSD" license.  Bundled files are:
     * hw/mcu/nordic/nrf51xxx/include/mcu/cortex_m0.h
@@ -352,8 +359,18 @@ This product bundles part of NXP mkw41z, which is available under the
     * hw/bsp/usbmkw41z/no-boot-mkw41z512.ld
     * hw/bsp/usbmkw41z/src/arch/cortex_m0/gcc_startup_mkw41z.s
 
-This product bundles part of mips architecture and ci40, which is available under the
-"3-clause BSD" license.  Bundled files are:
+This product bundles part of mips architecture and ci40, which is available
+under the "3-clause BSD" license.  Bundled files are:
     * kernel/os/src/arch/mips/asm/ctx.S
     * kernel/os/src/arch/mips/asm/excpt_isr.S
     * hw/bsp/ci40/uhi32.ld
+
+This product bundles LwIP, which is available under the "3-clause BSD"
+license. For details, and bundled files see:
+    * net/ip/lwip_base/COPYING
+    * net/ip/lwip_base
+
+This product bundles tinycrypt, which is available under the "3-clause BSD"
+license. For details, and bundled files see:
+    * crypto/tinycrypt/LICENSE
+    * crypto/tinycrypt


[19/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-671 Set default core flash area in native.

Posted by we...@apache.org.
MYNEWT-671 Set default core flash area in native.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/5490c39b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/5490c39b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/5490c39b

Branch: refs/heads/nrf_cputime
Commit: 5490c39b27ee9b8384af66a69ae4a4d3ffda9ebb
Parents: 4cf2e74
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Mar 15 11:46:22 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Mar 15 11:46:22 2017 -0700

----------------------------------------------------------------------
 hw/bsp/native/syscfg.yml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/5490c39b/hw/bsp/native/syscfg.yml
----------------------------------------------------------------------
diff --git a/hw/bsp/native/syscfg.yml b/hw/bsp/native/syscfg.yml
index b37b068..89171a5 100644
--- a/hw/bsp/native/syscfg.yml
+++ b/hw/bsp/native/syscfg.yml
@@ -21,3 +21,4 @@ syscfg.vals:
     NFFS_FLASH_AREA: FLASH_AREA_NFFS
     CONFIG_FCB_FLASH_AREA: FLASH_AREA_NFFS
     REBOOT_LOG_FLASH_AREA: FLASH_AREA_REBOOT_LOG
+    COREDUMP_FLASH_AREA: FLASH_AREA_IMAGE_1


[32/50] [abbrv] incubator-mynewt-core git commit: No Ticket - correct os_sem_init() comment

Posted by we...@apache.org.
No Ticket - correct os_sem_init() comment


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b5e0947a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b5e0947a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b5e0947a

Branch: refs/heads/nrf_cputime
Commit: b5e0947a0bc368cb8ac6adf7e10801e09fdfa17d
Parents: c93c7be
Author: Vipul Rahane <vi...@apache.org>
Authored: Sun Mar 19 22:42:16 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Mar 21 11:45:21 2017 -0700

----------------------------------------------------------------------
 kernel/os/src/os_sem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/b5e0947a/kernel/os/src/os_sem.c
----------------------------------------------------------------------
diff --git a/kernel/os/src/os_sem.c b/kernel/os/src/os_sem.c
index d347a61..02fecbf 100644
--- a/kernel/os/src/os_sem.c
+++ b/kernel/os/src/os_sem.c
@@ -35,9 +35,9 @@
  */
 
 /**
- * os sem create
+ * os sem initialize
  *
- * Create a semaphore and initialize it.
+ * Initialize a semaphore
  *
  * @param sem Pointer to semaphore
  *        tokens: # of tokens the semaphore should contain initially.


[40/50] [abbrv] incubator-mynewt-core git commit: Delete unused openocd script files.

Posted by we...@apache.org.
Delete unused openocd script files.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/eed3250d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/eed3250d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/eed3250d

Branch: refs/heads/nrf_cputime
Commit: eed3250d190fc03d49fe27fe899ce49ef7bdef59
Parents: ea988a0
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Thu Mar 23 15:09:09 2017 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Thu Mar 23 15:09:09 2017 -0700

----------------------------------------------------------------------
 hw/bsp/sensorhub/f407.cfg                   | 82 ------------------------
 hw/bsp/stm32f429discovery/f429.cfg          | 82 ------------------------
 hw/bsp/stm32f429discovery/f429discovery.cfg | 22 -------
 hw/bsp/stm32f767-nucleo/_f407.cfg           | 82 ------------------------
 4 files changed, 268 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/eed3250d/hw/bsp/sensorhub/f407.cfg
----------------------------------------------------------------------
diff --git a/hw/bsp/sensorhub/f407.cfg b/hw/bsp/sensorhub/f407.cfg
deleted file mode 100644
index 7c46d8b..0000000
--- a/hw/bsp/sensorhub/f407.cfg
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# 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.
-#
-
-# script for stm32f4x family
-
-if { [info exists CHIPNAME] } {
-   set _CHIPNAME $CHIPNAME
-} else {
-   set _CHIPNAME stm32f4x
-}
-
-if { [info exists ENDIAN] } {
-   set _ENDIAN $ENDIAN
-} else {
-   set _ENDIAN little
-}
-
-# Work-area is a space in RAM used for flash programming
-# By default use 64kB
-if { [info exists WORKAREASIZE] } {
-   set _WORKAREASIZE $WORKAREASIZE
-} else {
-   set _WORKAREASIZE 0x10000
-}
-
-# JTAG speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so use F_JTAG = 1MHz
-#
-# Since we may be running of an RC oscilator, we crank down the speed a
-# bit more to be on the safe side. Perhaps superstition, but if are
-# running off a crystal, we can run closer to the limit. Note
-# that there can be a pretty wide band where things are more or less stable.
-adapter_khz 1000
-
-adapter_nsrst_delay 100
-jtag_ntrst_delay 100
-
-#jtag scan chain
-if { [info exists CPUTAPID] } {
-   set _CPUTAPID $CPUTAPID
-} else {
-  # See STM Document RM0090
-  # Section 32.6.2 - corresponds to Cortex-M4 r0p1
-   set _CPUTAPID 0x4ba00477
-}
-jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
-
-if { [info exists BSTAPID] } {
-   set _BSTAPID $BSTAPID
-} else {
-  # See STM Document RM0090
-  # Section 32.6.3
-  set _BSTAPID 0x06413041
-}
-jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID
-
-set _TARGETNAME $_CHIPNAME.cpu
-target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
-
-$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
-
-set _FLASHNAME $_CHIPNAME.flash
-flash bank $_FLASHNAME stm32f2x 0 0 0 0 $_TARGETNAME
-
-# if srst is not fitted use SYSRESETREQ to
-# perform a soft reset
-cortex_m3 reset_config sysresetreq

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/eed3250d/hw/bsp/stm32f429discovery/f429.cfg
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f429discovery/f429.cfg b/hw/bsp/stm32f429discovery/f429.cfg
deleted file mode 100644
index cecf912..0000000
--- a/hw/bsp/stm32f429discovery/f429.cfg
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# 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.
-#
-
-# script for stm32f4x family
-
-if { [info exists CHIPNAME] } {
-   set _CHIPNAME $CHIPNAME
-} else {
-   set _CHIPNAME stm32f429x
-}
-
-if { [info exists ENDIAN] } {
-   set _ENDIAN $ENDIAN
-} else {
-   set _ENDIAN little
-}
-
-# Work-area is a space in RAM used for flash programming
-# By default use 64kB
-if { [info exists WORKAREASIZE] } {
-   set _WORKAREASIZE $WORKAREASIZE
-} else {
-   set _WORKAREASIZE 0x10000
-}
-
-# JTAG speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so use F_JTAG = 1MHz
-#
-# Since we may be running of an RC oscilator, we crank down the speed a
-# bit more to be on the safe side. Perhaps superstition, but if are
-# running off a crystal, we can run closer to the limit. Note
-# that there can be a pretty wide band where things are more or less stable.
-adapter_khz 1000
-
-adapter_nsrst_delay 100
-jtag_ntrst_delay 100
-
-#jtag scan chain
-if { [info exists CPUTAPID] } {
-   set _CPUTAPID $CPUTAPID
-} else {
-  # See STM Document RM0090
-  # Section 32.6.2 - corresponds to Cortex-M4 r0p1
-   set _CPUTAPID 0x4ba00477
-}
-jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
-
-if { [info exists BSTAPID] } {
-   set _BSTAPID $BSTAPID
-} else {
-  # See STM Document RM0090
-  # Section 32.6.3
-  set _BSTAPID 0x06413041
-}
-jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID
-
-set _TARGETNAME $_CHIPNAME.cpu
-target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
-
-$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
-
-set _FLASHNAME $_CHIPNAME.flash
-flash bank $_FLASHNAME stm32f2x 0 0 0 0 $_TARGETNAME
-
-# if srst is not fitted use SYSRESETREQ to
-# perform a soft reset
-cortex_m3 reset_config sysresetreq

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/eed3250d/hw/bsp/stm32f429discovery/f429discovery.cfg
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f429discovery/f429discovery.cfg b/hw/bsp/stm32f429discovery/f429discovery.cfg
deleted file mode 100644
index ac77b34..0000000
--- a/hw/bsp/stm32f429discovery/f429discovery.cfg
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-# 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.
-
-# New version of St-link
-source [find interface/stlink-v2-1.cfg]
-transport select hla_swd
-source [find target/stm32f4x.cfg]

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/eed3250d/hw/bsp/stm32f767-nucleo/_f407.cfg
----------------------------------------------------------------------
diff --git a/hw/bsp/stm32f767-nucleo/_f407.cfg b/hw/bsp/stm32f767-nucleo/_f407.cfg
deleted file mode 100644
index 7c46d8b..0000000
--- a/hw/bsp/stm32f767-nucleo/_f407.cfg
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# 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.
-#
-
-# script for stm32f4x family
-
-if { [info exists CHIPNAME] } {
-   set _CHIPNAME $CHIPNAME
-} else {
-   set _CHIPNAME stm32f4x
-}
-
-if { [info exists ENDIAN] } {
-   set _ENDIAN $ENDIAN
-} else {
-   set _ENDIAN little
-}
-
-# Work-area is a space in RAM used for flash programming
-# By default use 64kB
-if { [info exists WORKAREASIZE] } {
-   set _WORKAREASIZE $WORKAREASIZE
-} else {
-   set _WORKAREASIZE 0x10000
-}
-
-# JTAG speed should be <= F_CPU/6. F_CPU after reset is 8MHz, so use F_JTAG = 1MHz
-#
-# Since we may be running of an RC oscilator, we crank down the speed a
-# bit more to be on the safe side. Perhaps superstition, but if are
-# running off a crystal, we can run closer to the limit. Note
-# that there can be a pretty wide band where things are more or less stable.
-adapter_khz 1000
-
-adapter_nsrst_delay 100
-jtag_ntrst_delay 100
-
-#jtag scan chain
-if { [info exists CPUTAPID] } {
-   set _CPUTAPID $CPUTAPID
-} else {
-  # See STM Document RM0090
-  # Section 32.6.2 - corresponds to Cortex-M4 r0p1
-   set _CPUTAPID 0x4ba00477
-}
-jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
-
-if { [info exists BSTAPID] } {
-   set _BSTAPID $BSTAPID
-} else {
-  # See STM Document RM0090
-  # Section 32.6.3
-  set _BSTAPID 0x06413041
-}
-jtag newtap $_CHIPNAME bs -irlen 5 -expected-id $_BSTAPID
-
-set _TARGETNAME $_CHIPNAME.cpu
-target create $_TARGETNAME cortex_m3 -endian $_ENDIAN -chain-position $_TARGETNAME
-
-$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
-
-set _FLASHNAME $_CHIPNAME.flash
-flash bank $_FLASHNAME stm32f2x 0 0 0 0 $_TARGETNAME
-
-# if srst is not fitted use SYSRESETREQ to
-# perform a soft reset
-cortex_m3 reset_config sysresetreq


[13/50] [abbrv] incubator-mynewt-core git commit: SensorAPI: print console warning on if read fails

Posted by we...@apache.org.
SensorAPI: print console warning on if read fails

- If read fails because the sensor is not connected, print a message on
  the console.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/699ca157
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/699ca157
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/699ca157

Branch: refs/heads/nrf_cputime
Commit: 699ca157f6b4756ca5cd6d7710630a48a645f1c0
Parents: 3f4a64d
Author: Vipul Rahane <vi...@apache.org>
Authored: Mon Mar 13 15:41:56 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Mon Mar 13 15:41:56 2017 -0700

----------------------------------------------------------------------
 hw/sensor/src/sensor_shell.c | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/699ca157/hw/sensor/src/sensor_shell.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_shell.c b/hw/sensor/src/sensor_shell.c
index 8e65752..5fe0109 100644
--- a/hw/sensor/src/sensor_shell.c
+++ b/hw/sensor/src/sensor_shell.c
@@ -294,6 +294,7 @@ sensor_cmd_read(char *name, sensor_type_t type, int nsamples)
     while (1) {
         rc = sensor_read(sensor, type, NULL, NULL, OS_TIMEOUT_NEVER);
         if (rc) {
+            console_printf("Cannot read sensor %s\n", name);
             goto err;
         }
         if (ctx.num_entries >= nsamples) {


[48/50] [abbrv] incubator-mynewt-core git commit: nimble/controller: Slight refactor of use of pkt receive time

Posted by we...@apache.org.
nimble/controller: Slight refactor of use of pkt receive time

Modified the code so that the packet receive time is used in less
places. No functionality change.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/e888457f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/e888457f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/e888457f

Branch: refs/heads/nrf_cputime
Commit: e888457f1471005793b9da4b989c6825f59d8c58
Parents: e7934fa
Author: William San Filippo <wi...@runtime.io>
Authored: Thu Jan 19 14:57:21 2017 -0800
Committer: William San Filippo <wi...@runtime.io>
Committed: Fri Mar 24 14:14:05 2017 -0700

----------------------------------------------------------------------
 .../controller/include/controller/ble_ll_conn.h |  2 +-
 net/nimble/controller/src/ble_ll_adv.c          |  7 +------
 net/nimble/controller/src/ble_ll_conn.c         | 21 ++++++++------------
 net/nimble/controller/src/ble_ll_conn_priv.h    |  2 +-
 4 files changed, 11 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e888457f/net/nimble/controller/include/controller/ble_ll_conn.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/include/controller/ble_ll_conn.h b/net/nimble/controller/include/controller/ble_ll_conn.h
index d0badff..b2e6410 100644
--- a/net/nimble/controller/include/controller/ble_ll_conn.h
+++ b/net/nimble/controller/include/controller/ble_ll_conn.h
@@ -202,7 +202,7 @@ struct ble_ll_conn_sm
     uint16_t max_ce_len;
     uint16_t tx_win_off;
     uint32_t anchor_point;
-    uint32_t last_anchor_point;
+    uint32_t last_anchor_point;     /* Slave only */
     uint32_t slave_cur_tx_win_usecs;
     uint32_t slave_cur_window_widening;
     uint32_t last_rxd_pdu_cputime;  /* Used exclusively for supervision timer */

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e888457f/net/nimble/controller/src/ble_ll_adv.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_adv.c b/net/nimble/controller/src/ble_ll_adv.c
index 1130638..203f13a 100644
--- a/net/nimble/controller/src/ble_ll_adv.c
+++ b/net/nimble/controller/src/ble_ll_adv.c
@@ -1209,14 +1209,12 @@ ble_ll_adv_conn_req_rxd(uint8_t *rxbuf, struct ble_mbuf_hdr *hdr,
                         struct ble_ll_adv_sm *advsm)
 {
     int valid;
-    uint8_t pyld_len;
 #if MYNEWT_VAL(BLE_LL_CFG_FEAT_LL_PRIVACY)
     uint8_t resolved;
 #endif
     uint8_t addr_type;
     uint8_t *inita;
     uint8_t *ident_addr;
-    uint32_t endtime;
 
     /* Check filter policy. */
     valid = 0;
@@ -1275,10 +1273,7 @@ ble_ll_adv_conn_req_rxd(uint8_t *rxbuf, struct ble_mbuf_hdr *hdr,
 #endif
 
         /* Try to start slave connection. If successful, stop advertising */
-        pyld_len = rxbuf[1] & BLE_ADV_PDU_HDR_LEN_MASK;
-        endtime = hdr->beg_cputime +
-            os_cputime_usecs_to_ticks(BLE_TX_DUR_USECS_M(pyld_len));
-        valid = ble_ll_conn_slave_start(rxbuf, endtime, addr_type, hdr);
+        valid = ble_ll_conn_slave_start(rxbuf, addr_type, hdr);
         if (valid) {
             ble_ll_adv_sm_stop(advsm);
         }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e888457f/net/nimble/controller/src/ble_ll_conn.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn.c b/net/nimble/controller/src/ble_ll_conn.c
index d8d3f8f..c0cda6d 100644
--- a/net/nimble/controller/src/ble_ll_conn.c
+++ b/net/nimble/controller/src/ble_ll_conn.c
@@ -1770,11 +1770,11 @@ ble_ll_conn_next_event(struct ble_ll_conn_sm *connsm)
  * @ return 0: connection NOT created. 1: connection created
  */
 static int
-ble_ll_conn_created(struct ble_ll_conn_sm *connsm, uint32_t endtime,
-                    struct ble_mbuf_hdr *rxhdr)
+ble_ll_conn_created(struct ble_ll_conn_sm *connsm, struct ble_mbuf_hdr *rxhdr)
 {
     int rc;
     uint8_t *evbuf;
+    uint32_t endtime;
     uint32_t usecs;
 
     /* Set state to created */
@@ -1798,8 +1798,10 @@ ble_ll_conn_created(struct ble_ll_conn_sm *connsm, uint32_t endtime,
      * the transmit window offset from the end of the connection request.
      */
     rc = 1;
-    connsm->last_anchor_point = endtime;
     if (connsm->conn_role == BLE_LL_CONN_ROLE_SLAVE) {
+        endtime = rxhdr->beg_cputime +
+            os_cputime_usecs_to_ticks(BLE_TX_DUR_USECS_M(BLE_CONNECT_REQ_LEN));
+        connsm->last_anchor_point = endtime;
         connsm->slave_cur_tx_win_usecs =
             connsm->tx_win_size * BLE_LL_CONN_TX_WIN_USECS;
         usecs = 1250 + (connsm->tx_win_off * BLE_LL_CONN_TX_WIN_USECS);
@@ -2169,9 +2171,7 @@ ble_ll_init_rx_pkt_in(uint8_t *rxbuf, struct ble_mbuf_hdr *ble_hdr)
     int8_t rpa_index;
 #endif
     uint8_t addr_type;
-    uint8_t payload_len;
     uint8_t *addr;
-    uint32_t endtime;
     struct ble_ll_conn_sm *connsm;
 
     /* Get the connection state machine we are trying to create */
@@ -2216,10 +2216,7 @@ ble_ll_init_rx_pkt_in(uint8_t *rxbuf, struct ble_mbuf_hdr *ble_hdr)
         /* Connection has been created. Stop scanning */
         g_ble_ll_conn_create_sm = NULL;
         ble_ll_scan_sm_stop(0);
-        payload_len = rxbuf[1] & BLE_ADV_PDU_HDR_LEN_MASK;
-        endtime = ble_hdr->beg_cputime +
-            os_cputime_usecs_to_ticks(BLE_TX_DUR_USECS_M(payload_len));
-        ble_ll_conn_created(connsm, endtime, NULL);
+        ble_ll_conn_created(connsm, NULL);
     } else {
         ble_ll_scan_chk_resume();
     }
@@ -3040,8 +3037,7 @@ ble_ll_conn_set_global_chanmap(uint8_t num_used_chans, uint8_t *chanmap)
  * @return 0: connection not started; 1 connecton started
  */
 int
-ble_ll_conn_slave_start(uint8_t *rxbuf, uint32_t conn_req_end, uint8_t pat,
-                        struct ble_mbuf_hdr *rxhdr)
+ble_ll_conn_slave_start(uint8_t *rxbuf, uint8_t pat, struct ble_mbuf_hdr *rxhdr)
 {
     int rc;
     uint32_t temp;
@@ -3134,8 +3130,7 @@ ble_ll_conn_slave_start(uint8_t *rxbuf, uint32_t conn_req_end, uint8_t pat,
 
     /* Set initial schedule callback */
     connsm->conn_sch.sched_cb = ble_ll_conn_event_start_cb;
-
-    rc = ble_ll_conn_created(connsm, conn_req_end, rxhdr);
+    rc = ble_ll_conn_created(connsm, rxhdr);
     if (!rc) {
         SLIST_REMOVE(&g_ble_ll_conn_active_list, connsm, ble_ll_conn_sm, act_sle);
         STAILQ_INSERT_TAIL(&g_ble_ll_conn_free_list, connsm, free_stqe);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/e888457f/net/nimble/controller/src/ble_ll_conn_priv.h
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_conn_priv.h b/net/nimble/controller/src/ble_ll_conn_priv.h
index f3ede51..0913892 100644
--- a/net/nimble/controller/src/ble_ll_conn_priv.h
+++ b/net/nimble/controller/src/ble_ll_conn_priv.h
@@ -103,7 +103,7 @@ void ble_ll_conn_datalen_update(struct ble_ll_conn_sm *connsm,
                                 struct ble_ll_len_req *req);
 
 /* Advertising interface */
-int ble_ll_conn_slave_start(uint8_t *rxbuf, uint32_t conn_req_end, uint8_t pat,
+int ble_ll_conn_slave_start(uint8_t *rxbuf, uint8_t pat,
                             struct ble_mbuf_hdr *rxhdr);
 
 /* Link Layer interface */


[23/50] [abbrv] incubator-mynewt-core git commit: timtest: Fix pstack malloc for task 2 should use TASK2_STACK_SIZE

Posted by we...@apache.org.
timtest: Fix pstack malloc for task 2 should use TASK2_STACK_SIZE


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/3fa905bc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/3fa905bc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/3fa905bc

Branch: refs/heads/nrf_cputime
Commit: 3fa905bc40bfd77d708f8c4c682409d26423a743
Parents: 0d659e8
Author: Louie Lu <me...@louie.lu>
Authored: Thu Mar 16 11:51:20 2017 +0800
Committer: Louie Lu <me...@louie.lu>
Committed: Thu Mar 16 11:51:20 2017 +0800

----------------------------------------------------------------------
 apps/timtest/src/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/3fa905bc/apps/timtest/src/main.c
----------------------------------------------------------------------
diff --git a/apps/timtest/src/main.c b/apps/timtest/src/main.c
index ff6ace0..29ad716 100755
--- a/apps/timtest/src/main.c
+++ b/apps/timtest/src/main.c
@@ -169,13 +169,13 @@ init_tasks(void)
     res = hal_timer_get_resolution(TASK2_TIMER_NUM);
     assert(res == (1000000000 / TASK2_TIMER_FREQ));
 
-    pstack = malloc(sizeof(os_stack_t)*TASK1_STACK_SIZE);
+    pstack = malloc(sizeof(os_stack_t) * TASK1_STACK_SIZE);
     assert(pstack);
 
     os_task_init(&task1, "task1", task1_handler, NULL,
             TASK1_PRIO, OS_WAIT_FOREVER, pstack, TASK1_STACK_SIZE);
 
-    pstack = malloc(sizeof(os_stack_t)*TASK1_STACK_SIZE);
+    pstack = malloc(sizeof(os_stack_t) * TASK2_STACK_SIZE);
     assert(pstack);
 
     os_task_init(&task2, "task2", task2_handler, NULL,


[06/50] [abbrv] incubator-mynewt-core git commit: Use $OS to determine whether running on windows or not.

Posted by we...@apache.org.
Use $OS to determine whether running on windows or not.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/9cd69a34
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/9cd69a34
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/9cd69a34

Branch: refs/heads/nrf_cputime
Commit: 9cd69a34301772260c4db02e7afc3b0844247348
Parents: 567a360
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Sat Mar 4 20:42:45 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Mar 10 13:10:54 2017 -0800

----------------------------------------------------------------------
 hw/scripts/common.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/9cd69a34/hw/scripts/common.sh
----------------------------------------------------------------------
diff --git a/hw/scripts/common.sh b/hw/scripts/common.sh
index ee85a90..2563b29 100644
--- a/hw/scripts/common.sh
+++ b/hw/scripts/common.sh
@@ -34,9 +34,8 @@ common_file_to_load () {
 # Also check if $COMSPEC is set or not.
 #
 windows_detect() {
-    BUILD_OS=`uname`
     WINDOWS=0
-    if [ $BUILD_OS = "Windows_NT" ]; then
+    if [ $OS = "Windows_NT" ]; then
 	WINDOWS=1
     fi
     if [ $WINDOWS -eq 1 -a -z "$COMSPEC" ]; then


[08/50] [abbrv] incubator-mynewt-core git commit: SensorAPI TCS34725 Add AMS DN40 calculations

Posted by we...@apache.org.
SensorAPI TCS34725 Add AMS DN40 calculations

- Adding DN40 calculation and results to the sensor structure
- Instead of using the UNUSED_DATA constant which is -1 for various
  sensors, using bit fields to see if the data is valid/invalid.
- Adding conditional compilation for DN25 Vs DN40 based calculations
  (For reflective Vs incident light readings, interrupt pin should be
  shorted to the LED pin on the TCS34725 Adafruit breakout board)


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/70592981
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/70592981
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/70592981

Branch: refs/heads/nrf_cputime
Commit: 70592981db0c053a84cb2bed86b5a9325d1eaaee
Parents: 631db77
Author: Vipul Rahane <vi...@apache.org>
Authored: Fri Mar 10 17:45:41 2017 -0800
Committer: Vipul Rahane <vi...@apache.org>
Committed: Fri Mar 10 17:49:52 2017 -0800

----------------------------------------------------------------------
 hw/drivers/sensors/tcs34725/src/tcs34725.c      | 183 +++++++++++++++----
 hw/drivers/sensors/tcs34725/src/tcs34725_priv.h |  15 ++
 hw/sensor/include/sensor/color.h                |  41 +++--
 hw/sensor/src/sensor_shell.c                    |  43 +++--
 4 files changed, 221 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/70592981/hw/drivers/sensors/tcs34725/src/tcs34725.c
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/tcs34725/src/tcs34725.c b/hw/drivers/sensors/tcs34725/src/tcs34725.c
index cd0f2c2..7a4c07f 100644
--- a/hw/drivers/sensors/tcs34725/src/tcs34725.c
+++ b/hw/drivers/sensors/tcs34725/src/tcs34725.c
@@ -534,6 +534,11 @@ tcs34725_config(struct tcs34725 *tcs34725, struct tcs34725_cfg *cfg)
         goto err;
     }
 
+    rc = tcs34725_enable_interrupt(1);
+    if (rc) {
+        goto err;
+    }
+
     /* Overwrite the configuration data. */
     memcpy(&tcs34725->cfg, cfg, sizeof(*cfg));
 
@@ -638,19 +643,19 @@ err:
 
 /**
  *
- * Converts raw RGB values to color temp in deg K
+ * Converts raw RGB values to color temp in deg K and lux
  *
- * @param red value
- * @param green value
- * @param blue value
- * @return final CCT value using McCamy's formula
+ * @param ptr to sensor color data ptr
+ * @param ptr to sensor
  */
-static uint16_t
-tcs34725_calculate_color_temp(uint16_t r, uint16_t g, uint16_t b)
+static int
+tcs34725_calc_colortemp_lux(struct sensor_color_data *scd, struct tcs34725 *tcs34725)
 {
-    float n;
-    float cct;
+    int rc;
 
+    rc = 0;
+#if MYNEWT_VAL(USE_TCS34725_TAOS_DN25)
+    float n;
     /**
      * From the designer's notebook by TAOS:
      * Mapping sensor response  RGB values to CIE tristimulus values(XYZ)
@@ -679,12 +684,13 @@ tcs34725_calculate_color_temp(uint16_t r, uint16_t g, uint16_t b)
      * n = (xc - 0.3320F) / (0.1858F - yc);
      */
 
-     /*
-      * n can be calculated directly using the following formula for
-      * above considerations
-      */
-    n = ((0.23881)*r + (0.25499)*g + (-0.58291)*b) / ((0.11109)*r + (-0.85406)*g +
-         (0.52289)*b);
+    /*
+     * n can be calculated directly using the following formula for
+     * above considerations
+     */
+    n = ((0.23881)*scd->scd_r + (0.25499)*scd->scd_g + (-0.58291)*scd->scd_b) /
+         ((0.11109)*scd->scd_r + (-0.85406)*scd->scd_g + (0.52289)*scd->scd_b);
+
 
     /*
      * Calculate the final CCT
@@ -692,35 +698,134 @@ tcs34725_calculate_color_temp(uint16_t r, uint16_t g, uint16_t b)
      */
 
 #if MYNEWT_VAL(USE_MATH)
-    cct = (449.0F * powf(n, 3)) + (3525.0F * powf(n, 2)) + (6823.3F * n) + 5520.33F;
+    scd->scd_colortemp = (449.0F * powf(n, 3)) + (3525.0F * powf(n, 2)) + (6823.3F * n) + 5520.33F;
 #else
-    cct = (449.0F * n * n * n) + (3525.0F * n * n) + (6823.3F * n) + 5520.33F;
+    scd->scd_colortemp = (449.0F * n * n * n) + (3525.0F * n * n) + (6823.3F * n) + 5520.33F;
 #endif
 
-    /* Return the results in degrees Kelvin */
-    return (uint16_t)cct;
-}
+    scd->scd_lux = (-0.32466F * scd->scd_r) + (1.57837F * scd->scd_g) + (-0.73191F * scd->scd_b);
 
-/**
- *
- * Converts the raw RGB values to lux
- *
- * @param red value
- * @param green value
- * @param blue value
- * @return lux value
- */
-static uint16_t
-tcs34725_calculate_lux(uint16_t r, uint16_t g, uint16_t b)
-{
-    float lux;
+    scd->scd_r_is_valid = 1;
+    scd->scd_g_is_valid = 1;
+    scd->scd_b_is_valid = 1;
+    scd->scd_c_is_valid = 1;
+    scd->scd_colortemp_is_valid = 1;
+    scd->scd_lux_is_valid = 1;
 
-    lux = (-0.32466F * r) + (1.57837F * g) + (-0.73191F * b);
+    goto err;
+#else
+    uint8_t againx;
+    uint8_t atime;
+    uint16_t atime_ms;
+    uint16_t r_comp;
+    uint16_t g_comp;
+    uint16_t b_comp;
+    float cpl;
+    uint8_t agc_cur;
+
+    const struct tcs_agc agc_list[4] = {
+        { TCS34725_GAIN_60X, TCS34725_INTEGRATIONTIME_700MS,     0, 47566 },
+        { TCS34725_GAIN_16X, TCS34725_INTEGRATIONTIME_154MS,  3171, 63422 },
+        { TCS34725_GAIN_4X,  TCS34725_INTEGRATIONTIME_154MS, 15855, 63422 },
+        { TCS34725_GAIN_1X,  TCS34725_INTEGRATIONTIME_2_4MS,   248,     0 }
+    };
 
-    return (uint16_t)lux;
-}
+    agc_cur = 0;
+    while(1) {
+        if (agc_list[agc_cur].max_cnt && scd->scd_c > agc_list[agc_cur].max_cnt) {
+            agc_cur++;
+        } else if (agc_list[agc_cur].min_cnt &&
+                   scd->scd_c < agc_list[agc_cur].min_cnt) {
+            agc_cur--;
+            break;
+        } else {
+            break;
+        }
+
+        rc = tcs34725_set_gain(agc_list[agc_cur].ta_gain);
+        if (rc) {
+            goto err;
+        }
 
+        rc = tcs34725_set_integration_time(agc_list[agc_cur].ta_time);
+        if (rc) {
+            goto err;
+        }
 
+        /* Shock absorber */
+        os_time_delay((256 - (uint16_t)agc_list[agc_cur].ta_time) * 2.4 * 2 * OS_TICKS_PER_SEC);
+
+        rc = tcs34725_get_rawdata(&scd->scd_r, &scd->scd_g, &scd->scd_b, &scd->scd_c, tcs34725);
+        if (rc) {
+            goto err;
+        }
+        break;
+    }
+
+    atime = (uint16_t)agc_list[agc_cur].ta_time;
+
+    /* Formula from the datasheet */
+    atime_ms = ((256 - atime) * 2.4);
+
+    switch(agc_list[agc_cur].ta_time) {
+        case TCS34725_GAIN_1X:
+            againx = 1;
+            break;
+        case TCS34725_GAIN_4X:
+            againx = 4;
+            break;
+        case TCS34725_GAIN_16X:
+            againx = 16;
+            break;
+        case TCS34725_GAIN_60X:
+            againx = 60;
+            break;
+        default:
+            rc = SYS_EINVAL;
+            goto err;
+    }
+
+    scd->scd_ir = (scd->scd_r + scd->scd_g + scd->scd_b > scd->scd_c) ?
+                  (scd->scd_r + scd->scd_g + scd->scd_b - scd->scd_c) / 2 : 0;
+
+    r_comp = scd->scd_r - scd->scd_ir;
+    g_comp = scd->scd_g - scd->scd_ir;
+    b_comp = scd->scd_b - scd->scd_ir;
+
+    scd->scd_cratio = (float)scd->scd_ir / (float)scd->scd_c;
+
+    scd->scd_saturation = ((256 - atime) > 63) ? 65535 : 1024 * (256 - atime);
+
+    scd->scd_saturation75 = (atime_ms < 150) ? (scd->scd_saturation - scd->scd_saturation / 4) : scd->scd_saturation;
+
+    scd->scd_is_sat = (atime_ms < 150 && scd->scd_c > scd->scd_saturation75) ? 1 : 0;
+
+    cpl = (atime_ms * againx) / (TCS34725_GA * TCS34725_DF);
+
+    scd->scd_maxlux = 65535 / (cpl * 3);
+
+    scd->scd_lux = (TCS34725_R_COEF * (float)r_comp + TCS34725_G_COEF * (float)g_comp +
+           TCS34725_B_COEF * (float)b_comp) / cpl;
+
+    scd->scd_colortemp = TCS34725_CT_COEF * (float)b_comp / (float)r_comp + TCS34725_CT_OFFSET;
+
+    scd->scd_r_is_valid = 1;
+    scd->scd_g_is_valid = 1;
+    scd->scd_b_is_valid = 1;
+    scd->scd_c_is_valid = 1;
+    scd->scd_lux_is_valid = 1;
+    scd->scd_colortemp_is_valid = 1;
+    scd->scd_saturation_is_valid = 1;
+    scd->scd_saturation75_is_valid = 1;
+    scd->scd_is_sat_is_valid = 1;
+    scd->scd_cratio_is_valid = 1;
+    scd->scd_maxlux_is_valid = 1;
+    scd->scd_ir_is_valid = 1;
+#endif
+
+err:
+    return rc;
+}
 
 static int
 tcs34725_sensor_read(struct sensor *sensor, sensor_type_t type,
@@ -755,8 +860,10 @@ tcs34725_sensor_read(struct sensor *sensor, sensor_type_t type,
         scd.scd_g = g;
         scd.scd_b = b;
         scd.scd_c = c;
-        scd.scd_lux = tcs34725_calculate_lux(r, g, b);
-        scd.scd_colortemp = tcs34725_calculate_color_temp(r, g, b);
+        rc = tcs34725_calc_colortemp_lux(&scd, tcs34725);
+        if (rc) {
+            goto err;
+        }
 
         /* Call data function */
         rc = data_func(sensor, data_arg, &scd);

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/70592981/hw/drivers/sensors/tcs34725/src/tcs34725_priv.h
----------------------------------------------------------------------
diff --git a/hw/drivers/sensors/tcs34725/src/tcs34725_priv.h b/hw/drivers/sensors/tcs34725/src/tcs34725_priv.h
index 4c47929..5d5448c 100644
--- a/hw/drivers/sensors/tcs34725/src/tcs34725_priv.h
+++ b/hw/drivers/sensors/tcs34725/src/tcs34725_priv.h
@@ -101,10 +101,25 @@
 #define TCS34725_REG_BDATAL       0x1A
 #define TCS34725_REG_BDATAH       0x1B
 
+#define TCS34725_R_COEF         0.136F
+#define TCS34725_G_COEF         1.000F
+#define TCS34725_B_COEF        -0.444F
+#define TCS34725_GA               1.0F
+#define TCS34725_DF             310.0F
+#define TCS34725_CT_COEF       3810.0F
+#define TCS34725_CT_OFFSET     1391.0F
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+struct tcs_agc {
+    uint8_t ta_gain;
+    uint8_t ta_time;
+    uint16_t min_cnt;
+    uint16_t max_cnt;
+};
+
 /**
  * Writes a single byte to the specified register
  *

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/70592981/hw/sensor/include/sensor/color.h
----------------------------------------------------------------------
diff --git a/hw/sensor/include/sensor/color.h b/hw/sensor/include/sensor/color.h
index 6f219d7..46f3436 100644
--- a/hw/sensor/include/sensor/color.h
+++ b/hw/sensor/include/sensor/color.h
@@ -31,18 +31,37 @@ extern "C" {
 /* Data representing a singular read from a color sensor
  */
 struct sensor_color_data {
-    uint16_t scd_r;         /* Red data   */
-    uint16_t scd_g;         /* Green data */
-    uint16_t scd_b;         /* Blue data  */
-    uint16_t scd_c;         /* Clear data */
-    uint16_t scd_lux;       /* Lux data   */
-    uint16_t scd_colortemp; /* Color temp */
-} __attribute__((packed));
+    uint16_t scd_r;          /* Red data   */
+    uint16_t scd_g;          /* Green data */
+    uint16_t scd_b;          /* Blue data  */
+    uint16_t scd_c;          /* Clear data */
+    uint16_t scd_lux;        /* Lux data   */
+    uint16_t scd_colortemp;  /* Color temp */
+    /*
+     * The following is only used in AMS DN40
+     * calculation for lux
+     */
+    uint16_t scd_saturation;   /* Saturation        */
+    uint16_t scd_saturation75; /* Saturation75      */
+    uint8_t scd_is_sat;        /* Sensor saturrated */
+    float scd_cratio;          /* C Ratio           */
+    uint16_t scd_maxlux;       /* Max Lux value     */
+    uint16_t scd_ir;           /* Infrared value    */
 
-/**
- * Color Sensor data is unused for this field.
- */
-#define SENSOR_COLOR_DATA_UNUSED (-1)
+    /* Validity */
+    uint16_t scd_r_is_valid:1;
+    uint16_t scd_g_is_valid:1;
+    uint16_t scd_b_is_valid:1;
+    uint16_t scd_c_is_valid:1;
+    uint16_t scd_lux_is_valid:1;
+    uint16_t scd_colortemp_is_valid:1;
+    uint16_t scd_saturation_is_valid:1;
+    uint16_t scd_saturation75_is_valid:1;
+    uint16_t scd_is_sat_is_valid:1;
+    uint16_t scd_cratio_is_valid:1;
+    uint16_t scd_maxlux_is_valid:1;
+    uint16_t scd_ir_is_valid:1;
+} __attribute__((packed));
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/70592981/hw/sensor/src/sensor_shell.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_shell.c b/hw/sensor/src/sensor_shell.c
index 3d86beb..fbddd96 100644
--- a/hw/sensor/src/sensor_shell.c
+++ b/hw/sensor/src/sensor_shell.c
@@ -200,25 +200,44 @@ sensor_shell_read_listener(struct sensor *sensor, void *arg, void *data)
 
     if (ctx->type == SENSOR_TYPE_COLOR) {
         scd = (struct sensor_color_data *) data;
-        if (scd->scd_r != SENSOR_LIGHT_DATA_UNUSED) {
-            console_printf("red = %u, ", scd->scd_r);
+        if (scd->scd_r_is_valid) {
+            console_printf("r = %u, ", scd->scd_r);
         }
-        if (scd->scd_g != SENSOR_LIGHT_DATA_UNUSED) {
-            console_printf("green = %u, ", scd->scd_g);
+        if (scd->scd_g_is_valid) {
+            console_printf("g = %u, ", scd->scd_g);
         }
-        if (scd->scd_b != SENSOR_LIGHT_DATA_UNUSED) {
-            console_printf("blue = %u, ", scd->scd_b);
+        if (scd->scd_b_is_valid) {
+            console_printf("b = %u, ", scd->scd_b);
         }
-        if (scd->scd_c != SENSOR_LIGHT_DATA_UNUSED) {
-            console_printf("clear = %u, ", scd->scd_c);
+        if (scd->scd_c_is_valid) {
+            console_printf("c = %u, ", scd->scd_c);
         }
-        if (scd->scd_lux != SENSOR_LIGHT_DATA_UNUSED) {
+        if (scd->scd_lux_is_valid) {
             console_printf("lux = %u, ", scd->scd_lux);
         }
-        if (scd->scd_colortemp != SENSOR_LIGHT_DATA_UNUSED) {
-            console_printf("color temperature = %u, ", scd->scd_colortemp);
+        if (scd->scd_colortemp_is_valid) {
+            console_printf("cct = %uK, ", scd->scd_colortemp);
         }
-        console_printf("\n");
+        if (scd->scd_ir_is_valid) {
+            console_printf("ir = %u, \n", scd->scd_ir);
+        }
+        if (scd->scd_saturation_is_valid) {
+            console_printf("sat = %u, ", scd->scd_saturation);
+        }
+        if (scd->scd_saturation_is_valid) {
+            console_printf("sat75 = %u, ", scd->scd_saturation75);
+        }
+        if (scd->scd_is_sat_is_valid) {
+            console_printf(scd->scd_is_sat ? "is saturated, " : "not saturated, ");
+        }
+        if (scd->scd_cratio_is_valid) {
+            console_printf("cRatio = %s, ", sensor_ftostr(scd->scd_cratio, tmpstr, 13));
+        }
+        if (scd->scd_maxlux_is_valid) {
+            console_printf("max lux = %u, ", scd->scd_maxlux);
+        }
+
+        console_printf("\n\n");
     }
 
     return (0);


[28/50] [abbrv] incubator-mynewt-core git commit: This closes #210.

Posted by we...@apache.org.
This closes #210.

Merge remote-tracking branch 'spoonofpower/testbench_logging' into develop

* spoonofpower/testbench_logging:
  Log json test results and assume msg is null terminated


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/35323c20
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/35323c20
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/35323c20

Branch: refs/heads/nrf_cputime
Commit: 35323c20229e35ea0ecb9db19ec88355e0fdf89a
Parents: d7a9e96 fcb79cd
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Mar 17 14:38:04 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Mar 17 14:38:04 2017 -0700

----------------------------------------------------------------------
 apps/testbench/src/testbench.c            | 25 ++++++++++++++++---------
 apps/testbench/src/testbench.h            |  4 ++--
 test/testutil/include/testutil/testutil.h |  2 +-
 test/testutil/src/case.c                  |  9 +++------
 4 files changed, 22 insertions(+), 18 deletions(-)
----------------------------------------------------------------------



[02/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-666; walk of observer list was ending too soon.

Posted by we...@apache.org.
MYNEWT-666; walk of observer list was ending too soon.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/2b3d6ccf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/2b3d6ccf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/2b3d6ccf

Branch: refs/heads/nrf_cputime
Commit: 2b3d6ccf79be225fbb652e15b93e7044047cf1f8
Parents: e67144f
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Fri Mar 10 12:25:29 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Mar 10 12:25:29 2017 -0800

----------------------------------------------------------------------
 net/oic/src/messaging/coap/observe.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/2b3d6ccf/net/oic/src/messaging/coap/observe.c
----------------------------------------------------------------------
diff --git a/net/oic/src/messaging/coap/observe.c b/net/oic/src/messaging/coap/observe.c
index ed88682..3d45e03 100644
--- a/net/oic/src/messaging/coap/observe.c
+++ b/net/oic/src/messaging/coap/observe.c
@@ -231,11 +231,13 @@ coap_notify_observers(oc_resource_t *resource,
 
     coap_observer_t *obs = NULL;
     /* iterate over observers */
-    for (obs = SLIST_FIRST(&oc_observers);
-         obs && ((resource && obs->resource == resource) ||
-           (endpoint &&
-             memcmp(&obs->endpoint, endpoint, sizeof(oc_endpoint_t)) == 0));
-         obs = SLIST_NEXT(obs, next)) {
+    for (obs = SLIST_FIRST(&oc_observers); obs; obs = SLIST_NEXT(obs, next)) {
+        /* skip if neither resource nor endpoint match */
+        if (resource != obs->resource &&
+            0 != memcmp(&obs->endpoint, endpoint, sizeof(oc_endpoint_t))) {
+            continue;
+        }
+
         num_observers = obs->resource->num_observers;
 #if MYNEWT_VAL(OC_SEPARATE_RESPONSES)
         if (response.separate_response != NULL &&


[24/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-676 Reboot counter value inconsistent

Posted by we...@apache.org.
MYNEWT-676 Reboot counter value inconsistent

The value that gets logged to the reboot log is one greater than the
actual reboot counter (the value retrieved via "newtmgr config
reboot/reboot_cnt").


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/d1f00e95
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/d1f00e95
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/d1f00e95

Branch: refs/heads/nrf_cputime
Commit: d1f00e95a6d4187d4227782fd97b055473137a0e
Parents: 0d659e8
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Mar 17 12:04:40 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Fri Mar 17 12:20:11 2017 -0700

----------------------------------------------------------------------
 apps/sensors_test/src/main.c           |   4 +-
 apps/slinky/src/main.c                 |   4 +-
 apps/slinky_oic/src/main.c             |   4 +-
 apps/splitty/src/main.c                |   4 +-
 apps/testbench/src/testbench.c         |   4 +-
 apps/testbench/src/testbench.h         |   2 +-
 sys/reboot/include/reboot/log_reboot.h |   1 +
 sys/reboot/src/log_reboot.c            | 119 +++++++++++++---------------
 8 files changed, 67 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d1f00e95/apps/sensors_test/src/main.c
----------------------------------------------------------------------
diff --git a/apps/sensors_test/src/main.c b/apps/sensors_test/src/main.c
index 45d25a2..8ecbccd 100755
--- a/apps/sensors_test/src/main.c
+++ b/apps/sensors_test/src/main.c
@@ -46,7 +46,7 @@
 #include <assert.h>
 #include <string.h>
 #include <flash_test/flash_test.h>
-#include <reboot/log_reboot.h>
+#include <reboot/reboot_start.h>
 #include <os/os_time.h>
 #include <id/id.h>
 
@@ -425,7 +425,7 @@ main(int argc, char **argv)
 
     conf_load();
 
-    log_reboot(hal_reset_cause());
+    reboot_start(hal_reset_cause());
 
     init_tasks();
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d1f00e95/apps/slinky/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky/src/main.c b/apps/slinky/src/main.c
index 7ab13d6..2e74801 100755
--- a/apps/slinky/src/main.c
+++ b/apps/slinky/src/main.c
@@ -41,7 +41,7 @@
 #include <assert.h>
 #include <string.h>
 #include <flash_test/flash_test.h>
-#include <reboot/log_reboot.h>
+#include <reboot/reboot_start.h>
 #include <os/os_time.h>
 #include <id/id.h>
 
@@ -269,7 +269,7 @@ main(int argc, char **argv)
 
     conf_load();
 
-    log_reboot(hal_reset_cause());
+    reboot_start(hal_reset_cause());
 
     init_tasks();
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d1f00e95/apps/slinky_oic/src/main.c
----------------------------------------------------------------------
diff --git a/apps/slinky_oic/src/main.c b/apps/slinky_oic/src/main.c
index 2f8df31..115fa33 100755
--- a/apps/slinky_oic/src/main.c
+++ b/apps/slinky_oic/src/main.c
@@ -37,7 +37,7 @@
 #include <oic/oc_api.h>
 #include <assert.h>
 #include <string.h>
-#include <reboot/log_reboot.h>
+#include <reboot/reboot_start.h>
 #include <os/os_time.h>
 
 #ifdef ARCH_sim
@@ -283,7 +283,7 @@ main(int argc, char **argv)
 
     conf_load();
 
-    log_reboot(hal_reset_cause());
+    reboot_start(hal_reset_cause());
 
 #if MYNEWT_VAL(SPLIT_LOADER)
     {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d1f00e95/apps/splitty/src/main.c
----------------------------------------------------------------------
diff --git a/apps/splitty/src/main.c b/apps/splitty/src/main.c
index 267b4bc..6362187 100755
--- a/apps/splitty/src/main.c
+++ b/apps/splitty/src/main.c
@@ -34,7 +34,7 @@
 #include <imgmgr/imgmgr.h>
 #include <assert.h>
 #include <string.h>
-#include <reboot/log_reboot.h>
+#include <reboot/reboot_start.h>
 #include <os/os_time.h>
 #include <id/id.h>
 
@@ -196,7 +196,7 @@ main(int argc, char **argv)
 
     conf_load();
 
-    log_reboot(hal_reset_cause());
+    reboot_start(hal_reset_cause());
 
     init_tasks();
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d1f00e95/apps/testbench/src/testbench.c
----------------------------------------------------------------------
diff --git a/apps/testbench/src/testbench.c b/apps/testbench/src/testbench.c
index b8fe034..5345d6f 100644
--- a/apps/testbench/src/testbench.c
+++ b/apps/testbench/src/testbench.c
@@ -43,7 +43,7 @@
 #include <assert.h>
 #include <string.h>
 #include <json/json.h>
-#include <reboot/log_reboot.h>
+#include <reboot/reboot_start.h>
 #include <os/os_time.h>
 #include <id/id.h>
 #include <os/os_eventq.h>
@@ -353,7 +353,7 @@ main(int argc, char **argv)
     cbmem_init(&cbmem, cbmem_buf, MAX_CBMEM_BUF);
     log_register("testlog", &testlog, &log_cbmem_handler, &cbmem, LOG_SYSLEVEL);
 
-    log_reboot(hal_reset_cause());
+    reboot_start(hal_reset_cause());
 
     conf_load();
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d1f00e95/apps/testbench/src/testbench.h
----------------------------------------------------------------------
diff --git a/apps/testbench/src/testbench.h b/apps/testbench/src/testbench.h
index a94ee1c..8b39310 100644
--- a/apps/testbench/src/testbench.h
+++ b/apps/testbench/src/testbench.h
@@ -46,7 +46,7 @@
 #include <assert.h>
 #include <string.h>
 #include <json/json.h>
-#include <reboot/log_reboot.h>
+#include <reboot/reboot_start.h>
 #include <os/os_time.h>
 #include <id/id.h>
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d1f00e95/sys/reboot/include/reboot/log_reboot.h
----------------------------------------------------------------------
diff --git a/sys/reboot/include/reboot/log_reboot.h b/sys/reboot/include/reboot/log_reboot.h
index e3ff093..fbc1f24 100644
--- a/sys/reboot/include/reboot/log_reboot.h
+++ b/sys/reboot/include/reboot/log_reboot.h
@@ -35,6 +35,7 @@ extern "C" {
 
 int reboot_init_handler(int log_store_type, uint8_t entries);
 int log_reboot(enum hal_reset_reason);
+void reboot_start(enum hal_reset_reason reason);
 
 #ifdef __cplusplus
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/d1f00e95/sys/reboot/src/log_reboot.c
----------------------------------------------------------------------
diff --git a/sys/reboot/src/log_reboot.c b/sys/reboot/src/log_reboot.c
index 9bfe04c..b795e1c 100644
--- a/sys/reboot/src/log_reboot.c
+++ b/sys/reboot/src/log_reboot.c
@@ -43,17 +43,17 @@ static uint16_t reboot_cnt;
 static uint16_t soft_reboot;
 static char reboot_cnt_str[12];
 static char soft_reboot_str[12];
-static char *reboot_cnt_get(int argc, char **argv, char *buf, int max_len);
-static int reboot_cnt_set(int argc, char **argv, char *val);
-static int reboot_cnt_export(void (*export_func)(char *name, char *val),
+static char *reboot_conf_get(int argc, char **argv, char *buf, int max_len);
+static int reboot_conf_set(int argc, char **argv, char *val);
+static int reboot_conf_export(void (*export_func)(char *name, char *val),
                              enum conf_export_tgt tgt);
 
 struct conf_handler reboot_conf_handler = {
     .ch_name = "reboot",
-    .ch_get = reboot_cnt_get,
-    .ch_set = reboot_cnt_set,
+    .ch_get = reboot_conf_get,
+    .ch_set = reboot_conf_set,
     .ch_commit = NULL,
-    .ch_export = reboot_cnt_export
+    .ch_export = reboot_conf_export
 };
 
 #if MYNEWT_VAL(REBOOT_LOG_FCB)
@@ -127,6 +127,19 @@ reboot_init_handler(int log_store_type, uint8_t entries)
     return 0;
 }
 
+static int
+reboot_cnt_inc(void)
+{
+    char str[12];
+    int rc;
+
+    reboot_cnt++;
+    rc = conf_save_one("reboot/reboot_cnt",
+                       conf_str_from_value(CONF_INT16, &reboot_cnt,
+                                           str, sizeof(str)));
+    return rc;
+}
+
 /**
  * Logs reboot with the specified reason
  * @param reason for reboot
@@ -135,105 +148,83 @@ reboot_init_handler(int log_store_type, uint8_t entries)
 int
 log_reboot(enum hal_reset_reason reason)
 {
-    int rc;
-    char str[12] = {0};
     struct image_version ver;
-    int16_t reboot_tmp_cnt;
 
-    rc = 0;
 #if MYNEWT_VAL(REBOOT_LOG_FCB)
     {
         const struct flash_area *ptr;
         if (flash_area_open(MYNEWT_VAL(REBOOT_LOG_FLASH_AREA), &ptr)) {
-            goto err;
+            return 0;
         }
     }
 #endif
 
-    reboot_tmp_cnt = reboot_cnt;
-
     if (reason == HAL_RESET_REQUESTED) {
-        /*
-         * Save soft_reboot as 1 if user is requesting restart.
-         */
-        reboot_tmp_cnt = 1;
-        conf_save_one("reboot/soft_reboot",
-                      conf_str_from_value(CONF_INT16, &reboot_tmp_cnt,
-                                          str, sizeof(str)));
-        reboot_tmp_cnt = reboot_cnt + 1;
+        conf_save_one("reboot/soft_reboot", "1");
     } else {
         conf_save_one("reboot/soft_reboot", "0");
-        if (soft_reboot && reason == HAL_RESET_SOFT) {
-            /* No need to log as it's not a hard reboot */
-            goto err;
-        } else {
-            reboot_cnt++;
-            reboot_tmp_cnt = reboot_cnt;
-        }
     }
 
-    /*
-     * Only care for this return code as it will tell whether the config is
-     * full, the caller of the function might not care about the return code
-     * Saving the reboot cnt
-     */
-    rc = conf_save_one("reboot/reboot_cnt",
-                       conf_str_from_value(CONF_INT16, &reboot_tmp_cnt,
-                                           str, sizeof(str)));
+    if (!soft_reboot || reason != HAL_RESET_SOFT) {
+        imgr_my_version(&ver);
+
+        /* Log a reboot */
+        LOG_CRITICAL(&reboot_log, LOG_MODULE_REBOOT, "rsn:%s, cnt:%u,"
+                     " img:%u.%u.%u.%u", REBOOT_REASON_STR(reason),
+                     reboot_cnt, ver.iv_major, ver.iv_minor,
+                     ver.iv_revision, (unsigned int)ver.iv_build_num);
+    }
 
-    imgr_my_version(&ver);
+    return 0;
+}
 
-    /* Log a reboot */
-    LOG_CRITICAL(&reboot_log, LOG_MODULE_REBOOT, "rsn:%s, cnt:%u,"
-                 " img:%u.%u.%u.%u", REBOOT_REASON_STR(reason), reboot_tmp_cnt,
-                 ver.iv_major, ver.iv_minor, ver.iv_revision,
-                 (unsigned int)ver.iv_build_num);
-err:
-    return (rc);
+/**
+ * Increments the reboot counter and writes an entry to the reboot log, if
+ * necessary.  This function should be called from main() after config
+ * settings have been loaded via conf_load().
+ *
+ * @param reason                The cause of the reboot.
+ */
+void
+reboot_start(enum hal_reset_reason reason)
+{
+    reboot_cnt_inc();
+    log_reboot(reason);
 }
 
 static char *
-reboot_cnt_get(int argc, char **argv, char *buf, int max_len)
+reboot_conf_get(int argc, char **argv, char *buf, int max_len)
 {
     if (argc == 1) {
         if (!strcmp(argv[0], "reboot_cnt")) {
-            return reboot_cnt_str;
+            return conf_str_from_value(CONF_INT16, &reboot_cnt,
+                                       reboot_cnt_str, sizeof reboot_cnt_str);
         } else if (!strcmp(argv[0], "soft_reboot")) {
-            return soft_reboot_str;
+            return conf_str_from_value(CONF_INT16, &soft_reboot,
+                                       soft_reboot_str,
+                                       sizeof soft_reboot_str);
         }
     }
     return NULL;
 }
 
 static int
-reboot_cnt_set(int argc, char **argv, char *val)
+reboot_conf_set(int argc, char **argv, char *val)
 {
-    int rc;
-
     if (argc == 1) {
         if (!strcmp(argv[0], "reboot_cnt")) {
-            rc = CONF_VALUE_SET(val, CONF_STRING, reboot_cnt_str);
-            if (rc) {
-                goto err;
-            }
-
-            return CONF_VALUE_SET(reboot_cnt_str, CONF_INT16, reboot_cnt);
+            return CONF_VALUE_SET(val, CONF_INT16, reboot_cnt);
         } else if (!strcmp(argv[0], "soft_reboot")) {
-            rc = CONF_VALUE_SET(val, CONF_STRING, soft_reboot_str);
-            if (rc) {
-                goto err;
-            }
-
-            return CONF_VALUE_SET(soft_reboot_str, CONF_INT16, soft_reboot);
+            return CONF_VALUE_SET(val, CONF_INT16, soft_reboot);
         }
     }
 
-err:
     return OS_ENOENT;
 }
 
 static int
-reboot_cnt_export(void (*func)(char *name, char *val), enum conf_export_tgt tgt)
+reboot_conf_export(void (*func)(char *name, char *val),
+                   enum conf_export_tgt tgt)
 {
     if (tgt == CONF_EXPORT_SHOW) {
         func("reboot/reboot_cnt", reboot_cnt_str);


[03/50] [abbrv] incubator-mynewt-core git commit: Fix ctrl-c handling on Windows by launching separate cmd instances

Posted by we...@apache.org.
Fix ctrl-c handling on Windows by launching separate cmd instances


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/56444edf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/56444edf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/56444edf

Branch: refs/heads/nrf_cputime
Commit: 56444edfae339e40330686aeb3ca9d8a641eea7f
Parents: 2b3d6cc
Author: Simon Ratner <si...@probablyprime.net>
Authored: Sat Mar 4 11:41:30 2017 -0800
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Fri Mar 10 13:10:05 2017 -0800

----------------------------------------------------------------------
 hw/scripts/jlink.sh   | 63 ++++++++++++++++++++++++++++------------------
 hw/scripts/openocd.sh | 32 ++++++++++++++++-------
 2 files changed, 61 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/56444edf/hw/scripts/jlink.sh
----------------------------------------------------------------------
diff --git a/hw/scripts/jlink.sh b/hw/scripts/jlink.sh
index e6a4dfe..2f3fbe8 100644
--- a/hw/scripts/jlink.sh
+++ b/hw/scripts/jlink.sh
@@ -105,37 +105,50 @@ jlink_load () {
 #
 jlink_debug() {
     if [ -z "$NO_GDB" ]; then
-	GDB_CMD_FILE=.gdb_cmds
+        GDB_CMD_FILE=.gdb_cmds
 
-	if [ -z $FILE_NAME ]; then
+        if [ -z $FILE_NAME ]; then
             echo "Missing filename"
             exit 1
-	fi
-	if [ ! -f "$FILE_NAME" ]; then
+        fi
+        if [ ! -f "$FILE_NAME" ]; then
             echo "Cannot find file" $FILE_NAME
             exit 1
-	fi
-
-	echo "Debugging" $FILE_NAME
-
-	# Monitor mode. Background process gets it's own process group.
-	set -m
-	$JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun > /dev/null &
-	set +m
-
-	echo "target remote localhost:3333" > $GDB_CMD_FILE
-	# Whether target should be reset or not
-	if [ ! -z "$RESET" ]; then
-	    echo "mon reset" >> $GDB_CMD_FILE
-	    echo "si" >> $GDB_CMD_FILE
-	fi
-	echo "$EXTRA_GDB_CMDS" >> $GDB_CMD_FILE
-
-	arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
-
-	rm $GDB_CMD_FILE
+        fi
+
+        echo "Debugging" $FILE_NAME
+
+        if [ -x "$COMSPEC" ]; then
+            #
+            # Launch jlink server in a separate command interpreter, to make
+            # sure it doesn't get killed by Ctrl-C signal from bash.
+            #
+            $COMSPEC /C "start $COMSPEC /C $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun"
+        else
+            #
+            # Block Ctrl-C from getting passed to jlink server.
+            #
+            set -m
+            $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun > /dev/null &
+            set +m
+        fi
+
+        echo "target remote localhost:3333" > $GDB_CMD_FILE
+        # Whether target should be reset or not
+        if [ ! -z "$RESET" ]; then
+            echo "mon reset" >> $GDB_CMD_FILE
+            echo "si" >> $GDB_CMD_FILE
+        fi
+        echo "$EXTRA_GDB_CMDS" >> $GDB_CMD_FILE
+
+        if [ -x "$COMSPEC" ]; then
+            $COMSPEC /C "start $COMSPEC /C arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME"
+        else
+            arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
+            rm $GDB_CMD_FILE
+        fi
     else
-	$JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun
+        $JLINK_GDB_SERVER -device $JLINK_DEV -speed 4000 -if SWD -port 3333 -singlerun
     fi
     return 0
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/56444edf/hw/scripts/openocd.sh
----------------------------------------------------------------------
diff --git a/hw/scripts/openocd.sh b/hw/scripts/openocd.sh
index 7c6c012..e838bcd 100644
--- a/hw/scripts/openocd.sh
+++ b/hw/scripts/openocd.sh
@@ -76,12 +76,20 @@ openocd_debug () {
             exit 1
         fi
 
-        #
-        # Block Ctrl-C from getting passed to openocd.
-        #
-        set -m
-        openocd $CFG -f $OCD_CMD_FILE -c init -c halt &
-        set +m
+        if [ -x "$COMSPEC" ]; then
+            #
+            # Launch openocd in a separate command interpreter, to make sure
+            # it doesn't get killed by Ctrl-C signal from bash.
+            #
+            $COMSPEC /C "start $COMSPEC /C openocd $CFG -f $OCD_CMD_FILE -c init -c halt"
+        else
+            #
+            # Block Ctrl-C from getting passed to openocd.
+            #
+            set -m
+            openocd $CFG -f $OCD_CMD_FILE -c init -c halt &
+            set +m
+        fi
 
         GDB_CMD_FILE=.gdb_cmds
 
@@ -89,15 +97,21 @@ openocd_debug () {
         if [ ! -z "$RESET" ]; then
             echo "mon reset halt" >> $GDB_CMD_FILE
         fi
-        arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
-        rm $GDB_CMD_FILE
+        if [ -x "$COMSPEC" ]; then
+            $COMSPEC /C "start $COMSPEC /C arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME"
+        else
+            arm-none-eabi-gdb -x $GDB_CMD_FILE $FILE_NAME
+            rm $GDB_CMD_FILE
+        fi
     else
         # No GDB, wait for openocd to exit
         openocd $CFG -f $OCD_CMD_FILE -c init -c halt
         return $?
     fi
 
-    rm $OCD_CMD_FILE
+    if [ ! -x "$COMSPEC" ]; then
+        rm $OCD_CMD_FILE
+    fi
     return 0
 }
 


[10/50] [abbrv] incubator-mynewt-core git commit: This closes #204

Posted by we...@apache.org.
This closes #204

>From st datasheet page 24:

    The devices embed a nested vectored interrupt controller
    able to manage 16 priority levels, and handle up to 91
    maskable interrupt channels plus the 16 interrupt lines
    of the Cortex�-M4 with FPU core.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/b729f76a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/b729f76a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/b729f76a

Branch: refs/heads/nrf_cputime
Commit: b729f76a9482385a9377f0504f1ead0d9f55b243
Parents: 331f6c5 37d85d8
Author: Sterling Hughes <st...@runtime.io>
Authored: Sat Mar 11 08:24:40 2017 -0800
Committer: Sterling Hughes <st...@runtime.io>
Committed: Sat Mar 11 08:24:40 2017 -0800

----------------------------------------------------------------------
 apps/boot/src/boot.c                            |     2 +-
 compiler/arm-none-eabi-m7/compiler.yml          |     2 +-
 diff.txt                                        |   330 +
 hw/bsp/nina-b1/boot-nrf52xxaa.ld                |    25 +
 hw/bsp/nina-b1/bsp.yml                          |    62 +
 hw/bsp/nina-b1/include/bsp/boards.h             |    19 +
 hw/bsp/nina-b1/include/bsp/bsp.h                |    65 +
 hw/bsp/nina-b1/include/bsp/cmsis_nvic.h         |    29 +
 hw/bsp/nina-b1/nrf52dk_debug.sh                 |    46 +
 hw/bsp/nina-b1/nrf52dk_download.sh              |    40 +
 hw/bsp/nina-b1/nrf52dk_no_boot.ld               |   191 +
 hw/bsp/nina-b1/nrf52xxaa.ld                     |    25 +
 hw/bsp/nina-b1/pkg.yml                          |    92 +
 hw/bsp/nina-b1/split-nrf52dk.ld                 |   208 +
 .../src/arch/cortex_m4/gcc_startup_nrf52.s      |   299 +
 .../arch/cortex_m4/gcc_startup_nrf52_split.s    |   163 +
 hw/bsp/nina-b1/src/hal_bsp.c                    |   217 +
 hw/bsp/nina-b1/src/sbrk.c                       |    59 +
 hw/bsp/nina-b1/syscfg.yml                       |   111 +
 hw/bsp/sensorhub/boot-sensorhub.ld              |    31 +
 hw/bsp/sensorhub/bsp.yml                        |    63 +
 hw/bsp/sensorhub/f407.cfg                       |    82 +
 hw/bsp/sensorhub/include/bsp/bsp.h              |    72 +
 hw/bsp/sensorhub/include/bsp/cmsis_nvic.h       |    29 +
 .../sensorhub/include/bsp/stm32f4xx_hal_conf.h  |   431 +
 hw/bsp/sensorhub/pkg.yml                        |    40 +
 hw/bsp/sensorhub/sensorhub.cfg                  |    22 +
 hw/bsp/sensorhub/sensorhub.ld                   |    31 +
 hw/bsp/sensorhub/sensorhub_debug.cmd            |     3 +
 hw/bsp/sensorhub/sensorhub_debug.sh             |    39 +
 hw/bsp/sensorhub/sensorhub_download.cmd         |     3 +
 hw/bsp/sensorhub/sensorhub_download.sh          |    42 +
 .../src/arch/cortex_m4/startup_STM32F427xx.s    |   369 +
 hw/bsp/sensorhub/src/hal_bsp.c                  |   114 +
 hw/bsp/sensorhub/src/sbrk.c                     |    50 +
 hw/bsp/sensorhub/src/system_stm32f4xx.c         |   275 +
 hw/bsp/sensorhub/syscfg.yml                     |    32 +
 .../boot-stm32f429discovery.ld                  |    29 +
 hw/bsp/stm32f429discovery/bsp.yml               |    64 +
 hw/bsp/stm32f429discovery/f429.cfg              |    82 +
 hw/bsp/stm32f429discovery/f429discovery.cfg     |    22 +
 hw/bsp/stm32f429discovery/include/bsp/bsp.h     |    57 +
 .../stm32f429discovery/include/bsp/cmsis_nvic.h |    29 +
 .../include/bsp/stm32f4xx_hal_conf.h            |   432 +
 hw/bsp/stm32f429discovery/pkg.yml               |    40 +
 .../src/arch/cortex_m4/startup_STM32F429x.s     |   561 +
 hw/bsp/stm32f429discovery/src/hal_bsp.c         |   127 +
 hw/bsp/stm32f429discovery/src/sbrk.c            |    50 +
 .../stm32f429discovery/src/system_stm32f4xx.c   |   275 +
 hw/bsp/stm32f429discovery/stm32f429discovery.ld |    31 +
 .../stm32f429discovery_debug.cmd                |    22 +
 .../stm32f429discovery_debug.sh                 |    37 +
 .../stm32f429discovery_download.cmd             |    22 +
 .../stm32f429discovery_download.sh              |    41 +
 hw/bsp/stm32f429discovery/syscfg.yml            |    35 +
 hw/bsp/stm32f767-nucleo/_f407.cfg               |    82 +
 .../stm32f767-nucleo/boot-stm32f767-nucleo.ld   |    30 +
 hw/bsp/stm32f767-nucleo/bsp.yml                 |    61 +
 hw/bsp/stm32f767-nucleo/include/bsp/bsp.h       |    61 +
 .../stm32f767-nucleo/include/bsp/cmsis_nvic.h   |    29 +
 .../include/bsp/stm32f7xx_hal_conf.h            |   446 +
 hw/bsp/stm32f767-nucleo/nucleo767.cfg           |    22 +
 hw/bsp/stm32f767-nucleo/nucleo767_debug.sh      |    37 +
 hw/bsp/stm32f767-nucleo/nucleo767_download.sh   |    41 +
 hw/bsp/stm32f767-nucleo/pkg.yml                 |    40 +
 .../src/arch/cortex_m7/startup_stm32f767xx.s    |   652 +
 hw/bsp/stm32f767-nucleo/src/hal_bsp.c           |   133 +
 hw/bsp/stm32f767-nucleo/src/sbrk.c              |    50 +
 hw/bsp/stm32f767-nucleo/src/system_stm32f7xx.c  |   277 +
 hw/bsp/stm32f767-nucleo/stm32f767-nucleo.ld     |    32 +
 hw/bsp/stm32f767-nucleo/syscfg.yml              |    38 +
 hw/drivers/sensors/tcs34725/src/tcs34725.c      |   183 +-
 hw/drivers/sensors/tcs34725/src/tcs34725_priv.h |    15 +
 hw/mcu/stm/stm32f4xx/src/hal_gpio.c             |     2 +-
 hw/mcu/stm/stm32f4xx/stm32f427.ld               |   203 +
 hw/mcu/stm/stm32f4xx/stm32f429.ld               |   210 +
 hw/mcu/stm/stm32f7xx/include/mcu/cortex_m7.h    |    35 +
 hw/mcu/stm/stm32f7xx/include/mcu/mcu.h          |    48 +
 hw/mcu/stm/stm32f7xx/include/mcu/stm32f7_bsp.h  |    55 +
 .../include/mcu/stm32f7xx_mynewt_hal.h          |    74 +
 hw/mcu/stm/stm32f7xx/pkg.yml                    |    40 +
 .../Device/ST/STM32F7xx/Include/stm32f722xx.h   | 15165 ++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f723xx.h   | 15244 ++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f732xx.h   | 15390 ++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f733xx.h   | 15469 ++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f745xx.h   | 17219 +++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f746xx.h   | 17569 +++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f756xx.h   | 17856 +++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f765xx.h   | 17938 ++++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f767xx.h   | 18599 ++++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f769xx.h   | 21769 ++++++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f777xx.h   | 18886 ++++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f779xx.h   | 22056 +++++++++++++++++
 .../Device/ST/STM32F7xx/Include/stm32f7xx.h     |   230 +
 .../ST/STM32F7xx/Include/system_stm32f7xx.h     |   125 +
 .../Device/ST/STM32F7xx/Release_Notes.html      |   191 +
 .../Source/Templates/arm/startup_stm32f722xx.s  |   463 +
 .../Source/Templates/arm/startup_stm32f723xx.s  |   463 +
 .../Source/Templates/arm/startup_stm32f732xx.s  |   465 +
 .../Source/Templates/arm/startup_stm32f733xx.s  |   465 +
 .../Source/Templates/arm/startup_stm32f745xx.s  |   481 +
 .../Source/Templates/arm/startup_stm32f746xx.s  |   485 +
 .../Source/Templates/arm/startup_stm32f756xx.s  |   487 +
 .../Source/Templates/arm/startup_stm32f765xx.s  |   513 +
 .../Source/Templates/arm/startup_stm32f767xx.s  |   519 +
 .../Source/Templates/arm/startup_stm32f769xx.s  |   521 +
 .../Source/Templates/arm/startup_stm32f777xx.s  |   521 +
 .../Source/Templates/arm/startup_stm32f779xx.s  |   523 +
 .../Source/Templates/gcc/startup_stm32f722xx.s  |   555 +
 .../Source/Templates/gcc/startup_stm32f723xx.s  |   555 +
 .../Source/Templates/gcc/startup_stm32f732xx.s  |   558 +
 .../Source/Templates/gcc/startup_stm32f733xx.s  |   558 +
 .../Source/Templates/gcc/startup_stm32f745xx.s  |   585 +
 .../Source/Templates/gcc/startup_stm32f746xx.s  |   591 +
 .../Source/Templates/gcc/startup_stm32f756xx.s  |   594 +
 .../Source/Templates/gcc/startup_stm32f765xx.s  |   627 +
 .../Source/Templates/gcc/startup_stm32f767xx.s  |   636 +
 .../Source/Templates/gcc/startup_stm32f769xx.s  |   639 +
 .../Source/Templates/gcc/startup_stm32f777xx.s  |   639 +
 .../Source/Templates/gcc/startup_stm32f779xx.s  |   642 +
 .../iar/linker/stm32f722xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f722xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f722xx_sram.icf   |    34 +
 .../iar/linker/stm32f723xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f723xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f723xx_sram.icf   |    34 +
 .../iar/linker/stm32f732xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f732xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f732xx_sram.icf   |    34 +
 .../iar/linker/stm32f733xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f733xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f733xx_sram.icf   |    34 +
 .../iar/linker/stm32f745xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f745xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f745xx_sram.icf   |    34 +
 .../iar/linker/stm32f746xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f746xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f746xx_sram.icf   |    34 +
 .../iar/linker/stm32f756xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f756xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f756xx_sram.icf   |    34 +
 .../iar/linker/stm32f765xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f765xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f765xx_sram.icf   |    34 +
 .../iar/linker/stm32f767xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f767xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f767xx_sram.icf   |    34 +
 .../iar/linker/stm32f769xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f769xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f769xx_sram.icf   |    34 +
 .../iar/linker/stm32f777xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f777xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f777xx_sram.icf   |    34 +
 .../iar/linker/stm32f779xx_ITCM_flash.icf       |    35 +
 .../Templates/iar/linker/stm32f779xx_flash.icf  |    34 +
 .../Templates/iar/linker/stm32f779xx_sram.icf   |    34 +
 .../Source/Templates/iar/startup_stm32f722xx.s  |   668 +
 .../Source/Templates/iar/startup_stm32f723xx.s  |   668 +
 .../Source/Templates/iar/startup_stm32f732xx.s  |   673 +
 .../Source/Templates/iar/startup_stm32f733xx.s  |   673 +
 .../Source/Templates/iar/startup_stm32f745xx.s  |   722 +
 .../Source/Templates/iar/startup_stm32f746xx.s  |   732 +
 .../Source/Templates/iar/startup_stm32f756xx.s  |   737 +
 .../Source/Templates/iar/startup_stm32f765xx.s  |   784 +
 .../Source/Templates/iar/startup_stm32f767xx.s  |   799 +
 .../Source/Templates/iar/startup_stm32f769xx.s  |   804 +
 .../Source/Templates/iar/startup_stm32f777xx.s  |   804 +
 .../Source/Templates/iar/startup_stm32f779xx.s  |   809 +
 .../Source/Templates/system_stm32f7xx.c         |   280 +
 .../Inc/Legacy/stm32_hal_legacy.h               |  3158 +++
 .../Inc/stm32_assert_template.h                 |    75 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal.h    |   253 +
 .../Inc/stm32f7xx_hal_adc.h                     |   915 +
 .../Inc/stm32f7xx_hal_adc_ex.h                  |   379 +
 .../Inc/stm32f7xx_hal_can.h                     |   768 +
 .../Inc/stm32f7xx_hal_cec.h                     |   751 +
 .../Inc/stm32f7xx_hal_conf_template.h           |   464 +
 .../Inc/stm32f7xx_hal_cortex.h                  |   424 +
 .../Inc/stm32f7xx_hal_crc.h                     |   423 +
 .../Inc/stm32f7xx_hal_crc_ex.h                  |   168 +
 .../Inc/stm32f7xx_hal_cryp.h                    |  1168 +
 .../Inc/stm32f7xx_hal_cryp_ex.h                 |   293 +
 .../Inc/stm32f7xx_hal_dac.h                     |   408 +
 .../Inc/stm32f7xx_hal_dac_ex.h                  |   191 +
 .../Inc/stm32f7xx_hal_dcmi.h                    |   628 +
 .../Inc/stm32f7xx_hal_dcmi_ex.h                 |    55 +
 .../Inc/stm32f7xx_hal_def.h                     |   213 +
 .../Inc/stm32f7xx_hal_dfsdm.h                   |   710 +
 .../Inc/stm32f7xx_hal_dma.h                     |   768 +
 .../Inc/stm32f7xx_hal_dma2d.h                   |   638 +
 .../Inc/stm32f7xx_hal_dma_ex.h                  |   203 +
 .../Inc/stm32f7xx_hal_dsi.h                     |  1242 +
 .../Inc/stm32f7xx_hal_eth.h                     |  2184 ++
 .../Inc/stm32f7xx_hal_flash.h                   |   426 +
 .../Inc/stm32f7xx_hal_flash_ex.h                |   663 +
 .../Inc/stm32f7xx_hal_gpio.h                    |   327 +
 .../Inc/stm32f7xx_hal_gpio_ex.h                 |   675 +
 .../Inc/stm32f7xx_hal_hash.h                    |   450 +
 .../Inc/stm32f7xx_hal_hash_ex.h                 |   199 +
 .../Inc/stm32f7xx_hal_hcd.h                     |   281 +
 .../Inc/stm32f7xx_hal_i2c.h                     |   710 +
 .../Inc/stm32f7xx_hal_i2c_ex.h                  |   223 +
 .../Inc/stm32f7xx_hal_i2s.h                     |   483 +
 .../Inc/stm32f7xx_hal_irda.h                    |   760 +
 .../Inc/stm32f7xx_hal_irda_ex.h                 |   239 +
 .../Inc/stm32f7xx_hal_iwdg.h                    |   257 +
 .../Inc/stm32f7xx_hal_jpeg.h                    |   581 +
 .../Inc/stm32f7xx_hal_lptim.h                   |   739 +
 .../Inc/stm32f7xx_hal_ltdc.h                    |   662 +
 .../Inc/stm32f7xx_hal_ltdc_ex.h                 |   151 +
 .../Inc/stm32f7xx_hal_mdios.h                   |   537 +
 .../Inc/stm32f7xx_hal_mmc.h                     |   695 +
 .../Inc/stm32f7xx_hal_nand.h                    |   336 +
 .../Inc/stm32f7xx_hal_nor.h                     |   299 +
 .../Inc/stm32f7xx_hal_pcd.h                     |   337 +
 .../Inc/stm32f7xx_hal_pcd_ex.h                  |   116 +
 .../Inc/stm32f7xx_hal_pwr.h                     |   422 +
 .../Inc/stm32f7xx_hal_pwr_ex.h                  |   280 +
 .../Inc/stm32f7xx_hal_qspi.h                    |   781 +
 .../Inc/stm32f7xx_hal_rcc.h                     |  1306 +
 .../Inc/stm32f7xx_hal_rcc_ex.h                  |  3519 +++
 .../Inc/stm32f7xx_hal_rng.h                     |   358 +
 .../Inc/stm32f7xx_hal_rtc.h                     |   813 +
 .../Inc/stm32f7xx_hal_rtc_ex.h                  |  1035 +
 .../Inc/stm32f7xx_hal_sai.h                     |   850 +
 .../Inc/stm32f7xx_hal_sai_ex.h                  |    56 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_hal_sd.h |   716 +
 .../Inc/stm32f7xx_hal_sdram.h                   |   199 +
 .../Inc/stm32f7xx_hal_smartcard.h               |   949 +
 .../Inc/stm32f7xx_hal_smartcard_ex.h            |   308 +
 .../Inc/stm32f7xx_hal_smbus.h                   |   697 +
 .../Inc/stm32f7xx_hal_spdifrx.h                 |   560 +
 .../Inc/stm32f7xx_hal_spi.h                     |   689 +
 .../Inc/stm32f7xx_hal_sram.h                    |   195 +
 .../Inc/stm32f7xx_hal_tim.h                     |  1563 ++
 .../Inc/stm32f7xx_hal_tim_ex.h                  |   648 +
 .../Inc/stm32f7xx_hal_uart.h                    |  1221 +
 .../Inc/stm32f7xx_hal_uart_ex.h                 |   365 +
 .../Inc/stm32f7xx_hal_usart.h                   |   696 +
 .../Inc/stm32f7xx_hal_usart_ex.h                |   158 +
 .../Inc/stm32f7xx_hal_wwdg.h                    |   285 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_adc.h |  4767 ++++
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_bus.h |  1994 ++
 .../Inc/stm32f7xx_ll_cortex.h                   |   657 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_crc.h |   479 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_dac.h |  1316 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_dma.h |  2911 +++
 .../Inc/stm32f7xx_ll_dma2d.h                    |  2070 ++
 .../Inc/stm32f7xx_ll_exti.h                     |   968 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_fmc.h |  1339 +
 .../Inc/stm32f7xx_ll_gpio.h                     |  1000 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_i2c.h |  2207 ++
 .../Inc/stm32f7xx_ll_iwdg.h                     |   363 +
 .../Inc/stm32f7xx_ll_lptim.h                    |  1382 ++
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_pwr.h |  1036 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_rcc.h |  5170 ++++
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_rng.h |   355 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_rtc.h |  3867 +++
 .../Inc/stm32f7xx_ll_sdmmc.h                    |  1024 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_spi.h |  2293 ++
 .../Inc/stm32f7xx_ll_system.h                   |  1039 +
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_tim.h |  4663 ++++
 .../Inc/stm32f7xx_ll_usart.h                    |  3560 +++
 .../STM32F7xx_HAL_Driver/Inc/stm32f7xx_ll_usb.h |   474 +
 .../Inc/stm32f7xx_ll_utils.h                    |   323 +
 .../Inc/stm32f7xx_ll_wwdg.h                     |   342 +
 .../STM32F7xx_HAL_Driver/Release_Notes.html     |  1028 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_hal.c    |   536 +
 .../Src/stm32f7xx_hal_adc.c                     |  1686 ++
 .../Src/stm32f7xx_hal_adc_ex.c                  |  1069 +
 .../Src/stm32f7xx_hal_can.c                     |  1412 ++
 .../Src/stm32f7xx_hal_cec.c                     |   670 +
 .../Src/stm32f7xx_hal_cortex.c                  |   523 +
 .../Src/stm32f7xx_hal_crc.c                     |   531 +
 .../Src/stm32f7xx_hal_crc_ex.c                  |   242 +
 .../Src/stm32f7xx_hal_cryp.c                    |  5182 ++++
 .../Src/stm32f7xx_hal_cryp_ex.c                 |  6039 +++++
 .../Src/stm32f7xx_hal_dac.c                     |   967 +
 .../Src/stm32f7xx_hal_dac_ex.c                  |   388 +
 .../Src/stm32f7xx_hal_dcmi.c                    |   906 +
 .../Src/stm32f7xx_hal_dcmi_ex.c                 |    52 +
 .../Src/stm32f7xx_hal_dfsdm.c                   |  3018 +++
 .../Src/stm32f7xx_hal_dma.c                     |  1318 +
 .../Src/stm32f7xx_hal_dma2d.c                   |  1764 ++
 .../Src/stm32f7xx_hal_dma_ex.c                  |   328 +
 .../Src/stm32f7xx_hal_dsi.c                     |  2262 ++
 .../Src/stm32f7xx_hal_eth.c                     |  2045 ++
 .../Src/stm32f7xx_hal_flash.c                   |   829 +
 .../Src/stm32f7xx_hal_flash_ex.c                |  1140 +
 .../Src/stm32f7xx_hal_gpio.c                    |   543 +
 .../Src/stm32f7xx_hal_hash.c                    |  1878 ++
 .../Src/stm32f7xx_hal_hash_ex.c                 |  1636 ++
 .../Src/stm32f7xx_hal_hcd.c                     |  1229 +
 .../Src/stm32f7xx_hal_i2c.c                     |  4867 ++++
 .../Src/stm32f7xx_hal_i2c_ex.c                  |   275 +
 .../Src/stm32f7xx_hal_i2s.c                     |  1556 ++
 .../Src/stm32f7xx_hal_irda.c                    |  2240 ++
 .../Src/stm32f7xx_hal_iwdg.c                    |   282 +
 .../Src/stm32f7xx_hal_jpeg.c                    |  3460 +++
 .../Src/stm32f7xx_hal_lptim.c                   |  1705 ++
 .../Src/stm32f7xx_hal_ltdc.c                    |  1915 ++
 .../Src/stm32f7xx_hal_ltdc_ex.c                 |   162 +
 .../Src/stm32f7xx_hal_mdios.c                   |   627 +
 .../Src/stm32f7xx_hal_mmc.c                     |  2493 ++
 .../Src/stm32f7xx_hal_msp_template.c            |   119 +
 .../Src/stm32f7xx_hal_nand.c                    |  1859 ++
 .../Src/stm32f7xx_hal_nor.c                     |  1044 +
 .../Src/stm32f7xx_hal_pcd.c                     |  1311 +
 .../Src/stm32f7xx_hal_pcd_ex.c                  |   322 +
 .../Src/stm32f7xx_hal_pwr.c                     |   609 +
 .../Src/stm32f7xx_hal_pwr_ex.c                  |   572 +
 .../Src/stm32f7xx_hal_qspi.c                    |  2337 ++
 .../Src/stm32f7xx_hal_rcc.c                     |  1130 +
 .../Src/stm32f7xx_hal_rcc_ex.c                  |  1602 ++
 .../Src/stm32f7xx_hal_rng.c                     |   522 +
 .../Src/stm32f7xx_hal_rtc.c                     |  1567 ++
 .../Src/stm32f7xx_hal_rtc_ex.c                  |  1853 ++
 .../Src/stm32f7xx_hal_sai.c                     |  2184 ++
 .../Src/stm32f7xx_hal_sai_ex.c                  |    52 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_hal_sd.c |  2913 +++
 .../Src/stm32f7xx_hal_sdram.c                   |   859 +
 .../Src/stm32f7xx_hal_smartcard.c               |  2282 ++
 .../Src/stm32f7xx_hal_smartcard_ex.c            |   184 +
 .../Src/stm32f7xx_hal_smbus.c                   |  2053 ++
 .../Src/stm32f7xx_hal_spdifrx.c                 |  1258 +
 .../Src/stm32f7xx_hal_spi.c                     |  3739 +++
 .../Src/stm32f7xx_hal_sram.c                    |   690 +
 .../Src/stm32f7xx_hal_tim.c                     |  5534 +++++
 .../Src/stm32f7xx_hal_tim_ex.c                  |  2565 ++
 .../stm32f7xx_hal_timebase_rtc_alarm_template.c |   314 +
 ...stm32f7xx_hal_timebase_rtc_wakeup_template.c |   293 +
 .../Src/stm32f7xx_hal_timebase_tim_template.c   |   184 +
 .../Src/stm32f7xx_hal_uart.c                    |  2174 ++
 .../Src/stm32f7xx_hal_usart.c                   |  1986 ++
 .../Src/stm32f7xx_hal_wwdg.c                    |   322 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_adc.c |   920 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_crc.c |   125 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_dac.c |   273 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_dma.c |   464 +
 .../Src/stm32f7xx_ll_dma2d.c                    |   653 +
 .../Src/stm32f7xx_ll_exti.c                     |   232 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_fmc.c |  1117 +
 .../Src/stm32f7xx_ll_gpio.c                     |   325 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_i2c.c |   258 +
 .../Src/stm32f7xx_ll_lptim.c                    |   212 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_pwr.c |   105 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_rcc.c |  1581 ++
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_rng.c |   116 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_rtc.c |   897 +
 .../Src/stm32f7xx_ll_sdmmc.c                    |  1504 ++
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_spi.c |   589 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_tim.c |  1396 ++
 .../Src/stm32f7xx_ll_usart.c                    |   463 +
 .../STM32F7xx_HAL_Driver/Src/stm32f7xx_ll_usb.c |  1797 ++
 .../Src/stm32f7xx_ll_utils.c                    |   757 +
 hw/mcu/stm/stm32f7xx/src/hal_flash.c            |   141 +
 hw/mcu/stm/stm32f7xx/src/hal_gpio.c             |   715 +
 hw/mcu/stm/stm32f7xx/src/hal_i2c.c              |   177 +
 hw/mcu/stm/stm32f7xx/src/hal_os_tick.c          |    55 +
 hw/mcu/stm/stm32f7xx/src/hal_reset_cause.c      |    47 +
 hw/mcu/stm/stm32f7xx/src/hal_system.c           |    55 +
 hw/mcu/stm/stm32f7xx/src/hal_system_start.c     |    54 +
 hw/mcu/stm/stm32f7xx/src/hal_timer.c            |   648 +
 hw/mcu/stm/stm32f7xx/src/hal_uart.c             |   428 +
 hw/mcu/stm/stm32f7xx/src/hal_watchdog.c         |    59 +
 hw/mcu/stm/stm32f7xx/src/stm32f7xx_hw_id.c      |    42 +
 hw/mcu/stm/stm32f7xx/stm32f767.ld               |   212 +
 hw/scripts/common.sh                            |    21 +-
 hw/scripts/jlink.sh                             |    80 +-
 hw/scripts/openocd.sh                           |    82 +-
 hw/sensor/include/sensor/color.h                |    41 +-
 hw/sensor/src/sensor_shell.c                    |    43 +-
 .../os/include/os/arch/cortex_m7/os/os_arch.h   |    84 +
 kernel/os/src/arch/cortex_m7/m7/HAL_CM7.s       |   240 +
 kernel/os/src/arch/cortex_m7/m7/SVC_Table.s     |    56 +
 kernel/os/src/arch/cortex_m7/os_arch_arm.c      |   352 +
 kernel/os/src/arch/cortex_m7/os_fault.c         |   176 +
 net/oic/src/messaging/coap/observe.c            |    12 +-
 repository.yml                                  |    12 +-
 379 files changed, 457350 insertions(+), 140 deletions(-)
----------------------------------------------------------------------



[39/50] [abbrv] incubator-mynewt-core git commit: This closes #209.

Posted by we...@apache.org.
This closes #209.

Merge branch 'fix_timtest_pstack_malloc' of https://github.com/grapherd/incubator-mynewt-core into develop


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/ea988a0c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/ea988a0c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/ea988a0c

Branch: refs/heads/nrf_cputime
Commit: ea988a0cf9c88a0737643189ff63f9e2ad4125b9
Parents: ded20e1 3fa905b
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Wed Mar 22 13:52:27 2017 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Wed Mar 22 13:52:27 2017 -0700

----------------------------------------------------------------------
 apps/timtest/src/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



[22/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-673 testbench reports some fails as passes

Posted by we...@apache.org.
MYNEWT-673 testbench reports some fails as passes


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/0d659e87
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/0d659e87
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/0d659e87

Branch: refs/heads/nrf_cputime
Commit: 0d659e8762aa6626eeae69b9e2c154d44e85a4e8
Parents: c87fac5
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Mar 15 18:54:42 2017 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Mar 15 18:54:42 2017 -0700

----------------------------------------------------------------------
 apps/testbench/src/testbench.c         | 11 +++++------
 apps/testbench/src/testbench_json.c    |  5 -----
 apps/testbench/src/testbench_mempool.c |  5 -----
 apps/testbench/src/testbench_mutex.c   | 20 ++------------------
 apps/testbench/src/testbench_sem.c     |  5 ++---
 5 files changed, 9 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0d659e87/apps/testbench/src/testbench.c
----------------------------------------------------------------------
diff --git a/apps/testbench/src/testbench.c b/apps/testbench/src/testbench.c
index d97d397..b8fe034 100644
--- a/apps/testbench/src/testbench.c
+++ b/apps/testbench/src/testbench.c
@@ -127,18 +127,21 @@ void
 testbench_ts_pass(char *msg, int msg_len, void *arg)
 {
     TESTBENCH_UPDATE_TOD;
+
+    total_tests++;
     LOG_INFO(&testlog, LOG_MODULE_TEST, "%s test case %s PASSED %s %s",
              buildID, tu_case_name, msg, runtest_token);
-    return;
 }
 
 void
 testbench_ts_fail(char *msg, int msg_len, void *arg)
 {
     TESTBENCH_UPDATE_TOD;
+
+    total_tests++;
+    total_fails++;
     LOG_INFO(&testlog, LOG_MODULE_TEST, "%s test case %s FAILED %s %s",
              buildID, tu_case_name, msg, runtest_token);
-    return;
 }
 
 #if 0
@@ -209,8 +212,6 @@ testbench_runtests(struct os_event *ev)
         SLIST_FOREACH(ts, &g_ts_suites, ts_next) {
             if (run_all || !strcmp(runtest_arg->run_testname, ts->ts_name)) {
                 ts->ts_test();
-                total_tests += tu_case_idx;
-                total_fails += tu_case_failed;
             }
         }
     } else {
@@ -219,8 +220,6 @@ testbench_runtests(struct os_event *ev)
          */
         SLIST_FOREACH(ts, &g_ts_suites, ts_next) {
             ts->ts_test();
-            total_tests += tu_case_idx;
-            total_fails += tu_case_failed;
         }
     }
     testbench_test_complete();

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0d659e87/apps/testbench/src/testbench_json.c
----------------------------------------------------------------------
diff --git a/apps/testbench/src/testbench_json.c b/apps/testbench/src/testbench_json.c
index 1d1cc8e..b750cd3 100644
--- a/apps/testbench/src/testbench_json.c
+++ b/apps/testbench/src/testbench_json.c
@@ -39,15 +39,10 @@ testbench_json_init(void *arg)
     LOG_DEBUG(&testlog, LOG_MODULE_TEST,
              "%s testbench json_init", buildID);
 
-    tu_case_idx = 0;
-    tu_case_failed = 0;
-
     bigbuf = os_malloc(JSON_BIGBUF_SIZE);
 
     tu_suite_set_pass_cb(testbench_ts_pass, NULL);
     tu_suite_set_fail_cb(testbench_ts_fail, NULL);
-
-    return;
 }
 
 void

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0d659e87/apps/testbench/src/testbench_mempool.c
----------------------------------------------------------------------
diff --git a/apps/testbench/src/testbench_mempool.c b/apps/testbench/src/testbench_mempool.c
index 64b5f79..b7fc190 100644
--- a/apps/testbench/src/testbench_mempool.c
+++ b/apps/testbench/src/testbench_mempool.c
@@ -55,17 +55,12 @@ testbench_mempool_init(void *arg)
     LOG_DEBUG(&testlog, LOG_MODULE_TEST,
              "%s testbench mempool_init", buildID);
 
-    tu_case_idx = 0;
-    tu_case_failed = 0;
-
     TstMembufSz = (sizeof(os_membuf_t) *
                    OS_MEMPOOL_SIZE(NUM_MEM_BLOCKS, MEM_BLOCK_SIZE));
     TstMembuf = os_malloc(TstMembufSz);
 
     tu_suite_set_pass_cb(testbench_ts_pass, NULL);
     tu_suite_set_fail_cb(testbench_ts_fail, NULL);
-
-    return;
 }
 
 void

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0d659e87/apps/testbench/src/testbench_mutex.c
----------------------------------------------------------------------
diff --git a/apps/testbench/src/testbench_mutex.c b/apps/testbench/src/testbench_mutex.c
index 59c8158..4998aeb 100644
--- a/apps/testbench/src/testbench_mutex.c
+++ b/apps/testbench/src/testbench_mutex.c
@@ -75,20 +75,6 @@ testbench_mutex_tc_posttest(void* arg)
     return;
 }
 
-void
-testbench_mutex_ts_pass(char *msg, int msg_len, void *arg)
-{
-    LOG_INFO(&testlog, LOG_MODULE_TEST,
-              "%s test case %s PASSED %s", buildID, tu_case_name, msg);
-}
-    
-void
-testbench_mutex_ts_fail(char *msg, int msg_len, void *arg)
-{
-    LOG_INFO(&testlog, LOG_MODULE_TEST,
-             "%s test case %s FAILED %s", buildID, tu_case_name, msg);
-}
-
 /*
  * "Suspend" the test worker tasks after each test completes.
  * These tasks can be re-used for other tests, the stack also can be re-used.
@@ -131,10 +117,8 @@ testbench_mutex_init(void *arg)
     LOG_DEBUG(&testlog, LOG_MODULE_TEST,
              "%s testbench test_init", buildID);
 
-    tu_suite_set_pass_cb(testbench_mutex_ts_pass, NULL);
-    tu_suite_set_fail_cb(testbench_mutex_ts_fail, NULL);
-
-    return;
+    tu_suite_set_pass_cb(testbench_ts_pass, NULL);
+    tu_suite_set_fail_cb(testbench_ts_fail, NULL);
 }
 
 TEST_CASE_DECL(os_mutex_test_basic)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/0d659e87/apps/testbench/src/testbench_sem.c
----------------------------------------------------------------------
diff --git a/apps/testbench/src/testbench_sem.c b/apps/testbench/src/testbench_sem.c
index a14a36f..e570da5 100644
--- a/apps/testbench/src/testbench_sem.c
+++ b/apps/testbench/src/testbench_sem.c
@@ -72,12 +72,11 @@ testbench_sem_init(void *arg)
     tu_case_idx = 0;
     tu_case_failed = 0;
 
-    LOG_DEBUG(&testlog, LOG_MODULE_TEST, "%s testbench_sem suite init", buildID);
+    LOG_DEBUG(&testlog, LOG_MODULE_TEST, "%s testbench_sem suite init",
+              buildID);
 
     tu_suite_set_pass_cb(testbench_ts_pass, NULL);
     tu_suite_set_fail_cb(testbench_ts_fail, NULL);
-
-    return;
 }
 
 TEST_CASE(os_sem_test_null)


[11/50] [abbrv] incubator-mynewt-core git commit: remove diff.txt, spuriously merged.

Posted by we...@apache.org.
remove diff.txt, spuriously merged.


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/c9fbdfc3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c9fbdfc3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c9fbdfc3

Branch: refs/heads/nrf_cputime
Commit: c9fbdfc3529c9b512b24693a6fb01eef8e5951b1
Parents: b729f76
Author: Sterling Hughes <st...@runtime.io>
Authored: Sat Mar 11 10:56:41 2017 -0800
Committer: Sterling Hughes <st...@runtime.io>
Committed: Sat Mar 11 10:56:41 2017 -0800

----------------------------------------------------------------------
 diff.txt | 330 ----------------------------------------------------------
 1 file changed, 330 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c9fbdfc3/diff.txt
----------------------------------------------------------------------
diff --git a/diff.txt b/diff.txt
deleted file mode 100644
index 1496b88..0000000
--- a/diff.txt
+++ /dev/null
@@ -1,330 +0,0 @@
-diff --git a/apps/boot/src/boot.c b/apps/boot/src/boot.c
-index 9cd59e7..4f4f827 100755
---- a/apps/boot/src/boot.c
-+++ b/apps/boot/src/boot.c
-@@ -23,7 +23,7 @@
- #include "syscfg/syscfg.h"
- #include <flash_map/flash_map.h>
- #include <os/os.h>
--#include <bsp/bsp.h>
-+//#include <bsp/bsp.h>
- #include <hal/hal_bsp.h>
- #include <hal/hal_system.h>
- #include <hal/hal_flash.h>
-diff --git a/hw/bsp/sensorhub/boot-stm32f4discovery.ld b/hw/bsp/sensorhub/boot-stm32f4discovery.ld
-deleted file mode 100644
-index ae34f19..0000000
---- a/hw/bsp/sensorhub/boot-stm32f4discovery.ld
-+++ /dev/null
-@@ -1,31 +0,0 @@
--/*
-- * 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.
-- */
--
--/* Linker script for STM32F427 when running from flash and using the bootloader */
--
--/* Linker script to configure memory regions. */
--MEMORY
--{
--  FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 32K
--  CCM (rwx) : ORIGIN = 0x10000000, LENGTH = 64K
--  RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 192K
--}
--
--/* The bootloader does not contain an image header */
--_imghdr_size = 0x0;
-diff --git a/hw/bsp/sensorhub/bsp.yml b/hw/bsp/sensorhub/bsp.yml
-index c87e36a..f19e0e8 100644
---- a/hw/bsp/sensorhub/bsp.yml
-+++ b/hw/bsp/sensorhub/bsp.yml
-@@ -20,15 +20,15 @@
- bsp.arch: cortex_m4
- bsp.compiler: compiler/arm-none-eabi-m4
- bsp.linkerscript:
--    - "hw/bsp/stm32f4discovery/stm32f4discovery.ld"
-+    - "hw/bsp/sensorhub/sensorhub.ld"
-     - "hw/mcu/stm/stm32f4xx/stm32f427.ld"
- bsp.linkerscript.BOOT_LOADER.OVERWRITE:
--    - "hw/bsp/stm32f4discovery/boot-stm32f4discovery.ld"
-+    - "hw/bsp/sensorhub/boot-sensorhub.ld"
-     - "hw/mcu/stm/stm32f4xx/stm32f427.ld"
--bsp.downloadscript: "hw/bsp/stm32f4discovery/stm32f4discovery_download.sh"
--bsp.debugscript: "hw/bsp/stm32f4discovery/stm32f4discovery_debug.sh"
--bsp.downloadscript.WINDOWS.OVERRIDE: "hw/bsp/stm32f4discovery/stm32f4discovery_download.cmd"
--bsp.debugscript.WINDOWS.OVERRIDE: "hw/bsp/stm32f4discovery/stm32f4discovery_debug.cmd"
-+bsp.downloadscript: "hw/bsp/sensorhub/sensorhub_download.sh"
-+bsp.debugscript: "hw/bsp/sensorhub/sensorhub_debug.sh"
-+bsp.downloadscript.WINDOWS.OVERRIDE: "hw/bsp/sensorhub/sensorhub_download.cmd"
-+bsp.debugscript.WINDOWS.OVERRIDE: "hw/bsp/sensorhub/sensorhub_debug.cmd"
- 
- bsp.flash_map:
-     areas:
-diff --git a/hw/bsp/sensorhub/f4discovery.cfg b/hw/bsp/sensorhub/f4discovery.cfg
-deleted file mode 100644
-index 3fa5699..0000000
---- a/hw/bsp/sensorhub/f4discovery.cfg
-+++ /dev/null
-@@ -1,22 +0,0 @@
--#!/bin/sh
--# 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.
--
--# JLink debugger
--source [find interface/jlink.cfg]
--transport select hla_swd
--source [find target/stm32f4x.cfg]
-diff --git a/hw/bsp/sensorhub/include/bsp/bsp.h b/hw/bsp/sensorhub/include/bsp/bsp.h
-index f7866a2..ef7f6b4 100644
---- a/hw/bsp/sensorhub/include/bsp/bsp.h
-+++ b/hw/bsp/sensorhub/include/bsp/bsp.h
-@@ -1,4 +1,4 @@
--/*
-+quit/*
-  * 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
-@@ -35,11 +35,10 @@ extern "C" {
- /* More convenient section placement macros. */
- #define bssnz_t         sec_bss_nz_core
- 
--extern uint8_t _ram_start;
--extern uint8_t _ccram_start;
--
- /* System SRAM including CCM (core coupled memory) data RAM. */
-+extern uint8_t _ram_start;
- #define RAM_SIZE        (192 * 1024)
-+extern uint8_t _ccram_start;
- #define CCRAM_SIZE      (64 * 1024)
- 
- /* 4KB of backup SRAM, accessible only from the CPU. 
-@@ -54,14 +53,14 @@ extern uint8_t _ccram_start;
- #define UART_CNT 1
- #define CONSOLE_UART 	"uart0"
- 
--#if MYNEWT_VAL(BOOT_SERIAL)
-+//#if MYNEWT_VAL(BOOT_SERIAL)
- #define BOOT_SERIAL_DETECT_PIN          16 /* on Sensor Hub board BOOT0 is dedicated! */
- #define BOOT_SERIAL_DETECT_PIN_CFG      HAL_GPIO_PULL_UP
- #define BOOT_SERIAL_DETECT_PIN_VAL      0
- 
- #define BOOT_SERIAL_REPORT_PIN          LED_BLINK_PIN
- #define BOOT_SERIAL_REPORT_FREQ         (MYNEWT_VAL(OS_CPUTIME_FREQ) / 4)
--#endif
-+//#endif
- 
- #define NFFS_AREA_MAX    (8)
- 
-diff --git a/hw/bsp/sensorhub/src/hal_bsp.c b/hw/bsp/sensorhub/src/hal_bsp.c
-index 18a0f6c..1cea958 100644
---- a/hw/bsp/sensorhub/src/hal_bsp.c
-+++ b/hw/bsp/sensorhub/src/hal_bsp.c
-@@ -16,15 +16,10 @@
-  * specific language governing permissions and limitations
-  * under the License.
-  */
-+#include <stdint.h>
-+#include <stddef.h>
- #include <assert.h>
--
--#include <syscfg/syscfg.h>
--
--#include <os/os_dev.h>
--#if MYNEWT_VAL(UART_0)
--#include <uart/uart.h>
--#include <uart_hal/uart_hal.h>
--#endif
-+#include "syscfg/syscfg.h"
- 
- #include <hal/hal_bsp.h>
- #include <hal/hal_gpio.h>
-@@ -35,7 +30,12 @@
- #include <stm32f4xx_hal_gpio_ex.h>
- #include <mcu/stm32f4_bsp.h>
- 
--#include "bsp/bsp.h"
-+#if MYNEWT_VAL(UART_0)
-+#include <uart/uart.h>
-+#include <uart_hal/uart_hal.h>
-+#endif
-+#include "os/os_dev.h"
-+#include "bsp.h"
- 
- #if MYNEWT_VAL(UART_0)
- static struct uart_dev hal_uart0;
-diff --git a/hw/bsp/sensorhub/stm32f4discovery.ld b/hw/bsp/sensorhub/stm32f4discovery.ld
-deleted file mode 100644
-index 923a133..0000000
---- a/hw/bsp/sensorhub/stm32f4discovery.ld
-+++ /dev/null
-@@ -1,31 +0,0 @@
--/*
-- * 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.
-- */
--
--/* Linker script for STM32F427 when running from flash and using the bootloader */
--
--/* Linker script to configure memory regions. */
--MEMORY
--{
--  FLASH (rx) :  ORIGIN = 0x08020000, LENGTH = 384K /* First image slot. */
--  CCM (rwx) :   ORIGIN = 0x10000000, LENGTH = 64K
--  RAM (rwx) :   ORIGIN = 0x20000000, LENGTH = 192K
--}
--
--/* This linker script is used for images and thus contains an image header */
--_imghdr_size = 0x20;
-diff --git a/hw/bsp/sensorhub/stm32f4discovery_debug.cmd b/hw/bsp/sensorhub/stm32f4discovery_debug.cmd
-deleted file mode 100755
-index d6cfc11..0000000
---- a/hw/bsp/sensorhub/stm32f4discovery_debug.cmd
-+++ /dev/null
-@@ -1,3 +0,0 @@
--@rem Execute a shell with a script of the same name and .sh extension
--
--@bash "%~dp0%~n0.sh"
-diff --git a/hw/bsp/sensorhub/stm32f4discovery_debug.sh b/hw/bsp/sensorhub/stm32f4discovery_debug.sh
-deleted file mode 100755
-index 14b2a64..0000000
---- a/hw/bsp/sensorhub/stm32f4discovery_debug.sh
-+++ /dev/null
-@@ -1,39 +0,0 @@
--#!/bin/sh
--# 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.
--#
--
--# Called with following variables set:
--#  - CORE_PATH is absolute path to @apache-mynewt-core
--#  - BSP_PATH is absolute path to hw/bsp/bsp_name
--#  - BIN_BASENAME is the path to prefix to target binary,
--#    .elf appended to name is the ELF file
--#  - FEATURES holds the target features string
--#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
--#  - RESET set if target should be reset when attaching
--#  - NO_GDB set if we should not start gdb to debug
--#
--. $CORE_PATH/hw/scripts/openocd.sh
--
--FILE_NAME=$BIN_BASENAME.elf
--CFG="-s $BSP_PATH -f $BSP_PATH/f4discovery.cfg"
--#ADG! CFG="-s $BSP_PATH -f /usr/share/openocd/scripts/interface/jlink.cfg -f /home/alan/dev/myproj-2/targets/stm_blinky/openocd.cfg"
--
--# Exit openocd when gdb detaches.
--EXTRA_JTAG_CMD="$EXTRA_JTAG_CMD; stm32f4x.cpu configure -event gdb-detach {if {[stm32f4x.cpu curstate] eq \"halted\"} resume;shutdown}"
--
--openocd_debug
-diff --git a/hw/bsp/sensorhub/stm32f4discovery_download.cmd b/hw/bsp/sensorhub/stm32f4discovery_download.cmd
-deleted file mode 100755
-index d6cfc11..0000000
---- a/hw/bsp/sensorhub/stm32f4discovery_download.cmd
-+++ /dev/null
-@@ -1,3 +0,0 @@
--@rem Execute a shell with a script of the same name and .sh extension
--
--@bash "%~dp0%~n0.sh"
-diff --git a/hw/bsp/sensorhub/stm32f4discovery_download.sh b/hw/bsp/sensorhub/stm32f4discovery_download.sh
-deleted file mode 100755
-index 5a3a17d..0000000
---- a/hw/bsp/sensorhub/stm32f4discovery_download.sh
-+++ /dev/null
-@@ -1,42 +0,0 @@
--#!/bin/sh
--# 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.
--#
--
--# Called with following variables set:
--#  - CORE_PATH is absolute path to @apache-mynewt-core
--#  - BSP_PATH is absolute path to hw/bsp/bsp_name
--#  - BIN_BASENAME is the path to prefix to target binary,
--#    .elf appended to name is the ELF file
--#  - IMAGE_SLOT is the image slot to download to (for non-mfg-image, non-boot)
--#  - FEATURES holds the target features string
--#  - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
--#  - MFG_IMAGE is "1" if this is a manufacturing image
--#  - FLASH_OFFSET contains the flash offset to download to
--#  - BOOT_LOADER is set if downloading a bootloader
--. $CORE_PATH/hw/scripts/openocd.sh
--
--CFG="-s $BSP_PATH -f f4discovery.cfg"
--#ADG! CFG="-s $BSP_PATH -f /usr/share/openocd/scripts/interface/jlink.cfg -f /home/alan/dev/myproj-2/targets/stm_blinky/openocd.cfg"
--
--if [ "$MFG_IMAGE" ]; then
--    FLASH_OFFSET=0x08000000
--fi
--
--common_file_to_load
--openocd_load
--openocd_reset_run


[31/50] [abbrv] incubator-mynewt-core git commit: MYNEWT-678 SensorAPI: Shell:

Posted by we...@apache.org.
MYNEWT-678 SensorAPI: Shell:

- Add support for polling at a given interval for a
  specific duration
- Initial commit


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/c93c7bea
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c93c7bea
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c93c7bea

Branch: refs/heads/nrf_cputime
Commit: c93c7bea45ee2b525ac5c6d209b10ad2b495f21e
Parents: ea98953
Author: Vipul Rahane <vi...@apache.org>
Authored: Thu Mar 16 16:05:56 2017 -0700
Committer: Vipul Rahane <vi...@apache.org>
Committed: Tue Mar 21 11:44:18 2017 -0700

----------------------------------------------------------------------
 hw/sensor/src/sensor_shell.c | 148 ++++++++++++++++++++++++++++++++++----
 1 file changed, 136 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c93c7bea/hw/sensor/src/sensor_shell.c
----------------------------------------------------------------------
diff --git a/hw/sensor/src/sensor_shell.c b/hw/sensor/src/sensor_shell.c
index 8fe2b21..250478e 100644
--- a/hw/sensor/src/sensor_shell.c
+++ b/hw/sensor/src/sensor_shell.c
@@ -40,6 +40,10 @@
 #include "console/console.h"
 #include "shell/shell.h"
 #include "hal/hal_i2c.h"
+#include "hal/hal_timer.h"
+
+#define SENSOR_SHELL_TIMER_NUM        (1)
+#define SENSOR_SHELL_TIMER_CLOCK_FREQ (100000)
 
 static int sensor_cmd_exec(int, char **);
 static struct shell_cmd shell_sensor_cmd = {
@@ -47,13 +51,31 @@ static struct shell_cmd shell_sensor_cmd = {
     .sc_cmd_func = sensor_cmd_exec
 };
 
+struct os_sem g_sensor_shell_sem;
+struct hal_timer g_sensor_shell_timer;
+uint32_t sensor_shell_timer_arg = 0xdeadc0de;
+uint8_t g_timer_is_config;
+
+struct sensor_poll_data {
+    int spd_nsamples;
+    int spd_poll_itvl;
+    int spd_poll_duration;
+    int spd_poll_delay;
+};
+
 static void
 sensor_display_help(void)
 {
     console_printf("Possible commands for sensor are:\n");
     console_printf("  list\n");
-    console_printf("  read\n");
-    console_printf("  i2cscan\n");
+    console_printf("      list of sensors registered\n");
+    console_printf("  read <sensor_name> <type> [-n nsamples] [-i poll_itvl(ms)] [-d poll_duration(ms)]\n");
+    console_printf("      read <no_of_samples> from sensor<sensor_name> of type:<type> at preset interval or \n");
+    console_printf("      at <poll_interval> rate for <poll_duration>");
+    console_printf("  i2cscan <I2C num>\n");
+    console_printf("      scan I2C bus for connected devices\n");
+    console_printf("  type <sensor_name>\n");
+    console_printf("      types supported by registered sensor\n");
 }
 
 static void
@@ -254,13 +276,29 @@ sensor_shell_read_listener(struct sensor *sensor, void *arg, void *data)
     return (0);
 }
 
+void
+sensor_shell_timer_cb(void *arg)
+{
+    int timer_arg_val;
+    int rc;
+
+    timer_arg_val = *(int *)arg;
+    rc = hal_timer_start(&g_sensor_shell_timer, timer_arg_val);
+    assert(rc == 0);
+    os_sem_release(&g_sensor_shell_sem);
+}
+
 static int
-sensor_cmd_read(char *name, sensor_type_t type, int nsamples)
+sensor_cmd_read(char *name, sensor_type_t type, struct sensor_poll_data *spd)
 {
     struct sensor *sensor;
     struct sensor_listener listener;
     struct sensor_shell_read_ctx ctx;
     int rc;
+    int duration;
+    int64_t start_ts;
+    int newline;
+    char ch;
 
     /* Look up sensor by name */
     sensor = sensor_mgr_find_next_bydevname(name, NULL);
@@ -291,22 +329,90 @@ sensor_cmd_read(char *name, sensor_type_t type, int nsamples)
         return rc;
     }
 
+    if (spd->spd_poll_itvl) {
+
+        if (!g_timer_is_config) {
+            rc = hal_timer_config(SENSOR_SHELL_TIMER_NUM, SENSOR_SHELL_TIMER_CLOCK_FREQ);
+            assert(rc == 0);
+            g_timer_is_config = 1;
+        }
+
+        sensor_shell_timer_arg = 1000 * spd->spd_poll_itvl;
+        rc = hal_timer_set_cb(SENSOR_SHELL_TIMER_NUM, &g_sensor_shell_timer, sensor_shell_timer_cb,
+                              &sensor_shell_timer_arg);
+        assert(rc == 0);
+
+        rc = hal_timer_start(&g_sensor_shell_timer, sensor_shell_timer_arg);
+    }   assert(rc == 0);
+
+    start_ts = 0;
+    duration = 0;
+
     while (1) {
+        if (spd->spd_poll_itvl) {
+            /*
+             * Wait for semaphore from callback,
+             * this semaphore should only be considered when a
+             * a poll interval is specified
+             */
+            os_sem_pend(&g_sensor_shell_sem, OS_TIMEOUT_NEVER);
+        }
+
         rc = sensor_read(sensor, type, NULL, NULL, OS_TIMEOUT_NEVER);
         if (rc) {
             console_printf("Cannot read sensor %s\n", name);
             goto err;
         }
-        if (ctx.num_entries >= nsamples) {
+
+        /* Condition for number of samples */
+        if (spd->spd_nsamples && ctx.num_entries >= spd->spd_nsamples) {
+            hal_timer_stop(&g_sensor_shell_timer);
             break;
         }
-    }
 
-    sensor_unregister_listener(sensor, &listener);
+        /*
+         * Incrementing duration based on interval if specified or
+         * os_time if interval is not specified and checking duration
+         */
+        if (spd->spd_poll_duration) {
+            if (spd->spd_poll_itvl) {
+                duration += spd->spd_poll_itvl;
+            } else {
+                if (!start_ts) {
+                    start_ts = os_get_uptime_usec()/1000;
+                } else {
+                    duration = os_get_uptime_usec()/1000 - start_ts;
+                }
+
+            }
+
+            if (duration >= spd->spd_poll_duration) {
+                hal_timer_stop(&g_sensor_shell_timer);
+                console_printf("Sensor polling done\n");
+                break;
+            }
+        }
+
+        ch = 0;
+        /* Check for escape sequence */
+        rc = console_read(&ch, 1, &newline);
+        if (rc) {
+            hal_timer_stop(&g_sensor_shell_timer);
+            goto err;
+        }
+        /* ^C or q or Q gets it out of the sampling loop */
+        if (ch == 3 || ch == 'q' || ch == 'Q') {
+            hal_timer_stop(&g_sensor_shell_timer);
+            console_printf("Sensor polling stopped\n");
+            break;
+        }
+    }
 
-    return 0;
 err:
+    os_sem_release(&g_sensor_shell_sem);
+
     sensor_unregister_listener(sensor, &listener);
+
     return rc;
 }
 
@@ -375,8 +481,10 @@ err:
 static int
 sensor_cmd_exec(int argc, char **argv)
 {
+    struct sensor_poll_data spd;
     char *subcmd;
     int rc;
+    int i;
 
     if (argc <= 1) {
         sensor_display_help();
@@ -388,15 +496,31 @@ sensor_cmd_exec(int argc, char **argv)
     if (!strcmp(subcmd, "list")) {
         sensor_cmd_list_sensors();
     } else if (!strcmp(subcmd, "read")) {
-        if (argc != 5) {
-            console_printf("Three arguments required for read: device name, "
-                    "sensor type and number of samples, only %d provided.\n",
-                    argc - 2);
+        if (argc < 6) {
+            console_printf("Too few arguments: %d\n"
+                           "Usage: sensor read <sensor_name> <type>"
+                           "[-n nsamples] [-i poll_itvl(ms)] [-d poll_duration(ms)]\n",
+                           argc - 2);
             rc = SYS_EINVAL;
             goto err;
         }
 
-        rc = sensor_cmd_read(argv[2], (sensor_type_t) strtol(argv[3], NULL, 0), atoi(argv[4]));
+        i = 4;
+        memset(&spd, 0, sizeof(struct sensor_poll_data));
+        if (!strcmp(argv[i], "-n")) {
+            spd.spd_nsamples = atoi(argv[++i]);
+            i++;
+        }
+        if (!strcmp(argv[i], "-i")) {
+            spd.spd_poll_itvl = atoi(argv[++i]);
+            i++;
+        }
+        if (!strcmp(argv[i], "-d")) {
+            spd.spd_poll_duration = atoi(argv[++i]);
+            i++;
+        }
+
+        rc = sensor_cmd_read(argv[2], (sensor_type_t) strtol(argv[3], NULL, 0), &spd);
         if (rc) {
             goto err;
         }