Commit Graph

95 Commits (afe8834bb8aa0d094cf629b9c0b11030f48af599)

Author SHA1 Message Date
deepikabhavnani afe8834bb8 CRC class implementation
CRC class `MbedCRC.h` is templated class created to support hardware/software
CRCs. Default CRC will be hardware CRC when support for HAL is available.

Polynomial tables are available for 8/16 bit CCITT, 7/16 bit for SD card and
32-bit ANSI. Polynomial table implementation will be used if Hardware CRC is
not available.

In case device does not have hardware CRC and polynomial table is not supported,
CRC is still available and is computed runtime bit by bit for all data input.
2018-01-24 13:26:41 -06:00
Kevin Bracey 9678c8052e Make UARTSerial send all data when blocking
Previously, write() was somewhat soft - it only ever made one attempt to
wait for buffer space, so it would take as much data as would fit in the
buffer in one call.

This is not the intent of a POSIX filehandle write. It should try to
send everything if blocking, and only send less if interrupted by a
signal:

 - If the O_NONBLOCK flag is clear, write() shall block the calling
   thread until the data can be accepted.

 - If the O_NONBLOCK flag is set, write() shall not block the thread.
   If some data can be written without blocking the thread, write()
   shall write what it can and return the number of bytes written.
   Otherwise, it shall return -1 and set errno to [EAGAIN].

This "send all" behaviour is of slightly limited usefulness in POSIX, as
you still usually have to worry about the interruption possibility:

  - If write() is interrupted by a signal before it writes any data, it
    shall return -1 with errno set to [EINTR].

  - If write() is interrupted by a signal after it successfully writes
    some data, it shall return the number of bytes written.

But as mbed OS does not have the possibility of signal interruption, if we
strengthen write to write everything, we can make applications' lives
easier - they can just do "write(large amount)" confident that it will
all go in one call (if no errors).

So, rework to make multiple writes to the buffer, blocking as necessary,
until all data is written.

This change does not apply to read(), which is correct in only blocking until
some data is available:

 - If O_NONBLOCK is set, read() shall return -1 and set errno to [EAGAIN].

 - If O_NONBLOCK is clear, read() shall block the calling thread until some
   data becomes available.

 - The use of the O_NONBLOCK flag has no effect if there is some data
   available.
