mynewt-core.git
19 hours agohw/drivers/lps33thw: Fix CLI for bus driver master
Andrzej Kaczmarek [Fri, 14 Dec 2018 09:18:05 +0000 (10:18 +0100)] 
hw/drivers/lps33thw: Fix CLI for bus driver

We use lazy initialization of g_sensor_itf here since device may not be
yet created at pkg init time.

30 hours agosys/flash_map: Don't replace dflt flash map with 0
Christopher Collins [Thu, 13 Dec 2018 01:09:43 +0000 (17:09 -0800)] 
sys/flash_map: Don't replace dflt flash map with 0

If no flash areas were found in the MMR, keep using the hardcoded flash
map instead of an empty one.

30 hours agosys/fault: Remove #include of nonexistent header
Christopher Collins [Thu, 13 Dec 2018 01:09:24 +0000 (17:09 -0800)] 
sys/fault: Remove #include of nonexistent header

41 hours agolis2dw12: fix self test to match an5038 rev2
Jacob Rosenthal [Mon, 11 Jun 2018 18:48:54 +0000 (11:48 -0700)] 
lis2dw12: fix self test to match an5038 rev2

43 hours agoMerge pull request #1562 from mkiiskila/flash_loader_dump
mkiiskila [Thu, 13 Dec 2018 09:52:16 +0000 (11:52 +0200)] 
Merge pull request #1562 from mkiiskila/flash_loader_dump

flash_loader; add support for reading flash contents to a file.

2 days agoflash_loader; add support for reading flash contents to a file. 1562/head
Marko Kiiskila [Wed, 12 Dec 2018 15:03:01 +0000 (17:03 +0200)] 
flash_loader; add support for reading flash contents to a file.

2 days agobmp280/bme280: Fix dependency for bus driver
Jerzy Kasenberg [Fri, 7 Dec 2018 11:56:12 +0000 (12:56 +0100)] 
bmp280/bme280: Fix dependency for bus driver

dependency to i2cn is not needed when bus driver is used.

2 days agohw/drivers/bmp280: Fix build for bus driver
Jerzy Kasenberg [Fri, 7 Dec 2018 11:27:19 +0000 (12:27 +0100)] 
hw/drivers/bmp280: Fix build for bus driver

struct bmp280 did not have bus driver fields by accident.

2 days agohw/drivers/bme280: Fix integer calculation compilation
Jerzy Kasenberg [Fri, 7 Dec 2018 08:47:37 +0000 (09:47 +0100)] 
hw/drivers/bme280: Fix integer calculation compilation

Integer calculation build variant was outdated and would not build.
This aligns code for double and integer computations.

2 days agobmp280/bme280: Fix pressure, humidity readout
Jerzy Kasenberg [Mon, 3 Dec 2018 14:47:49 +0000 (15:47 +0100)] 
bmp280/bme280: Fix pressure, humidity readout

If user wanted to read only pressure and/or humidity from sensor only first value
read from the device would be correct.
Further pressure humidity read request would use incorrect value of t_fine that
was computed only for the first reading when  temperature was actually read.

Even if temperature reading was requested, pressure values would be incorrect,
since temperature used for pressure compensation was taken from previous
read. For slow rate readings pressure would be always calculated with
old values from temperature.

Now temperature is always read even if not requested by user code to make sure
that pressure and humidity calculations are correct.

2 days agobmp280/bme280: Cleanup temperature and pressure reading function
Jerzy Kasenberg [Mon, 3 Dec 2018 14:36:51 +0000 (15:36 +0100)] 
bmp280/bme280: Cleanup temperature and pressure reading function

There was unnecessary conditional code in functions:
bmp280_get_temperature(), bmp280_get_pressure().
It made functions return different values depending on compilation flag
one version returned 20 bits values shifted by 4 bits left.
Later on, one set of compensation functions shifted raw values anyway.

Compensation functions that uses double float arithmetic also compared
invalid value from sensor with incorrect (24 bit value) value 0x800000,
instead of 0x80000 (20 bit value).
Code was correct for 32 bits arithmetic because shifting was done after
check and input value was 24 bit value.