2017-11-21 09:51:36 +02:00
Martin Kojtal fbd9e7eaf2
Merge pull request #5372 from SenRamakri/sen_PlatformDoxygenUpdates
Doxygen comments fixes
2017-11-09 16:38:45 +00:00
Jimmy Brisson 6912a9dc0d
Merge pull request #5393 from c1728p9/call_chain_deprecation
Deprecate CallChain and InterruptManager
2017-11-02 11:10:52 -05:00
Jimmy Brisson 5768693e0d
Merge pull request #5088 from kjbracey-arm/uartserial_flow
UARTSerial: add flow control and format APIs
2017-11-02 10:37:40 -05:00
Russ Butler 8deef6a699 Deprecate InterruptManager
This patch deprecates the InterruptManager class since it is an
internal API (not in mbed.h) which is not being used anywhere in
the codebase.
2017-10-27 14:47:55 -05:00
Senthil Ramakrishnan 3ad298488c Doxygen comment updates and fixes 2017-10-26 15:36:26 -05:00
Jimmy Brisson 493e3788e3 Merge pull request #5216 from kjbracey-arm/UARTSerial_wait
Avoid wait_ms() spin
2017-10-13 09:20:41 -05:00
Jimmy Brisson 4dff32ab5a Merge pull request #5220 from c1728p9/sleep_lock_fixes
Fix deep sleep lock bugs
2017-10-05 10:03:44 -05:00
Russ Butler 32303a9130 Fix sleep lock underflow in LowPowerTimer
If a LowPowerTimer is started and then goes out of scope then a
deep sleep lock underflow can occur. This is because the
the variable '_lock_deepsleep' is checked when starting the timer
but is not checked in the destructor, which unconditionally releases
the deep sleep lock.
2017-10-02 19:32:20 -05:00
Russ Butler f854f3e6db Properly unlock sleep in destructor of drivers
Unlock sleep in CAN and SerialBase. This prevents deep sleep from
staying locked if these objects are destroyed without first clearing
the callbacks.
2017-10-02 11:35:08 -05:00
Russ Butler 87b151c8a0 Protect Ticker attach with a critical section
Add a critical section to attach_us so setting _function and
locking deep sleep are done atomically.
2017-10-02 11:35:05 -05:00
Jimmy Brisson bb61b42fba Merge pull request #5148 from mprse/fix_enable_deepsleep_for_lp_timer
Enable deepsleep for LowPowerXXX objects
2017-09-28 14:11:40 -05:00
Jimmy Brisson f7cca5b023 Merge pull request #5066 from kjbracey-arm/uartserial_readable
UARTSerial: Avoid readable() ambiguity
2017-09-28 14:08:43 -05:00
Jimmy Brisson 6177c01c92 Merge pull request #5062 from 0xc0170/fix_interruptin_callback
InterruptIn: Use NULL callback by default
2017-09-28 14:04:28 -05:00
Jimmy Brisson f57f0d4631 Merge pull request #5045 from maciejbocianski/ticker_fix
Ticker class description update - small interval warning
2017-09-28 14:01:36 -05:00
Kevin Bracey b18332cb4d Avoid wait_ms() spin
System's wait_ms() spins to achieve a precise delay - we don't want this.
Call Thread::wait directly.
2017-09-28 10:45:57 +03:00
Jimmy Brisson ddb6b66674 Merge pull request #5177 from 0xc0170/fix_pwmout_sleep
PWMOut: lock deesleep addition
2017-09-27 09:09:36 -05:00
Jimmy Brisson 8508d26ea2 Merge pull request #5095 from c1728p9/timer_sleep_lock_fix
Release deep sleep lock in destructor of Timer class
2017-09-27 09:09:07 -05:00
Martin Kojtal 5a6aee43eb PWMOut: lock deesleep addition
As PWMOut in most cases depend on high speed freq clock, it should lock deepsleep while active.
2017-09-22 15:08:02 +01:00
Martin Kojtal 26f9144c45 Merge pull request #5000 from 0xc0170/fix_flash_page_doc
flash: add note about program size
2017-09-22 11:28:54 +01:00
Przemyslaw Stekiel 10ee2fa935 Enable deepsleep for low power Ticker and low power Timer.
Fix for issue #5076.
2017-09-22 08:30:17 +02:00
Maciej Bocianski 19ee9c1b43 Ticker class description update - small interval warning 2017-09-18 11:39:06 +02:00
Russ Butler f766f7d421 Release deep sleep lock in destructor of Timer class
Release the deep sleep lock when running instances of the Timer class
are deleted. This ensures that deep sleep locks are properly released
by the Timer class.
2017-09-13 20:10:06 -05:00
Kevin Bracey c262a035f6 UARTSerial: add flow control and format APIs
Add passthrough APIs to enable the flow control and format methods from
SerialBase to be accessed.

Modify the RX data pump so it stops reading data and disables the IRQ
when the buffer is full, to allow UART automatic flow control to work.

In principle it would also be possible as a future enhancement to
provide XON/XOFF flow control, or manual RTS/CTS control using GPIO, but
this commit at least restores the functionality present in Serial,
SerialBase and RawSerial that was missing in UARTSerial.
2017-09-13 15:27:13 +03:00
Kevin Bracey 3b9f9bb564 UARTSerial: Avoid readable() ambiguity
UARTSerial inherits both FileHandle::readable() [public] and
SerialBase::readable() [private], so calling readable() on a UARTSerial
object produces an ambiguous member error.

Add using declarations to direct towards the FileHandle versions of
readable and writable.