2 days agobmp280/bme280: Update syscfg description
Jerzy Kasenberg [Mon, 3 Dec 2018 14:32:14 +0000 (15:32 +0100)] 
bmp280/bme280: Update syscfg description

syscfg description for BMx280_SPEC_CALC was cryptic.
Now it explains clearly what to expect when value is changed.
It switches between floating point and integer arithmetic used
for compensation calculations.

3 days agoUse syscfg settings for sysinit stage numbers
Christopher Collins [Thu, 25 Oct 2018 18:32:25 +0000 (11:32 -0700)] 
Use syscfg settings for sysinit stage numbers

This allows the app or target to rearrange package initialization order
via syscfg overrides.

Note: This requires an updated version of newt
(https://github.com/apache/mynewt-newt/pull/230).  Older versions of
newt fail to parse the updated `pkg.yml` files.

3 days agoRedefine `flash_area_close()` as an empty macro
Christopher Collins [Tue, 11 Dec 2018 03:02:04 +0000 (19:02 -0800)] 
Redefine `flash_area_close()` as an empty macro

Prior to this commit, `flash_area_close()` was a function with an empty
body.

To save code space in the boot loader, remove this function, and define
it as an empty macro instead.  If `flash_area_close()` ever needs to
perform a task, the macro can be removed and the function
re-implemented.

3 days agoMerge pull request #1557 from mkiiskila/flash_loader
mkiiskila [Tue, 11 Dec 2018 12:06:39 +0000 (14:06 +0200)] 
Merge pull request #1557 from mkiiskila/flash_loader

flash_loader; app and gdb macros to facilite populating external flash

3 days agohw/bsp: Specify SSD1673 config values in Reel Board bsp
Michał Narajowski [Wed, 7 Nov 2018 12:57:24 +0000 (13:57 +0100)] 
hw/bsp: Specify SSD1673 config values in Reel Board bsp

3 days agohw/bsp: Add option to enable active mode on Reel Board
Michał Narajowski [Wed, 7 Nov 2018 12:57:02 +0000 (13:57 +0100)] 
hw/bsp: Add option to enable active mode on Reel Board

Active mode enables power supply to peripherals. When using
display or sensors, please enable active mode.

3 days agohw/drivers: Port display driver SSD1673
Michał Narajowski [Tue, 6 Nov 2018 12:28:16 +0000 (13:28 +0100)] 
hw/drivers: Port display driver SSD1673

3 days agohw/drivers: Copy display drivers from Zephyr
Michał Narajowski [Tue, 6 Nov 2018 12:25:17 +0000 (13:25 +0100)] 
hw/drivers: Copy display drivers from Zephyr

4 days agoExport `id/target` setting if configured
Christopher Collins [Fri, 7 Dec 2018 01:32:15 +0000 (17:32 -0800)] 
Export `id/target` setting if configured

If the `ID_TARGET_PRESENT` syscfg setting is enabled, the target name is
readable through the `id/target` config setting.

This feature requires a recent version of newt (prior versions did not
inject the target name into the syscfg).  If an old version of newt is
used in a build where `ID_TARGET_PRESENT` is enabled, the build will
fail with a syscfg restriction violation error.

7 days agohw/drivers/bme280: Fix build errors
Jerzy Kasenberg [Thu, 6 Dec 2018 15:10:42 +0000 (16:10 +0100)] 
hw/drivers/bme280: Fix build errors

Code was using undefined macro to access field.

7 days agoConvert milliseconds to ticks before polling.
Nolan Lau [Fri, 7 Dec 2018 18:31:33 +0000 (10:31 -0800)] 
Convert milliseconds to ticks before polling.

7 days agoflash_loader; add a sample on how to use and scriptify this. 1557/head
Marko Kiiskila [Fri, 7 Dec 2018 16:19:50 +0000 (18:19 +0200)] 
flash_loader; add a sample on how to use and scriptify this.

7 days agoflash_loader; app and gdb macros to facilite populating external flash
Marko Kiiskila [Fri, 7 Dec 2018 12:37:48 +0000 (14:37 +0200)] 
flash_loader; app and gdb macros to facilite populating external flash
via MCU & programmer.

7 days agoMerge pull request #1378 from mlaz/lp5523_fixes
Miguel Azevedo [Fri, 7 Dec 2018 15:07:20 +0000 (15:07 +0000)] 
Merge pull request #1378 from mlaz/lp5523_fixes

lp5523: Fixing selftest, set_output_on and set_n_regs

7 days agoMerge pull request #1547 from mkiiskila/nrf52_ram_resident
mkiiskila [Fri, 7 Dec 2018 13:06:18 +0000 (15:06 +0200)] 
Merge pull request #1547 from mkiiskila/nrf52_ram_resident

nrf52; create a linker script for compiling apps which are loaded to RAM,

7 days ago.rat-excludes; add the new file nrf52_ram_resident.ld. 1547/head
Marko Kiiskila [Fri, 7 Dec 2018 12:51:36 +0000 (14:51 +0200)] 
.rat-excludes; add the new file nrf52_ram_resident.ld.

8 days agoBattery - Optional Start Delay (#1555)
brolan-juul [Fri, 7 Dec 2018 01:39:09 +0000 (17:39 -0800)] 
Battery - Optional Start Delay (#1555)

* Adding an optional delay before polling begins. This allows for certain fuel guages necessary bootup time.

* Consolidating function to avoid duplicating code.

8 days agobsp/hifive1: Add bus support
Jerzy Kasenberg [Thu, 6 Dec 2018 14:50:05 +0000 (15:50 +0100)] 
bsp/hifive1: Add bus support

SPI bus support is now added to bsp

8 days agofe310: Change spi freqnency to kHz
Jerzy Kasenberg [Thu, 6 Dec 2018 14:44:21 +0000 (15:44 +0100)] 
fe310: Change spi freqnency to kHz

SPI frequency was sepcified in Hz unlike other MCU's.

8 days agofe310: Add hal_spi_init_hw function
Jerzy Kasenberg [Thu, 6 Dec 2018 14:42:55 +0000 (15:42 +0100)] 
fe310: Add hal_spi_init_hw function

Recently added function needed for bus driver support.

8 days agobsp/hifive1: Fix linker warning
Jerzy Kasenberg [Thu, 6 Dec 2018 15:23:16 +0000 (16:23 +0100)] 
bsp/hifive1: Fix linker warning

Order of linker script entries in bsp.yml result in warning that is
visible during build only when some other link error happens.
repos/apache-mynewt-core/hw/bsp/hifive1/hifive1.ld:32: warning: memory region `flash' not declared
repos/apache-mynewt-core/hw/bsp/hifive1/hifive1.ld:131: warning: memory region `ram' not declared
repos/apache-mynewt-core/hw/bsp/hifive1/hifive1_boot.ld:22: warning: redeclaration of memory region `flash'
repos/apache-mynewt-core/hw/bsp/hifive1/hifive1_boot.ld:23: warning: redeclaration of memory region `ram'
Changing order of entries in bsp fixes this.

9 days agosys/log: Fix spurious uninitialized variable varning
Andrzej Kaczmarek [Wed, 5 Dec 2018 16:20:22 +0000 (17:20 +0100)] 
sys/log: Fix spurious uninitialized variable varning

GCC 7.3.1 complains about possible uinitialized 'rc' variable in
'shell_log_dump_entry' at 'if (rc < len) {` in optimized build.

This does not seem to be correct, but let's make it happy and
initialize 'rc'.

9 days agohw/drivers/lis2dh12: Fix build error
Andrzej Kaczmarek [Wed, 5 Dec 2018 16:20:00 +0000 (17:20 +0100)] 
hw/drivers/lis2dh12: Fix build error

9 days agohw/drivers/lps33hw: Add SPI support
Andrzej Kaczmarek [Tue, 4 Dec 2018 16:48:49 +0000 (17:48 +0100)] 
hw/drivers/lps33hw: Add SPI support

9 days agohw/drivers/lps33thw: Add proper I2C/SPI interface handling
Andrzej Kaczmarek [Tue, 4 Dec 2018 16:48:49 +0000 (17:48 +0100)] 
hw/drivers/lps33thw: Add proper I2C/SPI interface handling

9 days agohw/drivers/lis2dh12: Add proper I2C/SPI interface handling
Andrzej Kaczmarek [Tue, 4 Dec 2018 16:48:55 +0000 (17:48 +0100)] 
hw/drivers/lis2dh12: Add proper I2C/SPI interface handling

9 days agohw/drivers/lis2dw12: Add proper I2C/SPI interface handling
Andrzej Kaczmarek [Tue, 4 Dec 2018 16:48:49 +0000 (17:48 +0100)] 
hw/drivers/lis2dw12: Add proper I2C/SPI interface handling

9 days agohw/bus: Allow to override lock timeout per-node
Andrzej Kaczmarek [Mon, 3 Dec 2018 15:48:49 +0000 (16:48 +0100)] 
hw/bus: Allow to override lock timeout per-node

To save some space we may want to allow to disable per-node
configuration in future, but for now let's make it always enabled since
it only uses few extra bytes.

9 days agohw/bus: Enable bus driver statistics
Andrzej Kaczmarek [Mon, 3 Dec 2018 15:09:35 +0000 (16:09 +0100)] 
hw/bus: Enable bus driver statistics

This adds option to enable statistics for bus driver. There are two
types of statistics which can be used:
- per-device statistics (default)
- per-node statistics (optional)

For now cumulative number of reads, writes and errors for those are
counted as well as number of lock timeouts.

Stats for bus device are registered with bus device name prefixed by
"bd_" while bus nodes are prefixed with "bn_".

9 days agohw/bus: Fix lock timeout value usage
Andrzej Kaczmarek [Fri, 30 Nov 2018 10:30:58 +0000 (11:30 +0100)] 
hw/bus: Fix lock timeout value usage

9 days agohw/bus: Fix typo
Andrzej Kaczmarek [Fri, 30 Nov 2018 10:29:55 +0000 (11:29 +0100)] 
hw/bus: Fix typo

9 days agohw/drivers: Fix spiflash initialization function
Jerzy Kasenberg [Wed, 5 Dec 2018 11:21:39 +0000 (12:21 +0100)] 
hw/drivers: Fix spiflash initialization function

Nordic hal requrires SPI to be disabled before hal_spi_config() is called.
hal_spi_disable() is called just before hal_spi_config() to satisfy this.

9 days agosys/log: Add option to list available logs via cli
Andrzej Kaczmarek [Tue, 4 Dec 2018 16:03:15 +0000 (17:03 +0100)] 
sys/log: Add option to list available logs via cli

Use 'log -l' for this.

9 days agosys/log: Add option to dump only single log via cli
Andrzej Kaczmarek [Tue, 4 Dec 2018 16:01:55 +0000 (17:01 +0100)] 
sys/log: Add option to dump only single log via cli

Use 'log <logname>' for this.

9 days agosys/log: Add pretty-printing for CBOR log entries
Andrzej Kaczmarek [Tue, 4 Dec 2018 15:52:36 +0000 (16:52 +0100)] 
sys/log: Add pretty-printing for CBOR log entries

9 days agosys/log: Simplify log dump
Andrzej Kaczmarek [Tue, 4 Dec 2018 17:42:21 +0000 (18:42 +0100)] 
sys/log: Simplify log dump

Make common start/end for each log entry (i.e. timestamp + newline) and
also use console_write where possible to print simple strings instead of
going through formatting code.

10 days agoadp5061: Make charge_control dependency optional
Jerzy Kasenberg [Thu, 22 Nov 2018 13:56:24 +0000 (14:56 +0100)] 
adp5061: Make charge_control dependency optional

This change allows to disable all code related charge_control.
It will be possible to used ADP5061 API with alternative
charging manager, possibly reducing code size of application.

10 days agohw/mcu/nordic: Fix check for unresponsive TWI on read_op
Andrzej Kaczmarek [Fri, 30 Nov 2018 15:12:57 +0000 (16:12 +0100)] 
hw/mcu/nordic: Fix check for unresponsive TWI on read_op

When reading single byte on TWI it may happen that checks for SCL
line will start after this byte is received so SCL will never go to
low state because activity already happened on bus. To avoid this we'll
also check BB event which will also indicate that some activity on bus
happened.

For write ops there's no problem since after writing START and address
on bus controller will keep SCL low until we write 1st byte of data to
TXD.

10 days agohw/mcu/nordic: Rework workaround for unresponsive TWI
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:46:03 +0000 (17:46 +0100)] 
hw/mcu/nordic: Rework workaround for unresponsive TWI

Current workaround for unresponsive TWI will be triggered every time
there is operation timeout which has some drawbacks: it will be applied
to every operation that times out, it takes entire operation time to
recover and it will make operation fail so caller needs to retry.

It is possible to detect this condition and apply workaround quicker
without making operation fail by using simple hack: after triggering
START task SCL line should be pulled low to make START condition and
also when address is written. We can just wait a moment to see if SCL
is pulled low during this time - if not, restart controller and try
again.

This seems to work fine with LP5523 on the bus which can be used to
easily trigger this condition by sending reset command.

10 days agohw/mcu/nordic: Reset shorts on RX error
Andrzej Kaczmarek [Mon, 26 Nov 2018 10:10:35 +0000 (11:10 +0100)] 
hw/mcu/nordic: Reset shorts on  RX error

We manually trigger STOP task so there's no need for setting shorts
here. We should better just clear them instead.

10 days agohw/mcu/nordic: Remove unnecessary RESUME task trigger
Andrzej Kaczmarek [Mon, 26 Nov 2018 10:09:39 +0000 (11:09 +0100)] 
hw/mcu/nordic: Remove unnecessary RESUME task trigger

RESUME is used after SUSPEND, but we do not trigger SUSPEND anywhere so
this seems unnecessary.

10 days agosys/stats: Allow stats to be registered before sysinit
Andrzej Kaczmarek [Mon, 3 Dec 2018 15:12:33 +0000 (16:12 +0100)] 
sys/stats: Allow stats to be registered before sysinit

Some modules may want to register stats before sysinit, e.g. some BSP
can create os_dev in hal_bsp_init and corresponding driver will try to
register stats on device init which means before sysinit is called.

To make this possible, stats code was modified a bit so it will
automatically initialize itself on 1st register call in case it was not
yet initialized via sysinit. This is possible since it does not have any
extra dependencies.

To avoid using some new global variables which hold initialization state
we can just check stat for number of registered stats - it will be
non-zero after initialization since "stat" is always registered.

10 days agonrf52; create a linker script for compiling apps which are loaded to RAM,
Marko Kiiskila [Tue, 4 Dec 2018 09:36:46 +0000 (11:36 +0200)] 
nrf52; create a linker script for compiling apps which are loaded to RAM,
instead of flash. Show a sample on how to use this with one BSP.

11 days agohw/drivers/bmp280: Fix invalid includes
Andrzej Kaczmarek [Mon, 3 Dec 2018 15:12:11 +0000 (16:12 +0100)] 
hw/drivers/bmp280: Fix invalid includes

11 days agoadding battery polling rate 0 to stop polling (#1545)
JustineKH [Mon, 3 Dec 2018 21:20:02 +0000 (13:20 -0800)] 
adding battery polling rate 0 to stop polling (#1545)

* adding polling rate 0 to stop polling

* remove extra parentheses

* set b_poll_rate to 0 if polling stopped

11 days agohw/drivers: Add bus driver support to LP5523
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:42:28 +0000 (17:42 +0100)] 
hw/drivers: Add bus driver support to LP5523

11 days agohw/drivers/led: Add bus driver support
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:42:18 +0000 (17:42 +0100)] 
hw/drivers/led: Add bus driver support

11 days agohw/drivers: Add bus driver support to BQ27Z561
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:41:00 +0000 (17:41 +0100)] 
hw/drivers: Add bus driver support to BQ27Z561

11 days agohw/battery: Add bus driver support
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:43:02 +0000 (17:43 +0100)] 
hw/battery: Add bus driver support

11 days agohw/drivers: Add bus driver support to ADP5061
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:40:23 +0000 (17:40 +0100)] 
hw/drivers: Add bus driver support to ADP5061

11 days agohw/charge-control: Add bus driver support
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:40:43 +0000 (17:40 +0100)] 
hw/charge-control: Add bus driver support

11 days agohw/drivers: Add bus driver support to BMA253
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:26:32 +0000 (17:26 +0100)] 
hw/drivers: Add bus driver support to BMA253

11 days agohw/drivers: Add bus driver support to BMP280
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:26:23 +0000 (17:26 +0100)] 
hw/drivers: Add bus driver support to BMP280

11 days agohw/drivers: Add bus driver support to LPS33THW
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:26:08 +0000 (17:26 +0100)] 
hw/drivers: Add bus driver support to LPS33THW

11 days agohw/drivers: Add bus driver support to LPS33HW
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:26:02 +0000 (17:26 +0100)] 
hw/drivers: Add bus driver support to LPS33HW

11 days agohw/drivers: Add bus driver support to MS5840
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:25:45 +0000 (17:25 +0100)] 
hw/drivers: Add bus driver support to MS5840

11 days agohw/drivers: Add bus driver support to MS5837
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:25:40 +0000 (17:25 +0100)] 
hw/drivers: Add bus driver support to MS5837