There's currently no ambiguity for writable, as SerialBase uses the
spelling 'writeable', but add a using directive for that anyway, in case
SerialBase gains 'writable' later.
2017-09-12 11:36:57 +03:00
Martin Kojtal 78718910d3 Ticker: invoke _function only if attached 2017-09-09 20:42:57 -05:00
Martin Kojtal d3cc0038d3 InterruptIn: callback to NULL clean-up
As we can check if callback was attached, we use NULL assigment.
2017-09-09 09:48:10 +02:00
Martin Kojtal f6c34a2303 SerialBase and CAN: fix Callbacks comparision
As Callback currently does not have fully functional comparision (see #5017),
we workaround by doing null check.
2017-09-07 15:35:08 +01:00
Martin Kojtal 5b33d2583d drivers: fix attach sleep locking
attach/detach can be multiple invoked. Therefore lock/unlock deep sleep
only for the very first time it is invoked (when callbacks
are actually changed).
2017-09-07 15:35:06 +01:00
Martin Kojtal e57f0bcd26 Drivers: locking sleep fix for attach/detach
As attach provides API to change a callback, lock/unlock should
only happen if we are doing the first/last callback (start-stop).
2017-09-07 15:35:05 +01:00
Martin Kojtal e6d8a9a8a4 Drivers with interrupts: adding sleep deep locking
Any driver with attach or async API should be considered for deep sleep.

Add locking to those that require in most cases
high-frequency clocks:

- CAN
- I2C
- SPI
- Serial
- Ticker/Timeout/Timer
2017-09-07 15:35:05 +01:00
Martin Kojtal 3f58d3ef48 flash: add note about program size
Program size - the writable page size that flash controller supports.
Plus fix program page description - multiple pages program
2017-09-06 07:54:18 +01:00
Steve Cartmell cdca13798b Fix compiler warning for deprecated function call
Replaced the deprecated function call .attach() with an assignment
2017-08-14 12:10:31 +01:00
Jimmy Brisson 1f94ede86c Merge pull request #4744 from deepikabhavnani/spi_issue_4743
Allow user to set default transfer byte for block read
2017-07-24 14:45:30 -05:00
Jimmy Brisson c1e455c594 Merge pull request #4615 from u-blox/uart_serial_set_baud
Add set_baud() method to UARTSerial().
2017-07-24 10:50:43 -05:00
Deepika 1b797e9081 Closed review comments
1. Doxygen and Grammar related
2. Change dummy to spi_fill
3. Remove NXP driver and add default loop in spi block read (same as all
other drivers)
2017-07-21 09:46:22 -05:00
Deepika fd43405ffe Allow user to set dummy tranfer byte for block read 2017-07-11 15:46:32 -05:00
Jimmy Brisson efc5c47e55 Merge pull request #4720 from marcuschangarm/flashiap_read
FlashIAP: Add explicit read function to flash_api.h
2017-07-07 17:47:49 -05:00
Anna Bridge 4890261c98 Merge pull request #4548 from deepikabhavnani/os_warn
Resolve Warnings for mbed-os-examples
2017-07-07 12:43:27 +01:00
Anna Bridge 28df3aeb87 Merge pull request #4635 from deepikabhavnani/spi_acquire
_acquire() function added & removed duplication in format/freq calls
2017-07-07 12:41:34 +01:00
Marcus Chang abca2ca48b FlashIAP: Add explicit read function to flash_api.h
On some platforms, the in-application memory is not memory mapped
and therefore cannot be accessed using memcpy.

The flash_read function added to flash_api.h (with a weak
implementation using memcpy in mbed_flash_api.c) can be used for
reading data from areas that are not memory mapped.
2017-07-06 18:53:32 +01:00
Deepika 56f3868e48 Corrected typo 2017-06-29 09:09:53 -05:00
Deepika d22d8af2a2 Corrected handling of format/frequency 2017-06-26 14:34:13 -05:00
Deepika de89be35f8 _acquire() function added & no duplication in format/freq calls
1. Private _acquire() function is added to avoid multiple locking/unlocking
2. format and frequency functions updated to use appropriate function calls
instead of a aquire()
2017-06-26 14:06:16 -05:00
Jimmy Brisson f6d0c29b95 Merge pull request #4594 from pan-/non_copyable
Introduce mbed::NonCopyable traits
2017-06-26 10:29:35 -05:00
Rob Meades 89ddfc5beb Add set_baud() method to UARTSerial(). 2017-06-22 12:26:48 +01:00
Vincent Coubard 3f388ca2a8 drivers: Mark non identity types as non copyable with the NonCopyable traits.
Classes changed: CAN, Ethernet, FlashIAP, I2C, InterruptIn, LowPowerTicker, LowPowerTimeout, LowPowerTimer, RawSerial, Serial, SerialBase, SPI, SPISlave, Ticker, Timeout, Timer, TimerEvent and UARTSerial.
2017-06-20 16:23:46 +01:00
Vincent Coubard 7f5b992064 drivers: Replace private copy constructor and Copy assignement operator by NonCopyable traits.
Modified classes are: BusIn, BusOut, BusInOut and InterruptManager.
2017-06-20 16:23:46 +01:00
Deepika 1ece5ff8a8 Using size_t instead of integer type to resolve warning: comparison between signed and unsigned integer expressions 2017-06-15 14:59:24 -05:00