11 days agohw/drivers: Add bus driver support to LIS2DW12
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:25:25 +0000 (17:25 +0100)] 
hw/drivers: Add bus driver support to LIS2DW12

11 days agohw/drivers: Add bus driver support to LIS2DH12
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:25:20 +0000 (17:25 +0100)] 
hw/drivers: Add bus driver support to LIS2DH12

11 days agohw/sensor: Refactor sensor_itf with bus driver
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:21:38 +0000 (17:21 +0100)] 
hw/sensor: Refactor sensor_itf with bus driver

Initial idea of retrieving os_dev from sensor_itf when using bus driver
seems to be a bad idea since as it turns out there is some exsising
code which uses "loose" sensor_itf structures to access sensors.

To fix this, let's have os_dev pointer as a part of sensor_itf. It
should be initialized to point to os_dev structure for sensor and then
it can be used as usual.

2 weeks agohw/bus/spi: Make sure node config is set before init
Andrzej Kaczmarek [Mon, 26 Nov 2018 10:40:30 +0000 (11:40 +0100)] 
hw/bus/spi: Make sure node config is set before init

2 weeks agohw/bus/i2c: Make sure node config is set before init
Andrzej Kaczmarek [Mon, 26 Nov 2018 10:40:14 +0000 (11:40 +0100)] 
hw/bus/i2c: Make sure node config is set before init

2 weeks agohw/bus/i2c: Add I2C HAL errors translation
Andrzej Kaczmarek [Mon, 26 Nov 2018 14:36:21 +0000 (15:36 +0100)] 
hw/bus/i2c: Add I2C HAL errors translation

2 weeks agohw/bus/i2c: Fix operation timeouts
Andrzej Kaczmarek [Mon, 26 Nov 2018 11:19:12 +0000 (12:19 +0100)] 
hw/bus/i2c: Fix operation timeouts

These are specified in ticks in HAL already.

2 weeks agohw/bus/i2c: Delay controller enable
Andrzej Kaczmarek [Mon, 26 Nov 2018 10:37:45 +0000 (11:37 +0100)] 
hw/bus/i2c: Delay controller enable

Controller will be enabled when used for first time.

2 weeks agohw/bus/i2c: Set I2C pins to high state on startup
Andrzej Kaczmarek [Mon, 26 Nov 2018 10:37:10 +0000 (11:37 +0100)] 
hw/bus/i2c: Set I2C pins to high state on startup

This is just to ensure they are in high state until controller is enabled.

2 weeks agohw/bus/i2c: Fix node debug poisoning
Andrzej Kaczmarek [Mon, 26 Nov 2018 10:35:58 +0000 (11:35 +0100)] 
hw/bus/i2c: Fix node debug poisoning

2 weeks agohw/bus: Add missing unlock when configuration failed
Andrzej Kaczmarek [Mon, 26 Nov 2018 11:18:05 +0000 (12:18 +0100)] 
hw/bus: Add missing unlock when configuration failed

2 weeks agohw/bus: Allow to configure default transaction timeout
Andrzej Kaczmarek [Mon, 26 Nov 2018 13:50:30 +0000 (14:50 +0100)] 
hw/bus: Allow to configure default transaction timeout

This is used when using simple transaction APIs which do not specify
timeouts explicitly.

2 weeks agohw/bus: Make bus lock time configurable
Andrzej Kaczmarek [Mon, 26 Nov 2018 11:15:18 +0000 (12:15 +0100)] 
hw/bus: Make bus lock time configurable

Bus lock time is now configurable. There's global default timeout but
it will be possible to configure it per-node if necessary (not yet
implemented).

Also, when locking manually caller can use predefined symbol instead of
actual timeout value and default timeout will be used.

2 weeks agohw/mcu/nordic: Fix bus driver headers
Andrzej Kaczmarek [Tue, 27 Nov 2018 14:07:23 +0000 (15:07 +0100)] 
hw/mcu/nordic: Fix bus driver headers

2 weeks agohw/mcu/nordic: Enable all available buses for bus driver
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:20:56 +0000 (17:20 +0100)] 
hw/mcu/nordic: Enable all available buses for bus driver

2 weeks agohw/mcu/nordic: Update support for 380KHz I2C
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:43:59 +0000 (17:43 +0100)] 
hw/mcu/nordic: Update support for 380KHz I2C

2 weeks agosys/defs: Add new error code
Andrzej Kaczmarek [Mon, 26 Nov 2018 14:35:33 +0000 (15:35 +0100)] 
sys/defs: Add new error code

This is used to indicate I/O error caused by remote side. For example,
in bus driver this will indicate data NAK while existing SYS_EIO can be
used to indicate I/O errors on local side.

2 weeks agoFix QSPI parameter error on erase command
Fabio Utzig [Wed, 28 Nov 2018 14:51:49 +0000 (12:51 -0200)] 
Fix QSPI parameter error on erase command

According to NRF52840 PS, the erase operation on QSPI only accepts 4k,
64kb or all memory as parameters, which are encoded in the 2 LSb
(QSPI 52.10.12). This makes the erase command call 4KB erase for each
sector inside the user defined `QSPI_FLASH_SECTOR_SIZE`.

Signed-off-by: Fabio Utzig <utzig@apache.org>
2 weeks agoFix typo
Fabio Utzig [Wed, 28 Nov 2018 14:51:24 +0000 (12:51 -0200)] 
Fix typo

2 weeks agoMerge pull request #1539 from kasjer/kasjer/spiflash-thread-safe
kasjer [Thu, 29 Nov 2018 13:10:47 +0000 (14:10 +0100)] 
Merge pull request #1539 from kasjer/kasjer/spiflash-thread-safe

spiflash: Make spiflash thread safe

2 weeks agospiflash: Make spiflash thread safe 1539/head
Jerzy Kasenberg [Thu, 29 Nov 2018 11:07:00 +0000 (12:07 +0100)] 
spiflash: Make spiflash thread safe

If several task would try to use spiflash at the same time they
could get wrong result and even deadlock waiting for some SPI
state that would not happen.
Adding mutex to most of the functions makes spiflash usable from
multiple tasks.
For boot loader sake spiflash can be built without locking.

2 weeks agoMerge pull request #1537 from mkiiskila/newtmgr_fix_crash
mkiiskila [Thu, 29 Nov 2018 08:43:34 +0000 (10:43 +0200)] 
Merge pull request #1537 from mkiiskila/newtmgr_fix_crash

newtmgr; crashes with invalid nh_len.

2 weeks agosys/stats: Fix build error due to circular #include
Andrzej Kaczmarek [Fri, 23 Nov 2018 16:29:26 +0000 (17:29 +0100)] 
sys/stats: Fix build error due to circular #include

There's possible cicrular #include in stats.h which makes build fail:
  something.c -> stats/stats.h
  stats/stats.h -> os/mynewt.h
  os/mynewt.h with NEWT_FEATURE_LOGCFG -> logcfg/logcfg.h
  non-empty logcfg/logcfg.h -> modlog/modlog.h
  modlog/modlog.h -> log/log.h

log/log.h with LOG_STATS uses stats macros and tries to include stats.h
properly, but since it's implicitly included from stats.h these macros
are not yet defined thus there are a lot of build errors in different
files.

The solution is to include os/os.h since this is what stats.h really
needs.

2 weeks agonewtmgr; crashes with invalid nh_len. Fix by removing ability to 1537/head
Marko Kiiskila [Tue, 27 Nov 2018 13:45:56 +0000 (15:45 +0200)] 
newtmgr; crashes with invalid nh_len. Fix by removing ability to
handle multiple incoming requests in a single message, as that is
not being used.

2 weeks agohw/bus: Make proper fix for bus driver enable...
Andrzej Kaczmarek [Mon, 26 Nov 2018 13:23:49 +0000 (14:23 +0100)] 
hw/bus: Make proper fix for bus driver enable...

My previous patch was just plain stupid since bus driver is enabled by
package dependencies, not by BUS_DRIVER_PRESENT which shall always be
set to 1...

So, in order to enable bus driver one has to pull proper dependencies
and other packages will just use it.

2 weeks agohw/bus: Disable bus driver by default
Andrzej Kaczmarek [Mon, 26 Nov 2018 13:03:59 +0000 (14:03 +0100)] 
hw/bus: Disable bus driver by default

3 weeks agohw/bus: Fix node debug
Andrzej Kaczmarek [Mon, 19 Nov 2018 16:43:37 +0000 (17:43 +0100)] 
hw/bus: Fix node debug

3 weeks agoapps/bus_test: Remove BME280 sample node
Andrzej Kaczmarek [Mon, 19 Nov 2018 14:04:27 +0000 (15:04 +0100)] 
apps/bus_test: Remove BME280 sample node

BME280 sample node used driver from Bosch which I'm not sure if we can
include in Mynewt repository. Let's remove it - we have sample node for
LIS2DH written from scratch and BME280 is supported via sensors
interface.

3 weeks agoapps/bus_test: Adjust to latest changes in BME280
Andrzej Kaczmarek [Mon, 19 Nov 2018 13:56:10 +0000 (14:56 +0100)] 
apps/bus_test: Adjust to latest changes in BME280

3 weeks agohw/drivers/bme280: Adjust to latest changes in bus driver
Andrzej Kaczmarek [Mon, 19 Nov 2018 13:55:15 +0000 (14:55 +0100)] 
hw/drivers/bme280: Adjust to latest changes in bus driver

3 weeks agohw/bus: Update locking API
Andrzej Kaczmarek [Mon, 19 Nov 2018 13:35:25 +0000 (14:35 +0100)] 
hw/bus: Update locking API

Bus locking APIs names were changed to more friendly bus_node_lock()
and bus_node_unlock().

Also locking bus will automatically configure bus for given node since
we lock the bus in order to talk to given node so can have extra call
here.

bus_node_unlock() will not return an error since it's a bit useless -
probably no one cares about it and it can only fail if things are really
broken already, so we'll just assert internally to aid debugging.

3 weeks agohw/bus: Add init argument to node creation function
Andrzej Kaczmarek [Mon, 19 Nov 2018 10:40:44 +0000 (11:40 +0100)] 
hw/bus: Add init argument to node creation function

Since bus nodes are os_dev, they may need some extra argument to be
passed in init function. However, os_dev custom argument is already
used by bus driver thus we need other way to pass driver-specific arg.

To make this possible, bus_XXX_node_create functions have extra argument
which is stored inside node and passed to init function later.

Hack warning: to avoid using extra 4 bytes of memory for each node to
store extra arg for a brief time we'll just reuse the same pointer (via
union) as used by parent_bus. It's ok to make it like this since we need
to store arg until init function is called and also parent_bus is used
1st time in init function so we can just "exchange" contents there.