mirror of https://github.com/ARMmbed/mbed-os.git
Merge branch 'master' into STM_sha256_F439ZI
commit
ec72ac0a28
|
@ -13,6 +13,11 @@ script:
|
|||
# not start with lib
|
||||
- |
|
||||
find "(" -name "*.a" -or -name "*.ar" ")" -and -not -name "lib*" | tee BUILD/badlibs | sed -e "s/^/Bad library name found: /" && [ ! -s BUILD/badlibs ]
|
||||
# Assert that all assebler files are named correctly
|
||||
# The strange command below asserts that there are exactly 0 libraries that do
|
||||
# end with .s
|
||||
- |
|
||||
find -name "*.s" | tee BUILD/badasm | sed -e "s/^/Bad Assembler file name found: /" && [ ! -s BUILD/badasm ]
|
||||
- make -C events/equeue test clean
|
||||
- PYTHONPATH=. python tools/test/config_test/config_test.py
|
||||
- PYTHONPATH=. python tools/test/build_api/build_api_test.py
|
||||
|
|
|
@ -5,7 +5,7 @@ All changes in code base should originate from GitHub Issues and take advantage
|
|||
Guidelines from this document are created to help new and existing contributors understand process workflow and align to project rules before pull request is submitted. It explains how a participant should do things like format code, test fixes, and submit patches.
|
||||
|
||||
## Where to get more information?
|
||||
You can read more on our [documentation page](https://docs.mbed.com/).
|
||||
You can read more on our [documentation page](https://docs.mbed.com/docs/mbed-os-handbook/en/latest/cont/contributing/).
|
||||
|
||||
# How to contribute
|
||||
We really appreciate your contributions! We are Open Source project and we need your help. We want to keep it as easy as possible to contribute changes that get things working in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
EXTERN exit
|
||||
EXTERN __iar_dynamic_initialization
|
||||
EXTERN mbed_sdk_init
|
||||
EXTERN mbed_main
|
||||
EXTERN SystemInit
|
||||
|
||||
THUMB
|
||||
|
@ -87,6 +88,10 @@ _call_main:
|
|||
FUNCALL __cmain, __iar_argc_argv
|
||||
BL __iar_argc_argv ; Maybe setup command line
|
||||
|
||||
MOVS r0,#0 ; No parameters
|
||||
FUNCALL __cmain, mbed_main
|
||||
BL mbed_main
|
||||
|
||||
FUNCALL __cmain, main
|
||||
BL main
|
||||
_main:
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "platform/platform.h"
|
||||
#include "drivers/DigitalIn.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -28,7 +29,7 @@ namespace mbed {
|
|||
* @note Synchronization level: Thread safe
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class BusIn {
|
||||
class BusIn : private NonCopyable<BusIn> {
|
||||
|
||||
public:
|
||||
/* Group: Configuration Methods */
|
||||
|
@ -115,12 +116,9 @@ protected:
|
|||
|
||||
PlatformMutex _mutex;
|
||||
|
||||
/* disallow copy constructor and assignment operators */
|
||||
private:
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
BusIn(const BusIn&);
|
||||
BusIn & operator = (const BusIn&);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "drivers/DigitalInOut.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -27,7 +28,7 @@ namespace mbed {
|
|||
* @note Synchronization level: Thread safe
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class BusInOut {
|
||||
class BusInOut : private NonCopyable<BusInOut> {
|
||||
|
||||
public:
|
||||
|
||||
|
@ -135,11 +136,6 @@ protected:
|
|||
int _nc_mask;
|
||||
|
||||
PlatformMutex _mutex;
|
||||
|
||||
/* disallow copy constructor and assignment operators */
|
||||
private:
|
||||
BusInOut(const BusInOut&);
|
||||
BusInOut & operator = (const BusInOut&);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "drivers/DigitalOut.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -25,7 +26,7 @@ namespace mbed {
|
|||
/** A digital output bus, used for setting the state of a collection of pins
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class BusOut {
|
||||
class BusOut : private NonCopyable<BusOut> {
|
||||
|
||||
public:
|
||||
|
||||
|
@ -119,11 +120,6 @@ protected:
|
|||
int _nc_mask;
|
||||
|
||||
PlatformMutex _mutex;
|
||||
|
||||
/* disallow copy constructor and assignment operators */
|
||||
private:
|
||||
BusOut(const BusOut&);
|
||||
BusOut & operator = (const BusOut&);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "hal/can_api.h"
|
||||
#include "platform/Callback.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -78,7 +79,7 @@ public:
|
|||
/** A can bus client, used for communicating with can devices
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class CAN {
|
||||
class CAN : private NonCopyable<CAN> {
|
||||
|
||||
public:
|
||||
/** Creates an CAN interface connected to specific pins.
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define MBED_ETHERNET_H
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
#if defined (DEVICE_ETHERNET) || defined(DOXYGEN_ONLY)
|
||||
|
||||
|
@ -54,7 +55,7 @@ namespace mbed {
|
|||
* @endcode
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class Ethernet {
|
||||
class Ethernet : private NonCopyable<Ethernet> {
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "flash_api.h"
|
||||
#include "platform/SingletonPtr.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
|
||||
|
@ -37,7 +38,7 @@ namespace mbed {
|
|||
* @note Synchronization level: Thread safe
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class FlashIAP {
|
||||
class FlashIAP : private NonCopyable<FlashIAP> {
|
||||
public:
|
||||
FlashIAP();
|
||||
~FlashIAP();
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "hal/i2c_api.h"
|
||||
#include "platform/SingletonPtr.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
#if DEVICE_I2C_ASYNCH
|
||||
#include "platform/CThunk.h"
|
||||
|
@ -53,7 +54,7 @@ namespace mbed {
|
|||
* @endcode
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class I2C {
|
||||
class I2C : private NonCopyable<I2C> {
|
||||
|
||||
public:
|
||||
enum RxStatus {
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "platform/Callback.h"
|
||||
#include "platform/mbed_critical.h"
|
||||
#include "platform/mbed_toolchain.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -56,7 +57,7 @@ namespace mbed {
|
|||
* @endcode
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class InterruptIn {
|
||||
class InterruptIn : private NonCopyable<InterruptIn> {
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "cmsis.h"
|
||||
#include "platform/CallChain.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
#include <string.h>
|
||||
|
||||
namespace mbed {
|
||||
|
@ -53,7 +54,7 @@ namespace mbed {
|
|||
* @endcode
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class InterruptManager {
|
||||
class InterruptManager : private NonCopyable<InterruptManager> {
|
||||
public:
|
||||
/** Get the instance of InterruptManager Class
|
||||
*
|
||||
|
@ -138,12 +139,6 @@ private:
|
|||
void lock();
|
||||
void unlock();
|
||||
|
||||
// We declare the copy contructor and the assignment operator, but we don't
|
||||
// implement them. This way, if someone tries to copy/assign our instance,
|
||||
// he will get an error at compile time.
|
||||
InterruptManager(const InterruptManager&);
|
||||
InterruptManager& operator =(const InterruptManager&);
|
||||
|
||||
template<typename T>
|
||||
pFunctionPointer_t add_common(T *tptr, void (T::*mptr)(void), IRQn_Type irq, bool front=false) {
|
||||
_mutex.lock();
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "platform/platform.h"
|
||||
#include "drivers/Ticker.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
#if defined (DEVICE_LOWPOWERTIMER) || defined(DOXYGEN_ONLY)
|
||||
|
||||
|
@ -31,7 +32,7 @@ namespace mbed {
|
|||
* @note Synchronization level: Interrupt safe
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class LowPowerTicker : public Ticker {
|
||||
class LowPowerTicker : public Ticker, private NonCopyable<LowPowerTicker> {
|
||||
|
||||
public:
|
||||
LowPowerTicker() : Ticker(get_lp_ticker_data()) {
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "hal/lp_ticker_api.h"
|
||||
#include "drivers/LowPowerTicker.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -31,7 +32,7 @@ namespace mbed {
|
|||
* @note Synchronization level: Interrupt safe
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class LowPowerTimeout : public LowPowerTicker {
|
||||
class LowPowerTimeout : public LowPowerTicker, private NonCopyable<LowPowerTimeout> {
|
||||
|
||||
private:
|
||||
virtual void handler(void) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "platform/platform.h"
|
||||
#include "drivers/Timer.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
#if defined (DEVICE_LOWPOWERTIMER) || defined(DOXYGEN_ONLY)
|
||||
|
||||
|
@ -31,7 +32,7 @@ namespace mbed {
|
|||
* @note Synchronization level: Interrupt safe
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class LowPowerTimer : public Timer {
|
||||
class LowPowerTimer : public Timer, private NonCopyable<LowPowerTimer> {
|
||||
|
||||
public:
|
||||
LowPowerTimer() : Timer(get_lp_ticker_data()) {
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "drivers/SerialBase.h"
|
||||
#include "hal/serial_api.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -49,7 +50,7 @@ namespace mbed {
|
|||
* @endcode
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class RawSerial: public SerialBase {
|
||||
class RawSerial: public SerialBase, private NonCopyable<RawSerial> {
|
||||
|
||||
public:
|
||||
/** Create a RawSerial port, connected to the specified transmit and receive pins, with the specified baud.
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "platform/PlatformMutex.h"
|
||||
#include "hal/spi_api.h"
|
||||
#include "platform/SingletonPtr.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
#if DEVICE_SPI_ASYNCH
|
||||
#include "platform/CThunk.h"
|
||||
|
@ -72,7 +73,7 @@ namespace mbed {
|
|||
* @endcode
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class SPI {
|
||||
class SPI : private NonCopyable<SPI> {
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define MBED_SPISLAVE_H
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
#if defined (DEVICE_SPISLAVE) || defined(DOXYGEN_ONLY)
|
||||
|
||||
|
@ -52,7 +53,7 @@ namespace mbed {
|
|||
* @endcode
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class SPISlave {
|
||||
class SPISlave : private NonCopyable<SPISlave> {
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "SerialBase.h"
|
||||
#include "PlatformMutex.h"
|
||||
#include "serial_api.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -49,7 +50,7 @@ namespace mbed {
|
|||
* @endcode
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class Serial : public SerialBase, public Stream {
|
||||
class Serial : public SerialBase, public Stream, private NonCopyable<Serial> {
|
||||
|
||||
public:
|
||||
#if DEVICE_SERIAL_ASYNCH
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include "Callback.h"
|
||||
#include "serial_api.h"
|
||||
#include "mbed_toolchain.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
#if DEVICE_SERIAL_ASYNCH
|
||||
#include "CThunk.h"
|
||||
|
@ -38,7 +39,7 @@ namespace mbed {
|
|||
* @note Synchronization level: Set by subclass
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class SerialBase {
|
||||
class SerialBase : private NonCopyable<SerialBase> {
|
||||
|
||||
public:
|
||||
/** Set the baud rate of the serial port
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "drivers/TimerEvent.h"
|
||||
#include "platform/Callback.h"
|
||||
#include "platform/mbed_toolchain.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -59,7 +60,7 @@ namespace mbed {
|
|||
* @endcode
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class Ticker : public TimerEvent {
|
||||
class Ticker : public TimerEvent, private NonCopyable<Ticker> {
|
||||
|
||||
public:
|
||||
Ticker() : TimerEvent() {
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define MBED_TIMEOUT_H
|
||||
|
||||
#include "drivers/Ticker.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -52,7 +53,7 @@ namespace mbed {
|
|||
* @endcode
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class Timeout : public Ticker {
|
||||
class Timeout : public Ticker, private NonCopyable<Timeout> {
|
||||
|
||||
protected:
|
||||
virtual void handler();
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "platform/platform.h"
|
||||
#include "hal/ticker_api.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -46,7 +47,7 @@ namespace mbed {
|
|||
* @endcode
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class Timer {
|
||||
class Timer : private NonCopyable<Timer> {
|
||||
|
||||
public:
|
||||
Timer();
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "hal/ticker_api.h"
|
||||
#include "hal/us_ticker_api.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -27,7 +28,7 @@ namespace mbed {
|
|||
* @note Synchronization level: Interrupt safe
|
||||
* @ingroup drivers
|
||||
*/
|
||||
class TimerEvent {
|
||||
class TimerEvent : private NonCopyable<TimerEvent> {
|
||||
public:
|
||||
TimerEvent();
|
||||
TimerEvent(const ticker_data_t *data);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if DEVICE_SERIAL
|
||||
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN)
|
||||
|
||||
#include <errno.h>
|
||||
#include "UARTSerial.h"
|
||||
|
@ -80,16 +80,16 @@ off_t UARTSerial::seek(off_t offset, int whence)
|
|||
|
||||
int UARTSerial::sync()
|
||||
{
|
||||
lock();
|
||||
api_lock();
|
||||
|
||||
while (!_txbuf.empty()) {
|
||||
unlock();
|
||||
api_unlock();
|
||||
// Doing better than wait would require TxIRQ to also do wake() when becoming empty. Worth it?
|
||||
wait_ms(1);
|
||||
lock();
|
||||
api_lock();
|
||||
}
|
||||
|
||||
unlock();
|
||||
api_unlock();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -111,16 +111,16 @@ ssize_t UARTSerial::write(const void* buffer, size_t length)
|
|||
size_t data_written = 0;
|
||||
const char *buf_ptr = static_cast<const char *>(buffer);
|
||||
|
||||
lock();
|
||||
api_lock();
|
||||
|
||||
while (_txbuf.full()) {
|
||||
if (!_blocking) {
|
||||
unlock();
|
||||
api_unlock();
|
||||
return -EAGAIN;
|
||||
}
|
||||
unlock();
|
||||
api_unlock();
|
||||
wait_ms(1); // XXX todo - proper wait, WFE for non-rtos ?
|
||||
lock();
|
||||
api_lock();
|
||||
}
|
||||
|
||||
while (data_written < length && !_txbuf.full()) {
|
||||
|
@ -138,7 +138,7 @@ ssize_t UARTSerial::write(const void* buffer, size_t length)
|
|||
}
|
||||
core_util_critical_section_exit();
|
||||
|
||||
unlock();
|
||||
api_unlock();
|
||||
|
||||
return data_written;
|
||||
}
|
||||
|
@ -149,16 +149,16 @@ ssize_t UARTSerial::read(void* buffer, size_t length)
|
|||
|
||||
char *ptr = static_cast<char *>(buffer);
|
||||
|
||||
lock();
|
||||
api_lock();
|
||||
|
||||
while (_rxbuf.empty()) {
|
||||
if (!_blocking) {
|
||||
unlock();
|
||||
api_unlock();
|
||||
return -EAGAIN;
|
||||
}
|
||||
unlock();
|
||||
api_unlock();
|
||||
wait_ms(1); // XXX todo - proper wait, WFE for non-rtos ?
|
||||
lock();
|
||||
api_lock();
|
||||
}
|
||||
|
||||
while (data_read < length && !_rxbuf.empty()) {
|
||||
|
@ -166,7 +166,7 @@ ssize_t UARTSerial::read(void* buffer, size_t length)
|
|||
data_read++;
|
||||
}
|
||||
|
||||
unlock();
|
||||
api_unlock();
|
||||
|
||||
return data_read;
|
||||
}
|
||||
|
@ -205,12 +205,24 @@ short UARTSerial::poll(short events) const {
|
|||
return revents;
|
||||
}
|
||||
|
||||
void UARTSerial::lock(void)
|
||||
void UARTSerial::lock()
|
||||
{
|
||||
// This is the override for SerialBase.
|
||||
// No lock required as we only use SerialBase from interrupt or from
|
||||
// inside our own critical section.
|
||||
}
|
||||
|
||||
void UARTSerial::unlock()
|
||||
{
|
||||
// This is the override for SerialBase.
|
||||
}
|
||||
|
||||
void UARTSerial::api_lock(void)
|
||||
{
|
||||
_mutex.lock();
|
||||
}
|
||||
|
||||
void UARTSerial::unlock(void)
|
||||
void UARTSerial::api_unlock(void)
|
||||
{
|
||||
_mutex.unlock();
|
||||
}
|
||||
|
@ -262,4 +274,4 @@ void UARTSerial::tx_irq(void)
|
|||
|
||||
} //namespace mbed
|
||||
|
||||
#endif //DEVICE_SERIAL
|
||||
#endif //(DEVICE_SERIAL && DEVICE_INTERRUPTIN)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#include "platform/platform.h"
|
||||
|
||||
#if DEVICE_SERIAL
|
||||
#if (DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
|
||||
|
||||
#include "FileHandle.h"
|
||||
#include "SerialBase.h"
|
||||
|
@ -27,6 +27,7 @@
|
|||
#include "PlatformMutex.h"
|
||||
#include "serial_api.h"
|
||||
#include "CircularBuffer.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
#ifndef MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE
|
||||
#define MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE 256
|
||||
|
@ -38,7 +39,7 @@
|
|||
|
||||
namespace mbed {
|
||||
|
||||
class UARTSerial : private SerialBase, public FileHandle {
|
||||
class UARTSerial : private SerialBase, public FileHandle, private NonCopyable<UARTSerial> {
|
||||
|
||||
public:
|
||||
|
||||
|
@ -58,7 +59,7 @@ public:
|
|||
/** Write the contents of a buffer to a file
|
||||
*
|
||||
* @param buffer The buffer to write from
|
||||
* @param size The number of bytes to write
|
||||
* @param length The number of bytes to write
|
||||
* @return The number of bytes written, negative error on failure
|
||||
*/
|
||||
virtual ssize_t write(const void* buffer, size_t length);
|
||||
|
@ -72,17 +73,11 @@ public:
|
|||
* * If any data is available, call returns immediately
|
||||
*
|
||||
* @param buffer The buffer to read in to
|
||||
* @param size The number of bytes to read
|
||||
* @param length The number of bytes to read
|
||||
* @return The number of bytes read, 0 at end of file, negative error on failure
|
||||
*/
|
||||
virtual ssize_t read(void* buffer, size_t length);
|
||||
|
||||
/** Acquire mutex */
|
||||
virtual void lock(void);
|
||||
|
||||
/** Release mutex */
|
||||
virtual void unlock(void);
|
||||
|
||||
/** Close a file
|
||||
*
|
||||
* @return 0 on success, negative error code on failure
|
||||
|
@ -159,6 +154,18 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
/** SerialBase lock override */
|
||||
virtual void lock(void);
|
||||
|
||||
/** SerialBase unlock override */
|
||||
virtual void unlock(void);
|
||||
|
||||
/** Acquire mutex */
|
||||
virtual void api_lock(void);
|
||||
|
||||
/** Release mutex */
|
||||
virtual void api_unlock(void);
|
||||
|
||||
/** Software serial buffers
|
||||
* By default buffer size is 256 for TX and 256 for RX. Configurable through mbed_app.json
|
||||
*/
|
||||
|
@ -191,8 +198,9 @@ private:
|
|||
void wake(void);
|
||||
|
||||
void dcd_irq(void);
|
||||
|
||||
};
|
||||
} //namespace mbed
|
||||
|
||||
#endif //DEVICE_SERIAL
|
||||
#endif //(DEVICE_SERIAL && DEVICE_INTERRUPTIN) || defined(DOXYGEN_ONLY)
|
||||
#endif //MBED_UARTSERIAL_H
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "equeue/equeue.h"
|
||||
#include "platform/Callback.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
#include <cstddef>
|
||||
#include <new>
|
||||
|
||||
|
@ -47,7 +48,7 @@ class Event;
|
|||
* Flexible event queue for dispatching events
|
||||
* @ingroup events
|
||||
*/
|
||||
class EventQueue {
|
||||
class EventQueue : private mbed::NonCopyable<EventQueue> {
|
||||
public:
|
||||
/** Create an EventQueue
|
||||
*
|
||||
|
|
|
@ -476,8 +476,13 @@ nsapi_error_t mbed_lwip_emac_init(emac_interface_t *emac)
|
|||
// Backwards compatibility with people using DEVICE_EMAC
|
||||
nsapi_error_t mbed_lwip_init(emac_interface_t *emac)
|
||||
{
|
||||
nsapi_error_t ret;
|
||||
mbed_lwip_core_init();
|
||||
return mbed_lwip_emac_init(emac);
|
||||
ret = mbed_lwip_emac_init(emac);
|
||||
if (ret == NSAPI_ERROR_OK) {
|
||||
netif_inited = true;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
// Backwards compatibility with people using DEVICE_EMAC
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
#ifndef LWIPOPTS_H
|
||||
#define LWIPOPTS_H
|
||||
|
||||
#if MBED_CONF_LWIP_ETHERNET_ENABLED
|
||||
#include "lwipopts_conf.h"
|
||||
#endif
|
||||
|
||||
// Workaround for Linux timeval
|
||||
#if defined (TOOLCHAIN_GCC)
|
||||
|
|
|
@ -57,33 +57,39 @@ int HeapBlockDevice::init()
|
|||
|
||||
int HeapBlockDevice::deinit()
|
||||
{
|
||||
// Heapory is lazily cleaned up in destructor to allow
|
||||
MBED_ASSERT(_blocks != NULL);
|
||||
// Memory is lazily cleaned up in destructor to allow
|
||||
// data to live across de/reinitialization
|
||||
return BD_ERROR_OK;
|
||||
}
|
||||
|
||||
bd_size_t HeapBlockDevice::get_read_size() const
|
||||
{
|
||||
MBED_ASSERT(_blocks != NULL);
|
||||
return _read_size;
|
||||
}
|
||||
|
||||
bd_size_t HeapBlockDevice::get_program_size() const
|
||||
{
|
||||
MBED_ASSERT(_blocks != NULL);
|
||||
return _program_size;
|
||||
}
|
||||
|
||||
bd_size_t HeapBlockDevice::get_erase_size() const
|
||||
{
|
||||
MBED_ASSERT(_blocks != NULL);
|
||||
return _erase_size;
|
||||
}
|
||||
|
||||
bd_size_t HeapBlockDevice::size() const
|
||||
{
|
||||
MBED_ASSERT(_blocks != NULL);
|
||||
return _count * _erase_size;
|
||||
}
|
||||
|
||||
int HeapBlockDevice::read(void *b, bd_addr_t addr, bd_size_t size)
|
||||
{
|
||||
MBED_ASSERT(_blocks != NULL);
|
||||
MBED_ASSERT(is_valid_read(addr, size));
|
||||
uint8_t *buffer = static_cast<uint8_t*>(b);
|
||||
|
||||
|
@ -107,6 +113,7 @@ int HeapBlockDevice::read(void *b, bd_addr_t addr, bd_size_t size)
|
|||
|
||||
int HeapBlockDevice::program(const void *b, bd_addr_t addr, bd_size_t size)
|
||||
{
|
||||
MBED_ASSERT(_blocks != NULL);
|
||||
MBED_ASSERT(is_valid_program(addr, size));
|
||||
const uint8_t *buffer = static_cast<const uint8_t*>(b);
|
||||
|
||||
|
@ -133,6 +140,7 @@ int HeapBlockDevice::program(const void *b, bd_addr_t addr, bd_size_t size)
|
|||
|
||||
int HeapBlockDevice::erase(bd_addr_t addr, bd_size_t size)
|
||||
{
|
||||
MBED_ASSERT(_blocks != NULL);
|
||||
MBED_ASSERT(is_valid_erase(addr, size));
|
||||
// TODO assert on programming unerased blocks
|
||||
|
||||
|
|
|
@ -187,11 +187,16 @@ MBRBlockDevice::MBRBlockDevice(BlockDevice *bd, int part)
|
|||
|
||||
int MBRBlockDevice::init()
|
||||
{
|
||||
int err = _bd->init();
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
// Allocate smallest buffer necessary to write MBR
|
||||
uint32_t buffer_size = std::max<uint32_t>(_bd->get_read_size(), sizeof(struct mbr_table));
|
||||
uint8_t *buffer = new uint8_t[buffer_size];
|
||||
|
||||
int err = _bd->read(buffer, 512-buffer_size, buffer_size);
|
||||
err = _bd->read(buffer, 512-buffer_size, buffer_size);
|
||||
if (err) {
|
||||
delete[] buffer;
|
||||
return err;
|
||||
|
|
|
@ -247,10 +247,10 @@ FATFileSystem::~FATFileSystem()
|
|||
|
||||
int FATFileSystem::mount(BlockDevice *bd) {
|
||||
// requires duplicate definition to allow virtual overload to work
|
||||
return mount(bd, false);
|
||||
return mount(bd, true);
|
||||
}
|
||||
|
||||
int FATFileSystem::mount(BlockDevice *bd, bool force) {
|
||||
int FATFileSystem::mount(BlockDevice *bd, bool mount) {
|
||||
lock();
|
||||
if (_id != -1) {
|
||||
unlock();
|
||||
|
@ -265,7 +265,7 @@ int FATFileSystem::mount(BlockDevice *bd, bool force) {
|
|||
_fsid[1] = ':';
|
||||
_fsid[2] = '\0';
|
||||
debug_if(FFS_DBG, "Mounting [%s] on ffs drive [%s]\n", getName(), _fsid);
|
||||
FRESULT res = f_mount(&_fs, _fsid, force);
|
||||
FRESULT res = f_mount(&_fs, _fsid, mount);
|
||||
unlock();
|
||||
return fat_error_remap(res);
|
||||
}
|
||||
|
|
|
@ -69,14 +69,6 @@ public:
|
|||
*/
|
||||
virtual int mount(BlockDevice *bd);
|
||||
|
||||
/** Mounts a filesystem to a block device
|
||||
*
|
||||
* @param bd BlockDevice to mount to
|
||||
* @param force Flag to force the underlying filesystem to force mounting the filesystem
|
||||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
virtual int mount(BlockDevice *bd, bool force);
|
||||
|
||||
/** Unmounts a filesystem from the underlying block device
|
||||
*
|
||||
* @return 0 on success, negative error code on failure
|
||||
|
@ -235,6 +227,7 @@ private:
|
|||
protected:
|
||||
virtual void lock();
|
||||
virtual void unlock();
|
||||
virtual int mount(BlockDevice *bd, bool mount);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#ifndef GREENTEA_CLIENT_TEST_ENV_H_
|
||||
#define GREENTEA_CLIENT_TEST_ENV_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifdef YOTTA_GREENTEA_CLIENT_VERSION_STRING
|
||||
#define MBED_GREENTEA_CLIENT_VERSION_STRING YOTTA_GREENTEA_CLIENT_VERSION_STRING
|
||||
#else
|
||||
|
@ -81,7 +82,6 @@ extern const char* GREENTEA_TEST_ENV_LCOV_START;
|
|||
/**
|
||||
* Greentea-client related API for communication with host side
|
||||
*/
|
||||
void GREENTEA_SETUP(const int, const char *);
|
||||
void GREENTEA_SETUP_UUID(const int timeout, const char *host_test_name, char *buffer, size_t size);
|
||||
void GREENTEA_TESTSUITE_RESULT(const int);
|
||||
void GREENTEA_TESTCASE_START(const char *test_case_name);
|
||||
|
@ -90,12 +90,10 @@ void GREENTEA_TESTCASE_FINISH(const char *test_case_name, const size_t passes, c
|
|||
/**
|
||||
* Test suite result related notification API
|
||||
*/
|
||||
void greentea_send_kv(const char *, const char *);
|
||||
void greentea_send_kv(const char *, const int);
|
||||
void greentea_send_kv(const char *, const int, const int);
|
||||
void greentea_send_kv(const char *, const char *, const int);
|
||||
void greentea_send_kv(const char *, const char *, const int, const int);
|
||||
int greentea_parse_kv(char *, char *, const int, const int);
|
||||
|
||||
#ifdef MBED_CFG_DEBUG_OPTIONS_COVERAGE
|
||||
/**
|
||||
|
@ -105,6 +103,25 @@ void greentea_notify_coverage_start(const char *path);
|
|||
void greentea_notify_coverage_end();
|
||||
#endif // MBED_CFG_DEBUG_OPTIONS_COVERAGE
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Greentea-client C API
|
||||
*/
|
||||
void GREENTEA_SETUP(const int timeout, const char * host_test);
|
||||
void greentea_send_kv(const char * key, const char * val);
|
||||
int greentea_parse_kv(char * key, char * val,
|
||||
const int key_len, const int val_len);
|
||||
int greentea_getc();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // GREENTEA_CLIENT_TEST_ENV_H_
|
||||
|
||||
/** @}*/
|
||||
|
|
|
@ -72,6 +72,7 @@ static void send_heap_info()
|
|||
mbed_stats_heap_t heap_stats;
|
||||
mbed_stats_heap_get(&heap_stats);
|
||||
greentea_send_kv("max_heap_usage",heap_stats.max_size);
|
||||
greentea_send_kv("reserved_heap",heap_stats.reserved_size);
|
||||
}
|
||||
|
||||
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
|
||||
|
|
|
@ -94,7 +94,7 @@ void _GREENTEA_SETUP_COMMON(const int timeout, const char *host_test_name, char
|
|||
* and add host test's callback handlers to main event loop
|
||||
* This function is blocking.
|
||||
*/
|
||||
void GREENTEA_SETUP(const int timeout, const char *host_test_name) {
|
||||
extern "C" void GREENTEA_SETUP(const int timeout, const char *host_test_name) {
|
||||
char _value[GREENTEA_UUID_LENGTH] = {0};
|
||||
_GREENTEA_SETUP_COMMON(timeout, host_test_name, _value, GREENTEA_UUID_LENGTH);
|
||||
}
|
||||
|
@ -293,7 +293,7 @@ inline void greentea_write_int(const int val)
|
|||
* \param value Message payload, string value
|
||||
*
|
||||
*/
|
||||
void greentea_send_kv(const char *key, const char *val) {
|
||||
extern "C" void greentea_send_kv(const char *key, const char *val) {
|
||||
if (key && val) {
|
||||
greentea_write_preamble();
|
||||
greentea_write_string(key);
|
||||
|
@ -511,7 +511,6 @@ static int gettok(char *, const int);
|
|||
static int getNextToken(char *, const int);
|
||||
static int HandleKV(char *, char *, const int, const int);
|
||||
static int isstring(int);
|
||||
static int _get_char();
|
||||
|
||||
/**
|
||||
* \brief Current token of key-value protocol's tokenizer
|
||||
|
@ -555,7 +554,7 @@ enum Token {
|
|||
* \return Next character from the stream or EOF if stream has ended.
|
||||
*
|
||||
*/
|
||||
static int _get_char() {
|
||||
extern "C" int greentea_getc() {
|
||||
return greentea_serial->getc();
|
||||
}
|
||||
|
||||
|
@ -574,7 +573,7 @@ static int _get_char() {
|
|||
* success == 0 when end of the stream was found
|
||||
*
|
||||
*/
|
||||
int greentea_parse_kv(char *out_key,
|
||||
extern "C" int greentea_parse_kv(char *out_key,
|
||||
char *out_value,
|
||||
const int out_key_size,
|
||||
const int out_value_size) {
|
||||
|
@ -689,7 +688,7 @@ static int gettok(char *out_str, const int str_size) {
|
|||
|
||||
// whitespace ::=
|
||||
while (isspace(LastChar)) {
|
||||
LastChar = _get_char();
|
||||
LastChar = greentea_getc();
|
||||
}
|
||||
|
||||
// string ::= [a-zA-Z0-9_-!@#$%^&*()]+
|
||||
|
@ -699,7 +698,7 @@ static int gettok(char *out_str, const int str_size) {
|
|||
out_str[str_idx++] = LastChar;
|
||||
}
|
||||
|
||||
while (isstring((LastChar = _get_char())))
|
||||
while (isstring((LastChar = greentea_getc())))
|
||||
if (out_str && str_idx < str_size - 1) {
|
||||
out_str[str_idx++] = LastChar;
|
||||
}
|
||||
|
@ -712,24 +711,23 @@ static int gettok(char *out_str, const int str_size) {
|
|||
|
||||
// semicolon ::= ';'
|
||||
if (LastChar == ';') {
|
||||
LastChar = _get_char();
|
||||
LastChar = greentea_getc();
|
||||
return tok_semicolon;
|
||||
}
|
||||
|
||||
// open ::= '{{'
|
||||
if (LastChar == '{') {
|
||||
LastChar = _get_char();
|
||||
LastChar = greentea_getc();
|
||||
if (LastChar == '{') {
|
||||
LastChar = _get_char();
|
||||
LastChar = greentea_getc();
|
||||
return tok_open;
|
||||
}
|
||||
}
|
||||
|
||||
// close ::= '}'
|
||||
if (LastChar == '}') {
|
||||
LastChar = _get_char();
|
||||
LastChar = greentea_getc();
|
||||
if (LastChar == '}') {
|
||||
//LastChar = _get_char();
|
||||
return tok_close;
|
||||
}
|
||||
}
|
||||
|
@ -739,7 +737,7 @@ static int gettok(char *out_str, const int str_size) {
|
|||
|
||||
// Otherwise, just return the character as its ascii value.
|
||||
int ThisChar = LastChar;
|
||||
LastChar = _get_char();
|
||||
LastChar = greentea_getc();
|
||||
return ThisChar;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,4 +24,6 @@
|
|||
|
||||
#define MBEDTLS_SHA256_ALT
|
||||
|
||||
#define MBEDTLS_SHA1_ALT
|
||||
|
||||
#endif /* MBEDTLS_DEVICE_H */
|
||||
|
|
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
* sha1_alt.c for SHA1 HASH
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2017, STMicroelectronics
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
#include "mbedtls/sha1.h"
|
||||
#if defined(MBEDTLS_SHA1_ALT)
|
||||
#include "mbedtls/platform.h"
|
||||
|
||||
/* Implementation that should never be optimized out by the compiler */
|
||||
static void mbedtls_zeroize( void *v, size_t n ) {
|
||||
volatile unsigned char *p = (unsigned char*)v; while( n-- ) *p++ = 0;
|
||||
}
|
||||
|
||||
static int st_sha1_restore_hw_context(mbedtls_sha1_context *ctx)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t tickstart;
|
||||
/* allow multi-instance of HASH use: save context for HASH HW module CR */
|
||||
/* Check that there is no HASH activity on going */
|
||||
tickstart = HAL_GetTick();
|
||||
while ((HASH->SR & (HASH_FLAG_BUSY | HASH_FLAG_DMAS)) != 0) {
|
||||
if ((HAL_GetTick() - tickstart) > ST_SHA1_TIMEOUT) {
|
||||
return 0; // timeout: HASH processor is busy
|
||||
}
|
||||
}
|
||||
HASH->STR = ctx->ctx_save_str;
|
||||
HASH->CR = (ctx->ctx_save_cr | HASH_CR_INIT);
|
||||
for (i=0;i<38;i++) {
|
||||
HASH->CSR[i] = ctx->ctx_save_csr[i];
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int st_sha1_save_hw_context(mbedtls_sha1_context *ctx)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t tickstart;
|
||||
/* Check that there is no HASH activity on going */
|
||||
tickstart = HAL_GetTick();
|
||||
while ((HASH->SR & (HASH_FLAG_BUSY | HASH_FLAG_DMAS)) != 0) {
|
||||
if ((HAL_GetTick() - tickstart) > ST_SHA1_TIMEOUT) {
|
||||
return 0; // timeout: HASH processor is busy
|
||||
}
|
||||
}
|
||||
/* allow multi-instance of HASH use: restore context for HASH HW module CR */
|
||||
ctx->ctx_save_cr = HASH->CR;
|
||||
ctx->ctx_save_str = HASH->STR;
|
||||
for (i=0;i<38;i++) {
|
||||
ctx->ctx_save_csr[i] = HASH->CSR[i];
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void mbedtls_sha1_init( mbedtls_sha1_context *ctx )
|
||||
{
|
||||
mbedtls_zeroize( ctx, sizeof( mbedtls_sha1_context ) );
|
||||
|
||||
/* Enable HASH clock */
|
||||
__HAL_RCC_HASH_CLK_ENABLE();
|
||||
|
||||
}
|
||||
|
||||
void mbedtls_sha1_free( mbedtls_sha1_context *ctx )
|
||||
{
|
||||
if( ctx == NULL )
|
||||
return;
|
||||
mbedtls_zeroize( ctx, sizeof( mbedtls_sha1_context ) );
|
||||
}
|
||||
|
||||
void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
|
||||
const mbedtls_sha1_context *src )
|
||||
{
|
||||
*dst = *src;
|
||||
}
|
||||
|
||||
void mbedtls_sha1_starts( mbedtls_sha1_context *ctx )
|
||||
{
|
||||
/* Deinitializes the HASH peripheral */
|
||||
if (HAL_HASH_DeInit(&ctx->hhash_sha1) == HAL_ERROR) {
|
||||
// error found to be returned
|
||||
return;
|
||||
}
|
||||
|
||||
/* HASH Configuration */
|
||||
ctx->hhash_sha1.Init.DataType = HASH_DATATYPE_8B;
|
||||
if (HAL_HASH_Init(&ctx->hhash_sha1) == HAL_ERROR) {
|
||||
// error found to be returned
|
||||
return;
|
||||
}
|
||||
if (st_sha1_save_hw_context(ctx) != 1) {
|
||||
return; // return HASH_BUSY timeout Error here
|
||||
}
|
||||
}
|
||||
|
||||
void mbedtls_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[ST_SHA1_BLOCK_SIZE] )
|
||||
{
|
||||
if (st_sha1_restore_hw_context(ctx) != 1) {
|
||||
return; // Return HASH_BUSY timout error here
|
||||
}
|
||||
if (HAL_HASH_SHA1_Accumulate(&ctx->hhash_sha1, (uint8_t *) data, ST_SHA1_BLOCK_SIZE) != 0) {
|
||||
return; // Return error code
|
||||
}
|
||||
|
||||
if (st_sha1_save_hw_context(ctx) != 1) {
|
||||
return; // return HASH_BUSY timeout Error here
|
||||
}
|
||||
}
|
||||
|
||||
void mbedtls_sha1_update( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen )
|
||||
{
|
||||
size_t currentlen = ilen;
|
||||
if (st_sha1_restore_hw_context(ctx) != 1) {
|
||||
return; // Return HASH_BUSY timout error here
|
||||
}
|
||||
|
||||
// store mechanism to accumulate ST_SHA1_BLOCK_SIZE bytes (512 bits) in the HW
|
||||
if (currentlen == 0){ // only change HW status is size if 0
|
||||
if(ctx->hhash_sha1.Phase == HAL_HASH_PHASE_READY) {
|
||||
/* Select the SHA1 mode and reset the HASH processor core, so that the HASH will be ready to compute
|
||||
the message digest of a new message */
|
||||
HASH->CR |= HASH_ALGOSELECTION_SHA1 | HASH_CR_INIT;
|
||||
}
|
||||
ctx->hhash_sha1.Phase = HAL_HASH_PHASE_PROCESS;
|
||||
} else if (currentlen < (ST_SHA1_BLOCK_SIZE - ctx->sbuf_len)) {
|
||||
// only buffurize
|
||||
memcpy(ctx->sbuf + ctx->sbuf_len, input, currentlen);
|
||||
ctx->sbuf_len += currentlen;
|
||||
} else {
|
||||
// fill buffer and process it
|
||||
memcpy(ctx->sbuf + ctx->sbuf_len, input, (ST_SHA1_BLOCK_SIZE - ctx->sbuf_len));
|
||||
currentlen -= (ST_SHA1_BLOCK_SIZE - ctx->sbuf_len);
|
||||
mbedtls_sha1_process(ctx, ctx->sbuf);
|
||||
// Process every input as long as it is %64 bytes, ie 512 bits
|
||||
size_t iter = currentlen / ST_SHA1_BLOCK_SIZE;
|
||||
if (HAL_HASH_SHA1_Accumulate(&ctx->hhash_sha1, (uint8_t *)(input + ST_SHA1_BLOCK_SIZE - ctx->sbuf_len), (iter * ST_SHA1_BLOCK_SIZE)) != 0) {
|
||||
return; // Return error code here
|
||||
}
|
||||
// sbuf is completely accumulated, now copy up to 63 remaining bytes
|
||||
ctx->sbuf_len = currentlen % ST_SHA1_BLOCK_SIZE;
|
||||
if (ctx->sbuf_len !=0) {
|
||||
memcpy(ctx->sbuf, input + ilen - ctx->sbuf_len, ctx->sbuf_len);
|
||||
}
|
||||
}
|
||||
if (st_sha1_save_hw_context(ctx) != 1) {
|
||||
return; // return HASH_BUSY timeout Error here
|
||||
}
|
||||
}
|
||||
|
||||
void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, unsigned char output[20] )
|
||||
{
|
||||
if (st_sha1_restore_hw_context(ctx) != 1) {
|
||||
return; // Return HASH_BUSY timout error here
|
||||
}
|
||||
|
||||
if (ctx->sbuf_len > 0) {
|
||||
if (HAL_HASH_SHA1_Accumulate(&ctx->hhash_sha1, ctx->sbuf, ctx->sbuf_len) != 0) {
|
||||
return; // Return error code here
|
||||
}
|
||||
}
|
||||
mbedtls_zeroize(ctx->sbuf, ST_SHA1_BLOCK_SIZE);
|
||||
ctx->sbuf_len = 0;
|
||||
__HAL_HASH_START_DIGEST();
|
||||
|
||||
if (HAL_HASH_SHA1_Finish(&ctx->hhash_sha1, output, 10) != 0){
|
||||
return; // error code to be returned
|
||||
}
|
||||
if (st_sha1_save_hw_context(ctx) != 1) {
|
||||
return; // return HASH_BUSY timeout Error here
|
||||
}
|
||||
}
|
||||
|
||||
#endif /*MBEDTLS_SHA1_ALT*/
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* \file sha1_alt.h
|
||||
*
|
||||
* \brief SHA1 hw acceleration (hash function)
|
||||
*
|
||||
* Copyright (C) 2017, STMicroelectronics
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
#ifndef MBEDTLS_SHA1_ALT_H
|
||||
#define MBEDTLS_SHA1_ALT_H
|
||||
|
||||
#if defined (MBEDTLS_SHA1_ALT)
|
||||
|
||||
|
||||
#include "cmsis.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ST_SHA1_BLOCK_SIZE ((size_t) 64) // HW handles 512 bits, ie 64 bytes
|
||||
#define ST_SHA1_TIMEOUT ((uint32_t) 3)
|
||||
/**
|
||||
* \brief SHA-1 context structure
|
||||
* \note HAL_HASH_SHA1_Accumulate will accumulate 512 bits packets, unless it is the last call to the function
|
||||
* A ST_SHA1_BLOCK_SIZE bytes buffer is used to save values and handle the processing
|
||||
* multiples of ST_SHA1_BLOCK_SIZE bytes
|
||||
* If SHA1_finish is called and sbuf_len>0, the remaining bytes are accumulated prior to the call to HAL_HASH_SHA1_Finish
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
unsigned char sbuf[ST_SHA1_BLOCK_SIZE]; /*!< MBEDTLS_SHA1_BLOCK_SIZE buffer to store values so that algorithm is caled once the buffer is filled */
|
||||
unsigned char sbuf_len; /*!< number of bytes remaining in sbuf to be processed */
|
||||
HASH_HandleTypeDef hhash_sha1; /*!< ST HAL HASH struct */
|
||||
uint32_t ctx_save_cr;
|
||||
uint32_t ctx_save_str;
|
||||
uint32_t ctx_save_csr[38];
|
||||
}
|
||||
mbedtls_sha1_context;
|
||||
|
||||
/**
|
||||
* \brief Initialize SHA-1 context
|
||||
*
|
||||
* \param ctx SHA-1 context to be initialized
|
||||
*/
|
||||
void mbedtls_sha1_init( mbedtls_sha1_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief Clear SHA-1 context
|
||||
*
|
||||
* \param ctx SHA-1 context to be cleared
|
||||
*/
|
||||
void mbedtls_sha1_free( mbedtls_sha1_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief Clone (the state of) a SHA-1 context
|
||||
*
|
||||
* \param dst The destination context
|
||||
* \param src The context to be cloned
|
||||
*/
|
||||
void mbedtls_sha1_clone( mbedtls_sha1_context *dst,
|
||||
const mbedtls_sha1_context *src );
|
||||
|
||||
/**
|
||||
* \brief SHA-1 context setup
|
||||
*
|
||||
* \param ctx context to be initialized
|
||||
*/
|
||||
void mbedtls_sha1_starts( mbedtls_sha1_context *ctx );
|
||||
|
||||
/**
|
||||
* \brief SHA-1 process buffer
|
||||
*
|
||||
* \param ctx SHA-1 context
|
||||
* \param input buffer holding the data
|
||||
* \param ilen length of the input data
|
||||
*/
|
||||
void mbedtls_sha1_update( mbedtls_sha1_context *ctx, const unsigned char *input, size_t ilen );
|
||||
|
||||
/**
|
||||
* \brief SHA-1 final digest
|
||||
*
|
||||
* \param ctx SHA-1 context
|
||||
* \param output SHA-1 checksum result
|
||||
*/
|
||||
void mbedtls_sha1_finish( mbedtls_sha1_context *ctx, unsigned char output[20] );
|
||||
|
||||
/* Internal use */
|
||||
void mbedtls_sha1_process( mbedtls_sha1_context *ctx, const unsigned char data[ST_SHA1_BLOCK_SIZE] );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* MBEDTLS_SHA1_ALT */
|
||||
|
||||
#endif /* sha1_alt.h */
|
|
@ -1,19 +0,0 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM32F103RB.h"
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM_144_64pins.h"
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM_144_64pins.h"
|
|
@ -1,18 +0,0 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM_144_64pins.h"
|
|
@ -1,18 +0,0 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM_144_64pins.h"
|
|
@ -1,18 +0,0 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM_144_64pins.h"
|
|
@ -1,18 +0,0 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM_144_64pins.h"
|
|
@ -1,18 +0,0 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM_144_64pins.h"
|
|
@ -1,18 +0,0 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM_144_64pins.h"
|
|
@ -1,19 +0,0 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM_144_64pins.h"
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM_144_64pins.h"
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM_144_64pins.h"
|
|
@ -1,19 +0,0 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include "USBHAL_STM32F769NI.h"
|
|
@ -1,18 +0,0 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM32L053C8.h"
|
|
@ -0,0 +1,131 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#ifndef USBHAL_STM32L072CZ_H
|
||||
#define USBHAL_STM32L072CZ_H
|
||||
|
||||
#define USBHAL_IRQn USB_IRQn
|
||||
|
||||
/* must be multiple of 4 bytes */
|
||||
#define NB_ENDPOINT 8
|
||||
#define MAXTRANSFER_SIZE 0x200
|
||||
#define FIFO_USB_RAM_SIZE (MAXTRANSFER_SIZE+MAX_PACKET_SIZE_EP0+MAX_PACKET_SIZE_EP1+MAX_PACKET_SIZE_EP2+MAX_PACKET_SIZE_EP3)
|
||||
#if (FIFO_USB_RAM_SIZE > 0x500)
|
||||
#error "FIFO dimensioning incorrect"
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
USBHAL *inst;
|
||||
void (USBHAL::*bus_reset)(void);
|
||||
void (USBHAL::*sof)(int frame);
|
||||
void (USBHAL::*connect_change)(unsigned int connected);
|
||||
void (USBHAL::*suspend_change)(unsigned int suspended);
|
||||
void (USBHAL::*ep0_setup)(void);
|
||||
void (USBHAL::*ep0_in)(void);
|
||||
void (USBHAL::*ep0_out)(void);
|
||||
void (USBHAL::*ep0_read)(void);
|
||||
bool (USBHAL::*ep_realise)(uint8_t endpoint, uint32_t maxPacket, uint32_t flags);
|
||||
bool (USBHAL::*epCallback[6])(void);
|
||||
uint8_t epComplete[2*NB_ENDPOINT];
|
||||
/* memorize dummy buffer used for reception */
|
||||
uint32_t pBufRx[MAXTRANSFER_SIZE>>2];
|
||||
uint32_t pBufRx0[MAX_PACKET_SIZE_EP0>>2];
|
||||
gpio_t usb_switch;
|
||||
}USBHAL_Private_t;
|
||||
|
||||
uint32_t HAL_PCDEx_GetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo)
|
||||
{
|
||||
return 1024;
|
||||
}
|
||||
|
||||
void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state)
|
||||
{
|
||||
USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
|
||||
gpio_write(&(priv->usb_switch),state);
|
||||
}
|
||||
|
||||
void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd)
|
||||
{
|
||||
USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
|
||||
USBHAL *obj= priv->inst;
|
||||
uint32_t sofnum = (hpcd->Instance->FNR) & USB_FNR_FN;
|
||||
void (USBHAL::*func)(int frame) = priv->sof;
|
||||
(obj->*func)(sofnum);
|
||||
}
|
||||
|
||||
USBHAL * USBHAL::instance;
|
||||
|
||||
USBHAL::USBHAL(void)
|
||||
{
|
||||
/* init parameter */
|
||||
USBHAL_Private_t *HALPriv = new(USBHAL_Private_t);
|
||||
hpcd.Instance = USB;
|
||||
/* initialized Init to zero (constructor does not zero initialized the
|
||||
* area */
|
||||
/* initialized all field of init including 0 field */
|
||||
/* constructor does not fill with zero */
|
||||
memset(&hpcd.Init, 0, sizeof(hpcd.Init));
|
||||
hpcd.Init.dev_endpoints = NB_ENDPOINT;
|
||||
hpcd.Init.ep0_mps = MAX_PACKET_SIZE_EP0;
|
||||
hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
|
||||
hpcd.Init.Sof_enable = 1;
|
||||
hpcd.Init.speed = PCD_SPEED_FULL;
|
||||
/* pass instance for usage inside call back */
|
||||
HALPriv->inst = this;
|
||||
HALPriv->bus_reset = &USBHAL::busReset;
|
||||
HALPriv->suspend_change = &USBHAL::suspendStateChanged;
|
||||
HALPriv->connect_change = &USBHAL::connectStateChanged;
|
||||
HALPriv->sof = &USBHAL::SOF;
|
||||
HALPriv->ep0_setup = &USBHAL::EP0setupCallback;
|
||||
HALPriv->ep_realise = &USBHAL::realiseEndpoint;
|
||||
HALPriv->ep0_in = &USBHAL::EP0in;
|
||||
HALPriv->ep0_out = &USBHAL::EP0out;
|
||||
HALPriv->ep0_read = &USBHAL::EP0read;
|
||||
hpcd.pData = (void*)HALPriv;
|
||||
HALPriv->epCallback[0] = &USBHAL::EP1_OUT_callback;
|
||||
HALPriv->epCallback[1] = &USBHAL::EP1_IN_callback;
|
||||
HALPriv->epCallback[2] = &USBHAL::EP2_OUT_callback;
|
||||
HALPriv->epCallback[3] = &USBHAL::EP2_IN_callback;
|
||||
HALPriv->epCallback[4] = &USBHAL::EP3_OUT_callback;
|
||||
HALPriv->epCallback[5] = &USBHAL::EP3_IN_callback;
|
||||
instance = this;
|
||||
|
||||
/* Configure USB DM pin. This is optional, and maintained only for user guidance. */
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_USB));
|
||||
pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF2_USB));
|
||||
|
||||
/* Enable USB Clock */
|
||||
__HAL_RCC_USB_CLK_ENABLE();
|
||||
|
||||
/* Enable SYSCFG Clock */
|
||||
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
||||
hpcd.State = HAL_PCD_STATE_RESET;
|
||||
HAL_PCD_Init(&hpcd);
|
||||
|
||||
/* hardcoded size of FIFO according definition*/
|
||||
HAL_PCDEx_PMAConfig(&hpcd , 0x00 , PCD_SNG_BUF, 0x30);
|
||||
HAL_PCDEx_PMAConfig(&hpcd , 0x80 , PCD_SNG_BUF, 0x70);
|
||||
HAL_PCDEx_PMAConfig(&hpcd , 0x3, PCD_DBL_BUF, 0x018000b0);
|
||||
HAL_PCDEx_PMAConfig(&hpcd , 0x83, PCD_SNG_BUF, 0xb0);
|
||||
|
||||
NVIC_SetVector(USBHAL_IRQn,(uint32_t)&_usbisr);
|
||||
NVIC_SetPriority(USBHAL_IRQn, 1);
|
||||
HAL_PCD_Start(&hpcd);
|
||||
}
|
||||
#endif
|
|
@ -15,4 +15,4 @@
|
|||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM32L476VG.h"
|
||||
#include "USBHAL_STM32L072CZ.h"
|
|
@ -0,0 +1,145 @@
|
|||
/* Copyright (c) 2016 mbed.org, MIT License
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
||||
* and associated documentation files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all copies or
|
||||
* substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
* BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#ifndef USBHAL_STM32L475VG
|
||||
#define USBHAL_STM32L475VG
|
||||
|
||||
#define USBHAL_IRQn OTG_FS_IRQn
|
||||
|
||||
|
||||
#define NB_ENDPOINT 4
|
||||
/* must be multiple of 4 bytes */
|
||||
#define MAXTRANSFER_SIZE 0x200
|
||||
#define FIFO_USB_RAM_SIZE (MAXTRANSFER_SIZE+MAX_PACKET_SIZE_EP0+MAX_PACKET_SIZE_EP1+MAX_PACKET_SIZE_EP2+MAX_PACKET_SIZE_EP3)
|
||||
#if (FIFO_USB_RAM_SIZE > 0x500)
|
||||
#error "FIFO dimensioning incorrect"
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
USBHAL *inst;
|
||||
void (USBHAL::*bus_reset)(void);
|
||||
void (USBHAL::*sof)(int frame);
|
||||
void (USBHAL::*connect_change)(unsigned int connected);
|
||||
void (USBHAL::*suspend_change)(unsigned int suspended);
|
||||
void (USBHAL::*ep0_setup)(void);
|
||||
void (USBHAL::*ep0_in)(void);
|
||||
void (USBHAL::*ep0_out)(void);
|
||||
void (USBHAL::*ep0_read)(void);
|
||||
bool (USBHAL::*ep_realise)(uint8_t endpoint, uint32_t maxPacket, uint32_t flags);
|
||||
bool (USBHAL::*epCallback[2*NB_ENDPOINT-2])(void);
|
||||
uint8_t epComplete[8];
|
||||
/* memorize dummy buffer used for reception */
|
||||
uint32_t pBufRx[MAXTRANSFER_SIZE>>2];
|
||||
uint32_t pBufRx0[MAX_PACKET_SIZE_EP0>>2];
|
||||
}USBHAL_Private_t;
|
||||
|
||||
uint32_t HAL_PCDEx_GetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo)
|
||||
{
|
||||
uint32_t len;
|
||||
if (fifo == 0) len = hpcd->Instance->DIEPTXF0_HNPTXFSIZ>>16;
|
||||
else
|
||||
len = hpcd->Instance->DIEPTXF[fifo - 1] >> 16;
|
||||
return len*4;
|
||||
}
|
||||
void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) {
|
||||
USBHAL_Private_t *priv=((USBHAL_Private_t *)(hpcd->pData));
|
||||
USBHAL *obj= priv->inst;
|
||||
USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
|
||||
uint32_t sofnum = (USBx_DEVICE->DSTS & USB_OTG_DSTS_FNSOF) >> 8;
|
||||
void (USBHAL::*func)(int frame) = priv->sof;
|
||||
/* fix me call with same frame number */
|
||||
(obj->*func)(sofnum);
|
||||
}
|
||||
|
||||
USBHAL * USBHAL::instance;
|
||||
|
||||
USBHAL::USBHAL(void) {
|
||||
/* init parameter */
|
||||
USBHAL_Private_t *HALPriv = new(USBHAL_Private_t);
|
||||
/* initialized all field of init including 0 field */
|
||||
/* constructor does not fill with zero */
|
||||
hpcd.Instance = USB_OTG_FS;
|
||||
/* initialized all field of init including 0 field */
|
||||
/* constructor does not fill with zero */
|
||||
memset(&hpcd.Init, 0, sizeof(hpcd.Init));
|
||||
hpcd.Init.dev_endpoints = NB_ENDPOINT;
|
||||
hpcd.Init.ep0_mps = MAX_PACKET_SIZE_EP0;
|
||||
hpcd.Init.phy_itface = PCD_PHY_EMBEDDED;
|
||||
hpcd.Init.Sof_enable = 1;
|
||||
hpcd.Init.speed = PCD_SPEED_FULL;
|
||||
/* pass instance for usage inside call back */
|
||||
HALPriv->inst = this;
|
||||
HALPriv->bus_reset = &USBHAL::busReset;
|
||||
HALPriv->suspend_change = &USBHAL::suspendStateChanged;
|
||||
HALPriv->connect_change = &USBHAL::connectStateChanged;
|
||||
HALPriv->sof = &USBHAL::SOF;
|
||||
HALPriv->ep0_setup = &USBHAL::EP0setupCallback;
|
||||
HALPriv->ep_realise = &USBHAL::realiseEndpoint;
|
||||
HALPriv->ep0_in = &USBHAL::EP0in;
|
||||
HALPriv->ep0_out = &USBHAL::EP0out;
|
||||
HALPriv->ep0_read = &USBHAL::EP0read;
|
||||
hpcd.pData = (void*)HALPriv;
|
||||
HALPriv->epCallback[0] = &USBHAL::EP1_OUT_callback;
|
||||
HALPriv->epCallback[1] = &USBHAL::EP1_IN_callback;
|
||||
HALPriv->epCallback[2] = &USBHAL::EP2_OUT_callback;
|
||||
HALPriv->epCallback[3] = &USBHAL::EP2_IN_callback;
|
||||
HALPriv->epCallback[4] = &USBHAL::EP3_OUT_callback;
|
||||
HALPriv->epCallback[5] = &USBHAL::EP3_IN_callback;
|
||||
instance = this;
|
||||
|
||||
__HAL_RCC_PWR_CLK_ENABLE();
|
||||
|
||||
HAL_PWREx_EnableVddUSB();
|
||||
/* Configure USB VBUS GPIO */
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
|
||||
/* Configure USB FS GPIOs */
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
|
||||
/* Configure DM DP Pins */
|
||||
pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
|
||||
pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
|
||||
|
||||
/* Configure VBUS Pin */
|
||||
pin_function(PC_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
|
||||
|
||||
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
|
||||
|
||||
hpcd.State = HAL_PCD_STATE_RESET;
|
||||
|
||||
HAL_PCD_Init(&hpcd);
|
||||
/* 1.25kbytes */
|
||||
/* min value 16 (= 16 x 4 bytes) */
|
||||
/* max value 256 (= 1K bytes ) */
|
||||
/* maximum sum is 0x140 */
|
||||
HAL_PCDEx_SetRxFiFo(&hpcd, (MAXTRANSFER_SIZE/4));
|
||||
/* bulk/int 64 bytes in FS */
|
||||
HAL_PCDEx_SetTxFiFo(&hpcd, 0, (MAX_PACKET_SIZE_EP0/4)+1);
|
||||
/* bulk/int bytes in FS */
|
||||
HAL_PCDEx_SetTxFiFo(&hpcd, 1, (MAX_PACKET_SIZE_EP1/4)+1);
|
||||
HAL_PCDEx_SetTxFiFo(&hpcd, 2, (MAX_PACKET_SIZE_EP2/4));
|
||||
/* ISOchronous */
|
||||
HAL_PCDEx_SetTxFiFo(&hpcd, 3, (MAX_PACKET_SIZE_EP3/4));
|
||||
|
||||
NVIC_SetVector(USBHAL_IRQn,(uint32_t)&_usbisr);
|
||||
NVIC_SetPriority( USBHAL_IRQn, 1);
|
||||
|
||||
HAL_PCD_Start(&hpcd);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -15,4 +15,4 @@
|
|||
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include "USBHAL_STM32F303ZE.h"
|
||||
#include "USBHAL_STM32L475VG.h"
|
|
@ -102,11 +102,11 @@ USBHAL::USBHAL(void) {
|
|||
// Enable power and clocking
|
||||
/* board 144 pin all similar */
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
pin_function(PA_8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
|
||||
pin_function(PA_9, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF10_OTG_FS));
|
||||
pin_function(PA_10, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS));
|
||||
pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
|
||||
pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS));
|
||||
pin_function(PA_8, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS)); /* OTG_FS_SOF */
|
||||
pin_function(PA_9, STM_PIN_DATA(STM_MODE_INPUT, GPIO_NOPULL, GPIO_AF10_OTG_FS)); /* OTG_FS_VBUS */
|
||||
pin_function(PA_10, STM_PIN_DATA(STM_MODE_AF_OD, GPIO_PULLUP, GPIO_AF10_OTG_FS)); /* OTG_FS_ID */
|
||||
pin_function(PA_11, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS)); /* OTG_FS_DM */
|
||||
pin_function(PA_12, STM_PIN_DATA(STM_MODE_AF_PP, GPIO_NOPULL, GPIO_AF10_OTG_FS)); /* OTG_FS_DP */
|
||||
|
||||
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
|
||||
__HAL_RCC_SYSCFG_CLK_ENABLE();
|
||||
|
|
|
@ -16,4 +16,22 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#if defined(TARGET_DISCO_L476VG)
|
||||
#include "USBHAL_STM32L476VG.h"
|
||||
|
||||
#elif defined(TARGET_NUCLEO_F303ZE)
|
||||
#include "USBHAL_STM32F303ZE.h"
|
||||
|
||||
#elif defined(TARGET_NUCLEO_F103RB)
|
||||
#include "USBHAL_STM32F103RB.h"
|
||||
|
||||
#elif defined(TARGET_DISCO_F769NI)
|
||||
#include "USBHAL_STM32F769NI.h"
|
||||
|
||||
#elif defined(TARGET_DISCO_L053C8)
|
||||
#include "USBHAL_STM32L053C8.h"
|
||||
|
||||
#else /* default configuration */
|
||||
#include "USBHAL_STM_144_64pins.h"
|
||||
|
||||
#endif
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
/* 144 pins boards */
|
||||
#if defined(TARGET_NUCLEO_F429ZI) || defined(TARGET_NUCLEO_F446ZE) || defined(TARGET_NUCLEO_F207ZG) \
|
||||
|| defined(TARGET_NUCLEO_F767ZI) || defined(TARGET_NUCLEO_F746ZG) || defined(TARGET_NUCLEO_F412ZG)
|
||||
|| defined(TARGET_NUCLEO_F767ZI) || defined(TARGET_NUCLEO_F746ZG) || defined(TARGET_NUCLEO_F412ZG) \
|
||||
|| defined(TARGET_DISCO_F413ZH)
|
||||
#include "USBHALHost_STM_144_64pins.h"
|
||||
#endif
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ AnalogOut out(A1);
|
|||
defined(TARGET_NUCLEO_F303ZE) || \
|
||||
defined(TARGET_NUCLEO_F410RB) || \
|
||||
defined(TARGET_NUCLEO_F446ZE) || \
|
||||
defined(TARGET_NUCLEO_F429ZI)
|
||||
defined(TARGET_NUCLEO_F429ZI) || defined(TARGET_DISCO_L475VG_IOT01A)
|
||||
AnalogIn in(A0);
|
||||
AnalogOut out(D13);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ CAN can1(PD_0, PD_1);
|
|||
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE) || \
|
||||
defined(TARGET_DISCO_F429ZI) || defined(TARGET_NUCLEO_F103RB) || \
|
||||
defined(TARGET_NUCLEO_F746ZG) || defined(TARGET_NUCLEO_L476RG) || \
|
||||
defined(TARGET_NUCLEO_F412ZG) || \
|
||||
defined(TARGET_NUCLEO_F412ZG) || defined(TARGET_DISCO_F413ZH) || \
|
||||
defined(TARGET_NUCLEO_L432KC) || defined(TARGET_DISCO_F303VC)
|
||||
CAN can1(PA_11, PA_12);
|
||||
#elif defined(TARGET_DISCO_F469NI) ||defined(TARGET_DISCO_F746NG)
|
||||
|
@ -35,7 +35,7 @@ CAN can2(p34, p33);
|
|||
CAN can2(p30, p29);
|
||||
#elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_DISCO_F469NI) || \
|
||||
defined(TARGET_DISCO_F429ZI) || defined(TARGET_NUCLEO_F746ZG) || \
|
||||
defined(TARGET_NUCLEO_F412ZG) || \
|
||||
defined(TARGET_NUCLEO_F412ZG) || defined(TARGET_DISCO_F413ZH) || \
|
||||
defined(TARGET_DISCO_F746NG)
|
||||
CAN can2(PB_5, PB_6);
|
||||
#endif
|
||||
|
@ -69,7 +69,7 @@ int main() {
|
|||
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
|
||||
!defined(TARGET_NUCLEO_F303RE) && !defined(TARGET_NUCLEO_F303K8) && \
|
||||
!defined(TARGET_NUCLEO_F302R8) && !defined(TARGET_NUCLEO_F103RB) && \
|
||||
!defined(TARGET_DISCO_L476VG) && !defined(TARGET_NUCLEO_L476RG) && \
|
||||
!defined(TARGET_DISCO_L476VG) && !defined(TARGET_DISCO_L475VG_IOT01A) && !defined(TARGET_NUCLEO_L476RG) && \
|
||||
!defined(TARGET_NUCLEO_L432KC)) && !defined(TARGET_DISCO_F303VC)
|
||||
printf("loop()\n");
|
||||
if(can2.read(msg)) {
|
||||
|
|
|
@ -20,7 +20,7 @@ CAN can1(PD_0, PD_1);
|
|||
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE) || \
|
||||
defined(TARGET_DISCO_F429ZI) || defined(TARGET_NUCLEO_F103RB) || \
|
||||
defined(TARGET_NUCLEO_F746ZG) || defined(TARGET_NUCLEO_L476RG) || \
|
||||
defined(TARGET_NUCLEO_F412ZG) || \
|
||||
defined(TARGET_NUCLEO_F412ZG) || defined(TARGET_DISCO_F413ZH) || \
|
||||
defined(TARGET_NUCLEO_L432KC) || defined(TARGET_DISCO_F303VC)
|
||||
CAN can1(PA_11, PA_12);
|
||||
#elif defined(TARGET_DISCO_F469NI) || defined(TARGET_DISCO_F746NG)
|
||||
|
@ -35,7 +35,7 @@ CAN can2(p34, p33);
|
|||
CAN can2(p30, p29);
|
||||
#elif defined(TARGET_NUCLEO_F446RE) || defined(TARGET_DISCO_F469NI) || \
|
||||
defined(TARGET_DISCO_F429ZI) || defined(TARGET_NUCLEO_F746ZG) || \
|
||||
defined(TARGET_NUCLEO_F412ZG) || \
|
||||
defined(TARGET_NUCLEO_F412ZG) || defined(TARGET_DISCO_F413ZH) || \
|
||||
defined(TARGET_DISCO_F746NG)
|
||||
CAN can2(PB_5, PB_6);
|
||||
#endif
|
||||
|
@ -64,7 +64,7 @@ void send() {
|
|||
!defined(TARGET_NUCLEO_F042K6) && !defined(TARGET_NUCLEO_F334R8) && \
|
||||
!defined(TARGET_NUCLEO_F303RE) && !defined(TARGET_NUCLEO_F303K8) && \
|
||||
!defined(TARGET_NUCLEO_F302R8) && !defined(TARGET_NUCLEO_F103RB) && \
|
||||
!defined(TARGET_DISCO_L476VG) && !defined(TARGET_NUCLEO_L476RG) && \
|
||||
!defined(TARGET_DISCO_L476VG) && !defined(TARGET_DISCO_L475VG_IOT01A) && !defined(TARGET_NUCLEO_L476RG) && \
|
||||
!defined(TARGET_NUCLEO_L432KC) && !defined(TARGET_DISCO_F303VC))
|
||||
void read() {
|
||||
CANMessage msg;
|
||||
|
|
|
@ -18,15 +18,14 @@ CAN can1(P5_9, P5_10);
|
|||
defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F303K8) || \
|
||||
defined(TARGET_NUCLEO_F302R8) || defined(TARGET_NUCLEO_F446RE) || \
|
||||
defined(TARGET_DISCO_F429ZI) || \
|
||||
defined(TARGET_NUCLEO_F746ZG) || defined(TARGET_DISCO_L476VG) || \
|
||||
defined(TARGET_NUCLEO_F412ZG) || \
|
||||
defined(TARGET_NUCLEO_F746ZG) || defined(TARGET_DISCO_L476VG) || defined(TARGET_DISCO_L475VG_IOT01A) || \
|
||||
defined(TARGET_NUCLEO_F412ZG) || defined(TARGET_DISCO_F413ZH) || \
|
||||
defined(TARGET_NUCLEO_L476RG) || defined(TARGET_NUCLEO_L432KC)
|
||||
CAN can1(PA_11, PA_12);
|
||||
#elif defined(TARGET_DISCO_F469NI) || defined(TARGET_DISCO_F746NG) || \
|
||||
defined(TARGET_NUCLEO_F446ZE) || defined(TARGET_NUCLEO_F103RB) || \
|
||||
defined(TARGET_NUCLEO_F207ZG) || defined(TARGET_NUCLEO_F303ZE) || \
|
||||
defined(TARGET_DISCO_F769NI) || defined(TARGET_NUCLEO_F767ZI) || \
|
||||
defined(TARGET_NUCLEO_F412ZG) || \
|
||||
defined(TARGET_DISCO_F303VC)
|
||||
CAN can1(PB_8, PB_9);
|
||||
#endif
|
||||
|
|
|
@ -72,6 +72,9 @@ I2CSlave slave(D2, D4);
|
|||
defined (TARGET_NUCLEO_F072RB)
|
||||
I2CSlave slave(PB_11, D6);
|
||||
|
||||
#elif defined (TARGET_DISCO_L475VG_IOT01A)
|
||||
I2CSlave slave(A4, A5);
|
||||
|
||||
#else
|
||||
I2CSlave slave(D3, D6);
|
||||
|
||||
|
|
|
@ -47,6 +47,8 @@ I2C master(D14, D15); // I2C_SDA, I2C_SCL
|
|||
I2CSlave slave(PB_11, PB_10);
|
||||
#elif defined(TARGET_NUCLEO_F303RE)
|
||||
I2CSlave slave(D2, D8);
|
||||
#elif defined (TARGET_DISCO_L475VG_IOT01A)
|
||||
I2CSlave slave(A4, A5);
|
||||
#else
|
||||
I2CSlave slave(D3, D6);
|
||||
#endif
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
|
||||
namespace mbed {
|
||||
|
||||
class ATCmdParser
|
||||
class ATCmdParser : private NonCopyable<ATCmdParser>
|
||||
{
|
||||
private:
|
||||
// File handle
|
||||
|
@ -70,11 +70,6 @@ private:
|
|||
};
|
||||
oob *_oobs;
|
||||
|
||||
// Prohibiting use of of copy constructor
|
||||
ATCmdParser(const ATCmdParser &);
|
||||
// Prohibiting copy assignment Operator
|
||||
ATCmdParser &operator=(const ATCmdParser &);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "platform/Callback.h"
|
||||
#include "platform/mbed_toolchain.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
#include <string.h>
|
||||
|
||||
namespace mbed {
|
||||
|
@ -65,7 +66,7 @@ namespace mbed {
|
|||
typedef Callback<void()> *pFunctionPointer_t;
|
||||
class CallChainLink;
|
||||
|
||||
class CallChain {
|
||||
class CallChain : private NonCopyable<CallChain> {
|
||||
public:
|
||||
/** Create an empty chain
|
||||
*
|
||||
|
@ -178,10 +179,7 @@ public:
|
|||
return get(i);
|
||||
}
|
||||
|
||||
/* disallow copy constructor and assignment operators */
|
||||
private:
|
||||
CallChain(const CallChain&);
|
||||
CallChain & operator = (const CallChain&);
|
||||
CallChainLink *_chain;
|
||||
};
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <stdint.h>
|
||||
#include "platform/platform.h"
|
||||
#include "platform/FileHandle.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup platform */
|
||||
|
@ -41,7 +42,7 @@ namespace mbed {
|
|||
* @note Synchronization level: Set by subclass
|
||||
* @ingroup platform
|
||||
*/
|
||||
class DirHandle {
|
||||
class DirHandle : private NonCopyable<DirHandle> {
|
||||
public:
|
||||
virtual ~DirHandle() {}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ typedef int FILEHANDLE;
|
|||
#include "platform/platform.h"
|
||||
#include "platform/SingletonPtr.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup platform */
|
||||
|
@ -39,7 +40,7 @@ typedef enum {
|
|||
* @class FileBase
|
||||
* @ingroup platform
|
||||
*/
|
||||
class FileBase {
|
||||
class FileBase : private NonCopyable<FileBase> {
|
||||
public:
|
||||
FileBase(const char *name, PathType t);
|
||||
virtual ~FileBase();
|
||||
|
@ -59,8 +60,6 @@ private:
|
|||
FileBase *_next;
|
||||
const char * const _name;
|
||||
const PathType _path_type;
|
||||
FileBase(const FileBase&);
|
||||
FileBase & operator = (const FileBase&);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -22,6 +22,7 @@ typedef int FILEHANDLE;
|
|||
#include "Callback.h"
|
||||
#include "platform/mbed_poll.h"
|
||||
#include "platform/platform.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup platform */
|
||||
|
@ -37,7 +38,7 @@ namespace mbed {
|
|||
* @note Synchronization level: Set by subclass
|
||||
* @ingroup platform
|
||||
*/
|
||||
class FileHandle {
|
||||
class FileHandle : private NonCopyable<FileHandle> {
|
||||
public:
|
||||
virtual ~FileHandle() {}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "platform/mbed_toolchain.h"
|
||||
#include "platform/FileBase.h"
|
||||
#include "platform/FileHandle.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup platform */
|
||||
|
@ -31,7 +32,7 @@ namespace mbed {
|
|||
* @note Synchronization level: Set by subclass
|
||||
* @ingroup platform
|
||||
*/
|
||||
class FileLike : public FileHandle, public FileBase {
|
||||
class FileLike : public FileHandle, public FileBase, private NonCopyable<FileLike> {
|
||||
public:
|
||||
/** Constructor FileLike
|
||||
*
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "platform/FileBase.h"
|
||||
#include "platform/FileHandle.h"
|
||||
#include "platform/DirHandle.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup drivers */
|
||||
|
@ -35,7 +36,7 @@ namespace mbed {
|
|||
*
|
||||
* @note Synchronization level: Set by subclass
|
||||
*/
|
||||
class FileSystemHandle {
|
||||
class FileSystemHandle : private NonCopyable<FileSystemHandle> {
|
||||
public:
|
||||
/** FileSystemHandle lifetime
|
||||
*/
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "platform/FileSystemHandle.h"
|
||||
#include "platform/FileHandle.h"
|
||||
#include "platform/DirHandle.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup platform */
|
||||
|
@ -35,7 +36,7 @@ namespace mbed {
|
|||
* @note Synchronization level: Set by subclass
|
||||
* @ingroup platform
|
||||
*/
|
||||
class FileSystemLike : public FileSystemHandle, public FileBase {
|
||||
class FileSystemLike : public FileSystemHandle, public FileBase, private NonCopyable<FileSystemLike> {
|
||||
public:
|
||||
/** FileSystemLike lifetime
|
||||
*/
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "platform/FileSystemLike.h"
|
||||
#include "platform/PlatformMutex.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace mbed {
|
||||
/** \addtogroup platform */
|
||||
|
@ -34,7 +35,7 @@ FILEHANDLE local_file_open(const char* name, int flags);
|
|||
* @class LocalFileHandle
|
||||
* @ingroup platform
|
||||
*/
|
||||
class LocalFileHandle : public FileHandle {
|
||||
class LocalFileHandle : public FileHandle, private NonCopyable<LocalFileHandle> {
|
||||
|
||||
public:
|
||||
LocalFileHandle(FILEHANDLE fh);
|
||||
|
@ -98,7 +99,7 @@ protected:
|
|||
* not exit, you will need to hold down reset on the mbed Microcontroller to be able to see the drive again!
|
||||
* @ingroup platform
|
||||
*/
|
||||
class LocalFileSystem : public FileSystemLike {
|
||||
class LocalFileSystem : public FileSystemLike, private NonCopyable<LocalFileSystem> {
|
||||
// No modifiable state
|
||||
|
||||
public:
|
||||
|
|
|
@ -0,0 +1,168 @@
|
|||
/* Copyright (c) 2017 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef MBED_NONCOPYABLE_H_
|
||||
#define MBED_NONCOPYABLE_H_
|
||||
|
||||
namespace mbed {
|
||||
|
||||
/**
|
||||
* Inheriting from this class autogeneration of copy construction and copy
|
||||
* assignement operations.
|
||||
*
|
||||
* Classes which are not value type should inherit privately from this class
|
||||
* to avoid generation of invalid copy constructor or copy assignement operator
|
||||
* which can lead to unoticeable programming errors.
|
||||
*
|
||||
* As an example consider the following signature:
|
||||
*
|
||||
* @code
|
||||
* class Resource;
|
||||
*
|
||||
* class Foo {
|
||||
* public:
|
||||
* Foo() : _resource(new Resource()) { }
|
||||
* ~Foo() { delete _resource; }
|
||||
* private:
|
||||
* Resource* _resource;
|
||||
* }
|
||||
*
|
||||
* Foo get_foo();
|
||||
*
|
||||
* Foo foo = get_foo();
|
||||
* @endcode
|
||||
*
|
||||
* There is a bug in this function, it returns a temporary value which will be
|
||||
* byte copied into foo then destroyed. Unfortunately, internaly the Foo class
|
||||
* manage a pointer to a Resource object. This pointer will be released when the
|
||||
* temporary is destroyed and foo will manage a pointer to an already released
|
||||
* Resource.
|
||||
*
|
||||
* Two issues has to be fixed in the example above:
|
||||
* - Function signature has to be changed to reflect the fact that Foo
|
||||
* instances cannot be copied. In that case accessor should return a
|
||||
* reference to give access to objects already existing and managed.
|
||||
* Generator on the other hand should return a pointer to the created object.
|
||||
*
|
||||
* @code
|
||||
* // return a reference to an already managed Foo instance
|
||||
* Foo& get_foo();
|
||||
* Foo& foo = get_foo();
|
||||
*
|
||||
* // create a new Foo instance
|
||||
* Foo* make_foo();
|
||||
* Foo* m = make_foo();
|
||||
* @endcode
|
||||
*
|
||||
* - Copy constructor and copy assignement operator has to be made private
|
||||
* in the Foo class. It prevents unwanted copy of Foo objects. This can be
|
||||
* done by declaring copy constructor and copy assignement in the private
|
||||
* section of the Foo class.
|
||||
*
|
||||
* @code
|
||||
* class Foo {
|
||||
* public:
|
||||
* Foo() : _resource(new Resource()) { }
|
||||
* ~Foo() { delete _resource; }
|
||||
* private:
|
||||
* // disallow copy operations
|
||||
* Foo(const Foo&);
|
||||
* Foo& operator=(const Foo&);
|
||||
* // data members
|
||||
* Resource* _resource;
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
* Another solution is to inherit privately from the NonCopyable class.
|
||||
* It reduces the boiler plate needed to avoid copy operations but more
|
||||
* importantly it clarifies the programer intent and the object semantic.
|
||||
*
|
||||
* class Foo : private NonCopyable<Foo> {
|
||||
* public:
|
||||
* Foo() : _resource(new Resource()) { }
|
||||
* ~Foo() { delete _resource; }
|
||||
* private:
|
||||
* Resource* _resource;
|
||||
* }
|
||||
*
|
||||
* @tparam T The type that should be made non copyable. It prevent cases where
|
||||
* the empty base optimization cannot be applied and therefore ensure that the
|
||||
* cost of this semantic sugar is null.
|
||||
*
|
||||
* As an example, the empty base optimization is prohibited if one of the empty
|
||||
* base class is also a base type of the first non static data member:
|
||||
*
|
||||
* @code
|
||||
* struct A { };
|
||||
* struct B : A {
|
||||
* int foo;
|
||||
* };
|
||||
* // thanks to empty base optimization, sizeof(B) == sizeof(int)
|
||||
*
|
||||
* struct C : A {
|
||||
* B b;
|
||||
* };
|
||||
*
|
||||
* // empty base optimization cannot be applied here because A from C and A from
|
||||
* // B shall have a different address. In that case, with the alignement
|
||||
* // sizeof(C) == 2* sizeof(int)
|
||||
* @endcode
|
||||
*
|
||||
* The solution to that problem is to templatize the empty class to makes it
|
||||
* unique to the type it is applied to:
|
||||
*
|
||||
* @code
|
||||
* template<typename T>
|
||||
* struct A<T> { };
|
||||
* struct B : A<B> {
|
||||
* int foo;
|
||||
* };
|
||||
* struct C : A<C> {
|
||||
* B b;
|
||||
* };
|
||||
*
|
||||
* // empty base optimization can be applied B and C does not refer to the same
|
||||
* // kind of A. sizeof(C) == sizeof(B) == sizeof(int).
|
||||
* @endcode
|
||||
*/
|
||||
template<typename T>
|
||||
class NonCopyable {
|
||||
protected:
|
||||
/**
|
||||
* Disalow construction of NonCopyable objects from outside of its hierarchy.
|
||||
*/
|
||||
NonCopyable() { }
|
||||
/**
|
||||
* Disalow destruction of NonCopyable objects from outside of its hierarchy.
|
||||
*/
|
||||
~NonCopyable() { }
|
||||
|
||||
private:
|
||||
/**
|
||||
* Declare copy constructor as private, any attempt to copy construct
|
||||
* a NonCopyable will fail at compile time.
|
||||
*/
|
||||
NonCopyable(const NonCopyable&);
|
||||
|
||||
/**
|
||||
* Declare copy assignement operator as private, any attempt to copy assign
|
||||
* a NonCopyable will fail at compile time.
|
||||
*/
|
||||
NonCopyable& operator=(const NonCopyable&);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
||||
#endif /* MBED_NONCOPYABLE_H_ */
|
|
@ -18,6 +18,8 @@
|
|||
#ifndef PLATFORM_MUTEX_H
|
||||
#define PLATFORM_MUTEX_H
|
||||
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
#ifdef MBED_CONF_RTOS_PRESENT
|
||||
#include "rtos/Mutex.h"
|
||||
typedef rtos::Mutex PlatformMutex;
|
||||
|
@ -25,7 +27,7 @@ typedef rtos::Mutex PlatformMutex;
|
|||
/** A stub mutex for when an RTOS is not present
|
||||
* @ingroup platform
|
||||
*/
|
||||
class PlatformMutex {
|
||||
class PlatformMutex : private mbed::NonCopyable<PlatformMutex> {
|
||||
public:
|
||||
PlatformMutex() {
|
||||
// Stub
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "platform/platform.h"
|
||||
#include "platform/FileLike.h"
|
||||
#include "platform/FileHandle.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
|
||||
|
@ -36,7 +37,7 @@ extern char* mbed_gets(char *s, int size, std::FILE *_file);
|
|||
* @note Synchronization level: Set by subclass
|
||||
* @ingroup platform
|
||||
*/
|
||||
class Stream : public FileLike {
|
||||
class Stream : public FileLike, private NonCopyable<Stream> {
|
||||
|
||||
public:
|
||||
Stream(const char *name=NULL);
|
||||
|
@ -80,11 +81,6 @@ protected:
|
|||
virtual void unlock() {
|
||||
// Stub
|
||||
}
|
||||
|
||||
/* disallow copy constructor and assignment operators */
|
||||
private:
|
||||
Stream(const Stream&);
|
||||
Stream & operator = (const Stream&);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -1014,6 +1014,11 @@ extern "C" void EvrRtxMutexError (osMutexId_t mutex_id, int32_t status)
|
|||
|
||||
extern "C" void EvrRtxSemaphoreError (osSemaphoreId_t semaphore_id, int32_t status)
|
||||
{
|
||||
// Ignore semaphore overflow, the count will saturate with a returned error
|
||||
if (status == osRtxErrorSemaphoreCountLimit) {
|
||||
return;
|
||||
}
|
||||
|
||||
error("Semaphore %p error %i\r\n", semaphore_id, status);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include "rtx_lib.h"
|
||||
#include "mbed_rtos1_types.h"
|
||||
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
using namespace rtos;
|
||||
|
||||
namespace rtos {
|
||||
|
@ -47,7 +49,7 @@ namespace rtos {
|
|||
both for the mbed OS and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
|
||||
*/
|
||||
template<typename T, uint32_t queue_sz>
|
||||
class Mail {
|
||||
class Mail : private mbed::NonCopyable<Mail<T, queue_sz> > {
|
||||
public:
|
||||
/** Create and Initialise Mail queue. */
|
||||
Mail() { };
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "cmsis_os2.h"
|
||||
#include "mbed_rtos1_types.h"
|
||||
#include "mbed_rtos_storage.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace rtos {
|
||||
/** \addtogroup rtos */
|
||||
|
@ -42,7 +43,7 @@ namespace rtos {
|
|||
both for the mbed OS and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
|
||||
*/
|
||||
template<typename T, uint32_t pool_sz>
|
||||
class MemoryPool {
|
||||
class MemoryPool : private mbed::NonCopyable<MemoryPool<T, pool_sz> > {
|
||||
public:
|
||||
/** Create and Initialize a memory pool. */
|
||||
MemoryPool() {
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
#include "mbed_rtos1_types.h"
|
||||
#include "mbed_rtos_storage.h"
|
||||
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace rtos {
|
||||
/** \addtogroup rtos */
|
||||
/** @{*/
|
||||
|
@ -38,7 +40,7 @@ namespace rtos {
|
|||
Memory considerations: The mutex control structures will be created on current thread's stack, both for the mbed OS
|
||||
and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
|
||||
*/
|
||||
class Mutex {
|
||||
class Mutex : private mbed::NonCopyable<Mutex> {
|
||||
public:
|
||||
/** Create and Initialize a Mutex object */
|
||||
Mutex();
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "cmsis_os2.h"
|
||||
#include "mbed_rtos_storage.h"
|
||||
#include "platform/mbed_error.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
#include "mbed_rtos1_types.h"
|
||||
|
||||
namespace rtos {
|
||||
|
@ -45,7 +46,7 @@ namespace rtos {
|
|||
and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
|
||||
*/
|
||||
template<typename T, uint32_t queue_sz>
|
||||
class Queue {
|
||||
class Queue : private mbed::NonCopyable<Queue<T, queue_sz> > {
|
||||
public:
|
||||
/** Create and initialize a message Queue. */
|
||||
Queue() {
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "cmsis_os2.h"
|
||||
#include "rtx_lib.h"
|
||||
#include "platform/Callback.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
#include "platform/mbed_toolchain.h"
|
||||
#include "mbed_rtos1_types.h"
|
||||
|
||||
|
@ -79,7 +80,7 @@ namespace rtos {
|
|||
Memory considerations: The timer control structures will be created on current thread's stack, both for the mbed OS
|
||||
and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
|
||||
*/
|
||||
class RtosTimer {
|
||||
class RtosTimer : private mbed::NonCopyable<RtosTimer> {
|
||||
public:
|
||||
/** Create timer.
|
||||
@param func function to be executed by this timer.
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
namespace rtos {
|
||||
|
||||
Semaphore::Semaphore(int32_t count) {
|
||||
constructor(count, 1024);
|
||||
constructor(count, 0xffff);
|
||||
}
|
||||
|
||||
Semaphore::Semaphore(int32_t count, uint16_t max_count) {
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "cmsis_os2.h"
|
||||
#include "mbed_rtos1_types.h"
|
||||
#include "mbed_rtos_storage.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
|
||||
namespace rtos {
|
||||
/** \addtogroup rtos */
|
||||
|
@ -37,7 +38,7 @@ namespace rtos {
|
|||
* Memory considerations: The semaphore control structures will be created on current thread's stack, both for the mbed OS
|
||||
* and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
|
||||
*/
|
||||
class Semaphore {
|
||||
class Semaphore : private mbed::NonCopyable<Semaphore> {
|
||||
public:
|
||||
/** Create and Initialize a Semaphore object used for managing resources.
|
||||
@param count number of available resources; maximum index value is (count-1). (default: 0).
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "mbed_rtx_conf.h"
|
||||
#include "platform/Callback.h"
|
||||
#include "platform/mbed_toolchain.h"
|
||||
#include "platform/NonCopyable.h"
|
||||
#include "rtos/Semaphore.h"
|
||||
#include "rtos/Mutex.h"
|
||||
|
||||
|
@ -69,7 +70,7 @@ namespace rtos {
|
|||
* and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
|
||||
* Additionally the stack memory for this thread will be allocated on the heap, if it wasn't supplied to the constructor.
|
||||
*/
|
||||
class Thread {
|
||||
class Thread : private mbed::NonCopyable<Thread> {
|
||||
public:
|
||||
/** Allocate a new thread without starting execution
|
||||
@param priority initial priority of the thread function. (default: osPriorityNormal).
|
||||
|
@ -348,10 +349,6 @@ public:
|
|||
virtual ~Thread();
|
||||
|
||||
private:
|
||||
/* disallow copy constructor and assignment operators */
|
||||
Thread(const Thread&);
|
||||
Thread& operator=(const Thread&);
|
||||
|
||||
// Required to share definitions without
|
||||
// delegated constructors
|
||||
void constructor(osPriority priority=osPriorityNormal,
|
||||
|
|
|
@ -32,7 +32,9 @@
|
|||
#define OS_STACK_SIZE MBED_CONF_APP_THREAD_STACK_SIZE
|
||||
|
||||
#define OS_TIMER_THREAD_STACK_SIZE 768
|
||||
#ifndef OS_IDLE_THREAD_STACK_SIZE
|
||||
#define OS_IDLE_THREAD_STACK_SIZE 256
|
||||
#endif
|
||||
|
||||
#define OS_DYNAMIC_MEM_SIZE 0
|
||||
|
||||
|
|
|
@ -30,201 +30,204 @@ typedef enum {
|
|||
#define PORT_SHIFT 5
|
||||
|
||||
typedef enum {
|
||||
// MPS2 EXP Pin Names
|
||||
EXP0 = 0 ,
|
||||
EXP1 = 4 ,
|
||||
EXP2 = 2 ,
|
||||
EXP3 = 3 ,
|
||||
EXP4 = 1 ,
|
||||
EXP5 = 15,
|
||||
EXP6 = 5 ,
|
||||
EXP7 = 6 ,
|
||||
EXP8 = 7 ,
|
||||
EXP9 = 8 ,
|
||||
EXP10 =9 ,
|
||||
EXP11 =13,
|
||||
EXP12 =10,
|
||||
EXP13 =11,
|
||||
EXP14 =12,
|
||||
EXP15 =14,
|
||||
EXP16 =18,
|
||||
EXP17 =19,
|
||||
EXP18 =20,
|
||||
EXP19 =21,
|
||||
EXP20 =52,
|
||||
EXP21 =53,
|
||||
EXP22 =54,
|
||||
EXP23 =55,
|
||||
EXP24 =56,
|
||||
EXP25 =57,
|
||||
|
||||
EXP26 =16,
|
||||
EXP27 =25,
|
||||
EXP28 =24,
|
||||
EXP29 =31,
|
||||
EXP30 =17,
|
||||
EXP31 =23,
|
||||
EXP32 =27,
|
||||
EXP33 =30,
|
||||
EXP34 =26,
|
||||
EXP35 =28,
|
||||
EXP36 =29,
|
||||
EXP37 =58,
|
||||
EXP38 =48,
|
||||
EXP39 =49,
|
||||
EXP40 =50,
|
||||
EXP41 =22,
|
||||
EXP42 =59,
|
||||
EXP43 =60,
|
||||
EXP44 =51,
|
||||
EXP45 =61,
|
||||
EXP46 =62,
|
||||
EXP47 =63,
|
||||
EXP48 =64,
|
||||
EXP49 =65,
|
||||
EXP50 =66,
|
||||
EXP51 =67,
|
||||
/* MPS2 EXP Pin Names */
|
||||
EXP0 = 0,
|
||||
EXP1 = 1,
|
||||
EXP2 = 2,
|
||||
EXP3 = 3,
|
||||
EXP4 = 4,
|
||||
EXP5 = 5,
|
||||
EXP6 = 6,
|
||||
EXP7 = 7,
|
||||
EXP8 = 8,
|
||||
EXP9 = 9,
|
||||
EXP10 = 10,
|
||||
EXP11 = 11,
|
||||
EXP12 = 12,
|
||||
EXP13 = 13,
|
||||
EXP14 = 14,
|
||||
EXP15 = 15,
|
||||
EXP16 = 16,
|
||||
EXP17 = 17,
|
||||
EXP18 = 18,
|
||||
EXP19 = 19,
|
||||
EXP20 = 20,
|
||||
EXP21 = 21,
|
||||
EXP22 = 22,
|
||||
EXP23 = 23,
|
||||
EXP24 = 24,
|
||||
EXP25 = 25,
|
||||
EXP26 = 26,
|
||||
EXP27 = 27,
|
||||
EXP28 = 28,
|
||||
EXP29 = 29,
|
||||
EXP30 = 30,
|
||||
EXP31 = 31,
|
||||
EXP32 = 32,
|
||||
EXP33 = 33,
|
||||
EXP34 = 34,
|
||||
EXP35 = 35,
|
||||
EXP36 = 36,
|
||||
EXP37 = 37,
|
||||
EXP38 = 38,
|
||||
EXP39 = 39,
|
||||
EXP40 = 40,
|
||||
EXP41 = 41,
|
||||
EXP42 = 42,
|
||||
EXP43 = 43,
|
||||
EXP44 = 44,
|
||||
EXP45 = 45,
|
||||
EXP46 = 46,
|
||||
EXP47 = 47,
|
||||
EXP48 = 48,
|
||||
EXP49 = 49,
|
||||
EXP50 = 50,
|
||||
EXP51 = 51,
|
||||
|
||||
// Other mbed Pin Names
|
||||
|
||||
//LEDs on mps2
|
||||
//user leds
|
||||
USERLED1 = 100,
|
||||
USERLED2 = 101,
|
||||
//user switches
|
||||
USERSW1 = 110,
|
||||
USERSW2 = 111,
|
||||
/* User leds */
|
||||
USERLED1 = 100,
|
||||
USERLED2 = 101,
|
||||
/* User switches */
|
||||
USERSW1 = 110,
|
||||
USERSW2 = 111,
|
||||
|
||||
//mcc leds
|
||||
LED1 = 200,
|
||||
LED2 = 201,
|
||||
LED3 = 202,
|
||||
LED4 = 203,
|
||||
LED5 = 204,
|
||||
LED6 = 205,
|
||||
LED7 = 206,
|
||||
LED8 = 207,
|
||||
/* MCC leds */
|
||||
LED1 = 200,
|
||||
LED2 = 201,
|
||||
LED3 = 202,
|
||||
LED4 = 203,
|
||||
LED5 = 204,
|
||||
LED6 = 205,
|
||||
LED7 = 206,
|
||||
LED8 = 207,
|
||||
|
||||
//MCC Switches
|
||||
SW1 = 210,
|
||||
SW2 = 211,
|
||||
SW3 = 212,
|
||||
SW4 = 213,
|
||||
SW5 = 214,
|
||||
SW6 = 215,
|
||||
SW7 = 216,
|
||||
SW8 = 217,
|
||||
/* MCC Switches */
|
||||
SW1 = 210,
|
||||
SW2 = 211,
|
||||
SW3 = 212,
|
||||
SW4 = 213,
|
||||
SW5 = 214,
|
||||
SW6 = 215,
|
||||
SW7 = 216,
|
||||
SW8 = 217,
|
||||
|
||||
//MPS2 SPI header pins j21
|
||||
SPI_MOSI = 300,
|
||||
SPI_MISO = 301,
|
||||
SPI_SCLK = 302,
|
||||
SPI_SSEL = 303,
|
||||
/* MPS2 SPI header pins J21 */
|
||||
SPI_MOSI = 300,
|
||||
SPI_MISO = 301,
|
||||
SPI_SCLK = 302,
|
||||
SPI_SSEL = 303,
|
||||
|
||||
//MPS2 CLCD SPI
|
||||
CLCD_MOSI = 304,
|
||||
CLCD_MISO = 305,
|
||||
CLCD_SCLK = 306,
|
||||
CLCD_SSEL = 307,
|
||||
CLCD_RESET = 308,
|
||||
CLCD_RS = 309,
|
||||
CLCD_RD = 310,
|
||||
CLCD_BL_CTRL = 311,
|
||||
/* MPS2 CLCD SPI */
|
||||
CLCD_MOSI = 304,
|
||||
CLCD_MISO = 305,
|
||||
CLCD_SCLK = 306,
|
||||
CLCD_SSEL = 307,
|
||||
CLCD_RESET = 308,
|
||||
CLCD_RS = 309,
|
||||
CLCD_RD = 310,
|
||||
CLCD_BL_CTRL = 311,
|
||||
|
||||
//MPS2 shield 0 SPI
|
||||
SHIELD_0_SPI_SCK = 320,
|
||||
SHIELD_0_SPI_MOSI = 321,
|
||||
SHIELD_0_SPI_MISO = 322,
|
||||
SHIELD_0_SPI_nCS = 323,
|
||||
/* MPS2 shield 0 SPI */
|
||||
SHIELD_0_SPI_MOSI = EXP13,
|
||||
SHIELD_0_SPI_MISO = EXP14,
|
||||
SHIELD_0_SPI_SCK = EXP11,
|
||||
SHIELD_0_SPI_nCS = EXP12,
|
||||
|
||||
//MPS2 shield 1 SPI
|
||||
SHIELD_1_SPI_SCK = 331,
|
||||
SHIELD_1_SPI_MOSI = 332,
|
||||
SHIELD_1_SPI_MISO = 333,
|
||||
SHIELD_1_SPI_nCS = 334,
|
||||
/* MPS2 shield 1 SPI */
|
||||
SHIELD_1_SPI_MOSI = EXP39,
|
||||
SHIELD_1_SPI_MISO = EXP40,
|
||||
SHIELD_1_SPI_SCK = EXP44,
|
||||
SHIELD_1_SPI_nCS = EXP38,
|
||||
|
||||
//MPS2 shield ADC SPI
|
||||
ADC_MOSI = 650,
|
||||
ADC_MISO = 651,
|
||||
ADC_SCLK = 652,
|
||||
ADC_SSEL = 653,
|
||||
/* MPS2 shield ADC SPI */
|
||||
ADC_MOSI = EXP18,
|
||||
ADC_MISO = EXP17,
|
||||
ADC_SCLK = EXP19,
|
||||
ADC_SSEL = EXP16,
|
||||
|
||||
//MPS2 Uart
|
||||
USBTX = 400,
|
||||
USBRX = 401,
|
||||
XB_TX = 402,
|
||||
XB_RX = 403,
|
||||
SH0_TX = 404,
|
||||
SH0_RX = 405,
|
||||
SH1_TX = 406,
|
||||
SH1_RX = 407,
|
||||
MCC_TX = 408,
|
||||
MCC_RX = 409,
|
||||
/* MPS2 UART */
|
||||
MCC_TX = 400,
|
||||
MCC_RX = 401,
|
||||
USBTX = 402,
|
||||
USBRX = 403,
|
||||
XB_TX = EXP24,
|
||||
XB_RX = EXP23,
|
||||
SH0_TX = EXP4,
|
||||
SH0_RX = EXP0,
|
||||
SH1_TX = EXP30,
|
||||
SH1_RX = EXP26,
|
||||
|
||||
//MPS2 I2C touchscreen and audio
|
||||
TSC_SDA = 500,
|
||||
TSC_SCL = 501,
|
||||
AUD_SDA = 502,
|
||||
AUD_SCL = 503,
|
||||
/* MPS2 I2C touchscreen and audio */
|
||||
TSC_SDA = 500,
|
||||
TSC_SCL = 501,
|
||||
AUD_SDA = 502,
|
||||
AUD_SCL = 503,
|
||||
|
||||
//MPS2 I2C for shield
|
||||
SHIELD_0_SDA = 504,
|
||||
SHIELD_0_SCL = 505,
|
||||
SHIELD_1_SDA = 506,
|
||||
SHIELD_1_SCL = 507,
|
||||
/* MPS2 I2C for shield */
|
||||
SHIELD_0_SDA = EXP15,
|
||||
SHIELD_0_SCL = EXP5,
|
||||
SHIELD_1_SDA = EXP41,
|
||||
SHIELD_1_SCL = EXP31,
|
||||
|
||||
//MPS2 shield Analog pins
|
||||
A0_0 = 600,
|
||||
A0_1 = 601,
|
||||
A0_2 = 602,
|
||||
A0_3 = 603,
|
||||
A0_4 = 604,
|
||||
A0_5 = 605,
|
||||
A1_0 = 606,
|
||||
A1_1 = 607,
|
||||
A1_2 = 608,
|
||||
A1_3 = 609,
|
||||
A1_4 = 610,
|
||||
A1_5 = 611,
|
||||
//MPS2 Shield Digital pins
|
||||
D0_0 = EXP0,
|
||||
D0_1 = EXP4,
|
||||
D0_2 = EXP2,
|
||||
D0_3 = EXP3,
|
||||
D0_4 = EXP1,
|
||||
D0_5 = EXP6,
|
||||
D0_6 = EXP7,
|
||||
D0_7 = EXP8,
|
||||
D0_8 = EXP9,
|
||||
D0_9 = EXP10,
|
||||
D0_10 = EXP12,
|
||||
D0_11 = EXP13,
|
||||
D0_12 = EXP14,
|
||||
D0_13 = EXP11,
|
||||
D0_14 = EXP15,
|
||||
D0_15 = EXP5,
|
||||
/* MPS2 shield Analog pins */
|
||||
A0_0 = 600,
|
||||
A0_1 = 601,
|
||||
A0_2 = 602,
|
||||
A0_3 = 603,
|
||||
A0_4 = 604,
|
||||
A0_5 = 605,
|
||||
A1_0 = 606,
|
||||
A1_1 = 607,
|
||||
A1_2 = 608,
|
||||
A1_3 = 609,
|
||||
A1_4 = 610,
|
||||
A1_5 = 611,
|
||||
/* MPS2 Shield Digital pins */
|
||||
D0_0 = EXP0,
|
||||
D0_1 = EXP4,
|
||||
D0_2 = EXP2,
|
||||
D0_3 = EXP3,
|
||||
D0_4 = EXP1,
|
||||
D0_5 = EXP6,
|
||||
D0_6 = EXP7,
|
||||
D0_7 = EXP8,
|
||||
D0_8 = EXP9,
|
||||
D0_9 = EXP10,
|
||||
D0_10 = EXP12,
|
||||
D0_11 = EXP13,
|
||||
D0_12 = EXP14,
|
||||
D0_13 = EXP11,
|
||||
D0_14 = EXP15,
|
||||
D0_15 = EXP5,
|
||||
|
||||
D1_0 = EXP26,
|
||||
D1_1 = EXP30,
|
||||
D1_2 = EXP28,
|
||||
D1_3 = EXP29,
|
||||
D1_4 = EXP27,
|
||||
D1_5 = EXP32,
|
||||
D1_6 = EXP33,
|
||||
D1_7 = EXP34,
|
||||
D1_8 = EXP35,
|
||||
D1_9 = EXP36,
|
||||
D1_10 = EXP38,
|
||||
D1_11 = EXP39,
|
||||
D1_12 = EXP40,
|
||||
D1_13 = EXP44,
|
||||
D1_14 = EXP41,
|
||||
D1_15 = EXP31,
|
||||
D1_0 = EXP26,
|
||||
D1_1 = EXP30,
|
||||
D1_2 = EXP28,
|
||||
D1_3 = EXP29,
|
||||
D1_4 = EXP27,
|
||||
D1_5 = EXP32,
|
||||
D1_6 = EXP33,
|
||||
D1_7 = EXP34,
|
||||
D1_8 = EXP35,
|
||||
D1_9 = EXP36,
|
||||
D1_10 = EXP38,
|
||||
D1_11 = EXP39,
|
||||
D1_12 = EXP40,
|
||||
D1_13 = EXP44,
|
||||
D1_14 = EXP41,
|
||||
D1_15 = EXP31,
|
||||
|
||||
// Not connected
|
||||
NC = (int)0xFFFFFFFF,
|
||||
/* Not connected */
|
||||
NC = (int)0xFFFFFFFF,
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
ALTERNATE_FUNC = 0, /* The pin is used for alternative function */
|
||||
GPIO_FUNC = 1 /* The pin is used for GPIO function */
|
||||
} PinFunction;
|
||||
|
||||
typedef enum {
|
||||
PullUp = 2,
|
||||
PullDown = 1,
|
||||
|
|
|
@ -22,7 +22,9 @@ extern "C" {
|
|||
|
||||
typedef enum {
|
||||
Port0 = 0,
|
||||
Port1 = 1
|
||||
Port1,
|
||||
Port2,
|
||||
Port3,
|
||||
} PortName;
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -0,0 +1,153 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2017 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This HAL implementation uses the AD7490 analog-to-digital converter
|
||||
* available on the MPS2 Adapter for Arduino shields.
|
||||
*/
|
||||
|
||||
#include "analogin_api.h"
|
||||
#include "gpio_api.h"
|
||||
#include "spi_api.h"
|
||||
#include "mbed_error.h"
|
||||
#include "mbed_wait_api.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
/*
|
||||
* There is only one AD7490 controller to read the analog pins in both shields.
|
||||
* The AD7490 documentation (AD7490.pdf, page 12) tells us the right control
|
||||
* register to send.
|
||||
*/
|
||||
|
||||
/* Output conversion is straight binary */
|
||||
#define CODING (1 << 0)
|
||||
/* Analog input range from 0 to REF_IN volts */
|
||||
#define RANGE (1 << 1)
|
||||
/* DOUT line state, weakly driven or three-state */
|
||||
#define WEAK_TRI (1 << 2)
|
||||
/* Access to the shadow register */
|
||||
#define SHADOW (1 << 3)
|
||||
/* Normal operation power mode */
|
||||
#define PM0 (1 << 4)
|
||||
/* Normal operation power mode */
|
||||
#define PM1 (1 << 5)
|
||||
/* Write control register */
|
||||
#define WRITE (1 << 11)
|
||||
#define NORMAL_CONTROL_REGISTER (CODING | RANGE | PM0 | PM1 | WRITE)
|
||||
/* The ADC will ignore the write of this control register */
|
||||
#define NO_WRITE_CONTROL_REGISTER 0x000
|
||||
/* Bit position of the channel number in the control register */
|
||||
#define CHANNEL_NUMBER_POSITION 6
|
||||
/* CS signal of the ADC needs to be put low during transfers */
|
||||
#define CS_LOW 0
|
||||
#define CS_HIGH 1
|
||||
/* The ADC expects a 16 bits word but only read the 12 most significant bits */
|
||||
#define USELESS_ADC_BITS 4
|
||||
/* The ADC result is on the 12 least significant bits */
|
||||
#define OUTPUT_DATA_MASK 0xFFF
|
||||
/* The maximum value is the biggest value than can be coded on 12 bits */
|
||||
#define MAXIMUM_VALUE_12_BITS OUTPUT_DATA_MASK
|
||||
#define FRAME_16_BITS 16
|
||||
#define NO_POLARITY_NO_PHASE 0
|
||||
#define MASTER_MODE 0
|
||||
/* Maximal SPI frequency as written in the ADC documentation */
|
||||
#define MAXIMAL_SPI_FREQUENCY_HZ 12000000
|
||||
|
||||
/* The value of the peripheral constant linked with one analog pins is the
|
||||
* channel number of that pin on the ADC:
|
||||
* A0_0 is channel 0
|
||||
* ...
|
||||
* A0_5 is channel 5
|
||||
* A1_0 is channel 6
|
||||
* ...
|
||||
* A1_5 is channel 11
|
||||
*/
|
||||
static const PinMap PinMap_ADC[] = {
|
||||
{A0_0, ADC0_0, 0},
|
||||
{A0_1, ADC0_1, 0},
|
||||
{A0_2, ADC0_2, 0},
|
||||
{A0_3, ADC0_3, 0},
|
||||
{A0_4, ADC0_4, 0},
|
||||
{A0_5, ADC0_5, 0},
|
||||
{A1_0, ADC0_6, 0},
|
||||
{A1_1, ADC0_7, 0},
|
||||
{A1_2, ADC0_8, 0},
|
||||
{A1_3, ADC0_9, 0},
|
||||
{A1_4, ADC0_10, 0},
|
||||
{A1_5, ADC0_11, 0},
|
||||
{NC , NC, 0}
|
||||
};
|
||||
|
||||
/* mbed OS gpio_t structure for the CS pin linked to the ADC */
|
||||
static gpio_t adc_cs;
|
||||
|
||||
/* mbed OS spi_t structure to communicate with the ADC */
|
||||
static spi_t adc_spi;
|
||||
|
||||
void analogin_init(analogin_t *obj, PinName pin)
|
||||
{
|
||||
uint16_t control_register = NORMAL_CONTROL_REGISTER;
|
||||
uint32_t channel_number = pinmap_peripheral(pin, PinMap_ADC);
|
||||
|
||||
if (channel_number == (uint32_t)NC) {
|
||||
error("pin %d is not connected to the ADC", pin);
|
||||
}
|
||||
|
||||
/* Add the channel number to the control register */
|
||||
control_register |= (channel_number << CHANNEL_NUMBER_POSITION);
|
||||
/* Only the 12 first bits are taken into account */
|
||||
control_register <<= USELESS_ADC_BITS;
|
||||
obj->ctrl_register = control_register;
|
||||
|
||||
spi_init(&adc_spi, ADC_MOSI, ADC_MISO, ADC_SCLK, NC);
|
||||
spi_format(&adc_spi, FRAME_16_BITS, NO_POLARITY_NO_PHASE, MASTER_MODE);
|
||||
spi_frequency(&adc_spi, MAXIMAL_SPI_FREQUENCY_HZ);
|
||||
|
||||
gpio_init_out(&adc_cs, ADC_SSEL);
|
||||
}
|
||||
|
||||
uint16_t analogin_read_u16(analogin_t *obj)
|
||||
{
|
||||
uint16_t result;
|
||||
|
||||
/* Request conversion */
|
||||
gpio_write(&adc_cs, CS_LOW);
|
||||
/* Only write the control register, ignore the previous results */
|
||||
(void)spi_master_write(&adc_spi, obj->ctrl_register);
|
||||
gpio_write(&adc_cs, CS_HIGH);
|
||||
|
||||
/*
|
||||
* According to the documentation, t_QUIET (50 ns) time needs to pass before
|
||||
* accessing to the SPI bus again. We wait here 1 us as we can not wait a
|
||||
* shorter time than that.
|
||||
*/
|
||||
wait_us(1);
|
||||
|
||||
/* Read conversion result */
|
||||
gpio_write(&adc_cs, CS_LOW);
|
||||
/* Only read the results without writing the control register */
|
||||
result = spi_master_write(&adc_spi, NO_WRITE_CONTROL_REGISTER);
|
||||
gpio_write(&adc_cs, CS_HIGH);
|
||||
|
||||
return (result & OUTPUT_DATA_MASK);
|
||||
}
|
||||
|
||||
float analogin_read(analogin_t *obj)
|
||||
{
|
||||
uint16_t result = analogin_read_u16(obj);
|
||||
|
||||
return (result * (1. / MAXIMUM_VALUE_12_BITS));
|
||||
}
|
|
@ -93,8 +93,8 @@ typedef enum IRQn
|
|||
MPS2_SPI0_IRQn = 49, /* SPI Interrupt (spi header) */
|
||||
MPS2_SPI1_IRQn = 50, /* SPI Interrupt (clcd) */
|
||||
MPS2_SPI2_IRQn = 51, /* SPI Interrupt (spi 1 ADC replacement) */
|
||||
MPS2_SPI3_IRQn = 52, /* SPI Interrupt (spi 0 shield 0 replacement) */
|
||||
MPS2_SPI4_IRQn = 53, /* SPI Interrupt (shield 1) */
|
||||
MPS2_SPI3_IRQn = 52, /* SPI Interrupt (shield 0) */
|
||||
MPS2_SPI4_IRQn = 53, /* SPI Interrupt (shield 1) */
|
||||
PORT4_ALL_IRQn = 54, /* GPIO Port 4 combined Interrupt */
|
||||
PORT5_ALL_IRQn = 55, /* GPIO Port 5 combined Interrupt */
|
||||
UART4_IRQn = 56 /* UART 4 RX and TX Combined Interrupt */
|
||||
|
@ -635,104 +635,7 @@ typedef struct
|
|||
#define CMSDK_SYSCON_RSTINFO_LOCKUPRESET_Pos 2
|
||||
#define CMSDK_SYSCON_RSTINFO_LOCKUPRESET_Msk (0x00001ul << CMSDK_SYSCON_RSTINFO_LOCKUPRESET_Pos) /* CMSDK_SYSCON RSTINFO: LOCKUPRESET Mask */
|
||||
|
||||
|
||||
/*------------- PL230 uDMA (PL230) --------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
__I uint32_t DMA_STATUS; /* Offset: 0x000 (R/W) DMA status Register */
|
||||
__O uint32_t DMA_CFG; /* Offset: 0x004 ( /W) DMA configuration Register */
|
||||
__IO uint32_t CTRL_BASE_PTR; /* Offset: 0x008 (R/W) Channel Control Data Base Pointer Register */
|
||||
__I uint32_t ALT_CTRL_BASE_PTR; /* Offset: 0x00C (R/ ) Channel Alternate Control Data Base Pointer Register */
|
||||
__I uint32_t DMA_WAITONREQ_STATUS; /* Offset: 0x010 (R/ ) Channel Wait On Request Status Register */
|
||||
__O uint32_t CHNL_SW_REQUEST; /* Offset: 0x014 ( /W) Channel Software Request Register */
|
||||
__IO uint32_t CHNL_USEBURST_SET; /* Offset: 0x018 (R/W) Channel UseBurst Set Register */
|
||||
__O uint32_t CHNL_USEBURST_CLR; /* Offset: 0x01C ( /W) Channel UseBurst Clear Register */
|
||||
__IO uint32_t CHNL_REQ_MASK_SET; /* Offset: 0x020 (R/W) Channel Request Mask Set Register */
|
||||
__O uint32_t CHNL_REQ_MASK_CLR; /* Offset: 0x024 ( /W) Channel Request Mask Clear Register */
|
||||
__IO uint32_t CHNL_ENABLE_SET; /* Offset: 0x028 (R/W) Channel Enable Set Register */
|
||||
__O uint32_t CHNL_ENABLE_CLR; /* Offset: 0x02C ( /W) Channel Enable Clear Register */
|
||||
__IO uint32_t CHNL_PRI_ALT_SET; /* Offset: 0x030 (R/W) Channel Primary-Alterante Set Register */
|
||||
__O uint32_t CHNL_PRI_ALT_CLR; /* Offset: 0x034 ( /W) Channel Primary-Alterante Clear Register */
|
||||
__IO uint32_t CHNL_PRIORITY_SET; /* Offset: 0x038 (R/W) Channel Priority Set Register */
|
||||
__O uint32_t CHNL_PRIORITY_CLR; /* Offset: 0x03C ( /W) Channel Priority Clear Register */
|
||||
uint32_t RESERVED0[3];
|
||||
__IO uint32_t ERR_CLR; /* Offset: 0x04C Bus Error Clear Register (R/W) */
|
||||
|
||||
} CMSDK_PL230_TypeDef;
|
||||
|
||||
#define PL230_DMA_CHNL_BITS 0
|
||||
|
||||
#define CMSDK_PL230_DMA_STATUS_MSTREN_Pos 0 /* CMSDK_PL230 DMA STATUS: MSTREN Position */
|
||||
#define CMSDK_PL230_DMA_STATUS_MSTREN_Msk (0x00000001ul << CMSDK_PL230_DMA_STATUS_MSTREN_Pos) /* CMSDK_PL230 DMA STATUS: MSTREN Mask */
|
||||
|
||||
#define CMSDK_PL230_DMA_STATUS_STATE_Pos 0 /* CMSDK_PL230 DMA STATUS: STATE Position */
|
||||
#define CMSDK_PL230_DMA_STATUS_STATE_Msk (0x0000000Ful << CMSDK_PL230_DMA_STATUS_STATE_Pos) /* CMSDK_PL230 DMA STATUS: STATE Mask */
|
||||
|
||||
#define CMSDK_PL230_DMA_STATUS_CHNLS_MINUS1_Pos 0 /* CMSDK_PL230 DMA STATUS: CHNLS_MINUS1 Position */
|
||||
#define CMSDK_PL230_DMA_STATUS_CHNLS_MINUS1_Msk (0x0000001Ful << CMSDK_PL230_DMA_STATUS_CHNLS_MINUS1_Pos) /* CMSDK_PL230 DMA STATUS: CHNLS_MINUS1 Mask */
|
||||
|
||||
#define CMSDK_PL230_DMA_STATUS_TEST_STATUS_Pos 0 /* CMSDK_PL230 DMA STATUS: TEST_STATUS Position */
|
||||
#define CMSDK_PL230_DMA_STATUS_TEST_STATUS_Msk (0x00000001ul << CMSDK_PL230_DMA_STATUS_TEST_STATUS_Pos) /* CMSDK_PL230 DMA STATUS: TEST_STATUS Mask */
|
||||
|
||||
#define CMSDK_PL230_DMA_CFG_MSTREN_Pos 0 /* CMSDK_PL230 DMA CFG: MSTREN Position */
|
||||
#define CMSDK_PL230_DMA_CFG_MSTREN_Msk (0x00000001ul << CMSDK_PL230_DMA_CFG_MSTREN_Pos) /* CMSDK_PL230 DMA CFG: MSTREN Mask */
|
||||
|
||||
#define CMSDK_PL230_DMA_CFG_CPCCACHE_Pos 2 /* CMSDK_PL230 DMA CFG: CPCCACHE Position */
|
||||
#define CMSDK_PL230_DMA_CFG_CPCCACHE_Msk (0x00000001ul << CMSDK_PL230_DMA_CFG_CPCCACHE_Pos) /* CMSDK_PL230 DMA CFG: CPCCACHE Mask */
|
||||
|
||||
#define CMSDK_PL230_DMA_CFG_CPCBUF_Pos 1 /* CMSDK_PL230 DMA CFG: CPCBUF Position */
|
||||
#define CMSDK_PL230_DMA_CFG_CPCBUF_Msk (0x00000001ul << CMSDK_PL230_DMA_CFG_CPCBUF_Pos) /* CMSDK_PL230 DMA CFG: CPCBUF Mask */
|
||||
|
||||
#define CMSDK_PL230_DMA_CFG_CPCPRIV_Pos 0 /* CMSDK_PL230 DMA CFG: CPCPRIV Position */
|
||||
#define CMSDK_PL230_DMA_CFG_CPCPRIV_Msk (0x00000001ul << CMSDK_PL230_DMA_CFG_CPCPRIV_Pos) /* CMSDK_PL230 DMA CFG: CPCPRIV Mask */
|
||||
|
||||
#define CMSDK_PL230_CTRL_BASE_PTR_Pos PL230_DMA_CHNL_BITS + 5 /* CMSDK_PL230 STATUS: BASE_PTR Position */
|
||||
#define CMSDK_PL230_CTRL_BASE_PTR_Msk (0x0FFFFFFFul << CMSDK_PL230_CTRL_BASE_PTR_Pos) /* CMSDK_PL230 STATUS: BASE_PTR Mask */
|
||||
|
||||
#define CMSDK_PL230_ALT_CTRL_BASE_PTR_Pos 0 /* CMSDK_PL230 STATUS: MSTREN Position */
|
||||
#define CMSDK_PL230_ALT_CTRL_BASE_PTR_Msk (0xFFFFFFFFul << CMSDK_PL230_ALT_CTRL_BASE_PTR_Pos) /* CMSDK_PL230 STATUS: MSTREN Mask */
|
||||
|
||||
#define CMSDK_PL230_DMA_WAITONREQ_STATUS_Pos 0 /* CMSDK_PL230 DMA_WAITONREQ_STATUS: DMA_WAITONREQ_STATUS Position */
|
||||
#define CMSDK_PL230_DMA_WAITONREQ_STATUS_Msk (0xFFFFFFFFul << CMSDK_PL230_DMA_WAITONREQ_STATUS_Pos) /* CMSDK_PL230 DMA_WAITONREQ_STATUS: DMA_WAITONREQ_STATUS Mask */
|
||||
|
||||
#define CMSDK_PL230_CHNL_SW_REQUEST_Pos 0 /* CMSDK_PL230 CHNL_SW_REQUEST: CHNL_SW_REQUEST Position */
|
||||
#define CMSDK_PL230_CHNL_SW_REQUEST_Msk (0xFFFFFFFFul << CMSDK_PL230_CHNL_SW_REQUEST_Pos) /* CMSDK_PL230 CHNL_SW_REQUEST: CHNL_SW_REQUEST Mask */
|
||||
|
||||
#define CMSDK_PL230_CHNL_USEBURST_SET_Pos 0 /* CMSDK_PL230 CHNL_USEBURST: SET Position */
|
||||
#define CMSDK_PL230_CHNL_USEBURST_SET_Msk (0xFFFFFFFFul << CMSDK_PL230_CHNL_USEBURST_SET_Pos) /* CMSDK_PL230 CHNL_USEBURST: SET Mask */
|
||||
|
||||
#define CMSDK_PL230_CHNL_USEBURST_CLR_Pos 0 /* CMSDK_PL230 CHNL_USEBURST: CLR Position */
|
||||
#define CMSDK_PL230_CHNL_USEBURST_CLR_Msk (0xFFFFFFFFul << CMSDK_PL230_CHNL_USEBURST_CLR_Pos) /* CMSDK_PL230 CHNL_USEBURST: CLR Mask */
|
||||
|
||||
#define CMSDK_PL230_CHNL_REQ_MASK_SET_Pos 0 /* CMSDK_PL230 CHNL_REQ_MASK: SET Position */
|
||||
#define CMSDK_PL230_CHNL_REQ_MASK_SET_Msk (0xFFFFFFFFul << CMSDK_PL230_CHNL_REQ_MASK_SET_Pos) /* CMSDK_PL230 CHNL_REQ_MASK: SET Mask */
|
||||
|
||||
#define CMSDK_PL230_CHNL_REQ_MASK_CLR_Pos 0 /* CMSDK_PL230 CHNL_REQ_MASK: CLR Position */
|
||||
#define CMSDK_PL230_CHNL_REQ_MASK_CLR_Msk (0xFFFFFFFFul << CMSDK_PL230_CHNL_REQ_MASK_CLR_Pos) /* CMSDK_PL230 CHNL_REQ_MASK: CLR Mask */
|
||||
|
||||
#define CMSDK_PL230_CHNL_ENABLE_SET_Pos 0 /* CMSDK_PL230 CHNL_ENABLE: SET Position */
|
||||
#define CMSDK_PL230_CHNL_ENABLE_SET_Msk (0xFFFFFFFFul << CMSDK_PL230_CHNL_ENABLE_SET_Pos) /* CMSDK_PL230 CHNL_ENABLE: SET Mask */
|
||||
|
||||
#define CMSDK_PL230_CHNL_ENABLE_CLR_Pos 0 /* CMSDK_PL230 CHNL_ENABLE: CLR Position */
|
||||
#define CMSDK_PL230_CHNL_ENABLE_CLR_Msk (0xFFFFFFFFul << CMSDK_PL230_CHNL_ENABLE_CLR_Pos) /* CMSDK_PL230 CHNL_ENABLE: CLR Mask */
|
||||
|
||||
#define CMSDK_PL230_CHNL_PRI_ALT_SET_Pos 0 /* CMSDK_PL230 CHNL_PRI_ALT: SET Position */
|
||||
#define CMSDK_PL230_CHNL_PRI_ALT_SET_Msk (0xFFFFFFFFul << CMSDK_PL230_CHNL_PRI_ALT_SET_Pos) /* CMSDK_PL230 CHNL_PRI_ALT: SET Mask */
|
||||
|
||||
#define CMSDK_PL230_CHNL_PRI_ALT_CLR_Pos 0 /* CMSDK_PL230 CHNL_PRI_ALT: CLR Position */
|
||||
#define CMSDK_PL230_CHNL_PRI_ALT_CLR_Msk (0xFFFFFFFFul << CMSDK_PL230_CHNL_PRI_ALT_CLR_Pos) /* CMSDK_PL230 CHNL_PRI_ALT: CLR Mask */
|
||||
|
||||
#define CMSDK_PL230_CHNL_PRIORITY_SET_Pos 0 /* CMSDK_PL230 CHNL_PRIORITY: SET Position */
|
||||
#define CMSDK_PL230_CHNL_PRIORITY_SET_Msk (0xFFFFFFFFul << CMSDK_PL230_CHNL_PRIORITY_SET_Pos) /* CMSDK_PL230 CHNL_PRIORITY: SET Mask */
|
||||
|
||||
#define CMSDK_PL230_CHNL_PRIORITY_CLR_Pos 0 /* CMSDK_PL230 CHNL_PRIORITY: CLR Position */
|
||||
#define CMSDK_PL230_CHNL_PRIORITY_CLR_Msk (0xFFFFFFFFul << CMSDK_PL230_CHNL_PRIORITY_CLR_Pos) /* CMSDK_PL230 CHNL_PRIORITY: CLR Mask */
|
||||
|
||||
#define CMSDK_PL230_ERR_CLR_Pos 0 /* CMSDK_PL230 ERR: CLR Position */
|
||||
#define CMSDK_PL230_ERR_CLR_Msk (0x00000001ul << CMSDK_PL230_ERR_CLR_Pos) /* CMSDK_PL230 ERR: CLR Mask */
|
||||
|
||||
|
||||
/*------------------- Watchdog ----------------------------------------------*/
|
||||
/*------------------- WATCHDOG ----------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
|
||||
|
@ -749,35 +652,35 @@ typedef struct
|
|||
__O uint32_t ITOP; /* Offset: 0xF04 ( /W) Watchdog Integration Test Output Set Register */
|
||||
}CMSDK_WATCHDOG_TypeDef;
|
||||
|
||||
#define CMSDK_Watchdog_LOAD_Pos 0 /* CMSDK_Watchdog LOAD: LOAD Position */
|
||||
#define CMSDK_Watchdog_LOAD_Msk (0xFFFFFFFFul << CMSDK_Watchdog_LOAD_Pos) /* CMSDK_Watchdog LOAD: LOAD Mask */
|
||||
#define CMSDK_WATCHDOG_LOAD_Pos 0 /* CMSDK_WATCHDOG LOAD: LOAD Position */
|
||||
#define CMSDK_WATCHDOG_LOAD_Msk (0xFFFFFFFFul << CMSDK_WATCHDOG_LOAD_Pos) /* CMSDK_WATCHDOG LOAD: LOAD Mask */
|
||||
|
||||
#define CMSDK_Watchdog_VALUE_Pos 0 /* CMSDK_Watchdog VALUE: VALUE Position */
|
||||
#define CMSDK_Watchdog_VALUE_Msk (0xFFFFFFFFul << CMSDK_Watchdog_VALUE_Pos) /* CMSDK_Watchdog VALUE: VALUE Mask */
|
||||
#define CMSDK_WATCHDOG_VALUE_Pos 0 /* CMSDK_WATCHDOG VALUE: VALUE Position */
|
||||
#define CMSDK_WATCHDOG_VALUE_Msk (0xFFFFFFFFul << CMSDK_WATCHDOG_VALUE_Pos) /* CMSDK_WATCHDOG VALUE: VALUE Mask */
|
||||
|
||||
#define CMSDK_Watchdog_CTRL_RESEN_Pos 1 /* CMSDK_Watchdog CTRL_RESEN: Enable Reset Output Position */
|
||||
#define CMSDK_Watchdog_CTRL_RESEN_Msk (0x1ul << CMSDK_Watchdog_CTRL_RESEN_Pos) /* CMSDK_Watchdog CTRL_RESEN: Enable Reset Output Mask */
|
||||
#define CMSDK_WATCHDOG_CTRL_RESEN_Pos 1 /* CMSDK_WATCHDOG CTRL_RESEN: Enable Reset Output Position */
|
||||
#define CMSDK_WATCHDOG_CTRL_RESEN_Msk (0x1ul << CMSDK_WATCHDOG_CTRL_RESEN_Pos) /* CMSDK_WATCHDOG CTRL_RESEN: Enable Reset Output Mask */
|
||||
|
||||
#define CMSDK_Watchdog_CTRL_INTEN_Pos 0 /* CMSDK_Watchdog CTRL_INTEN: Int Enable Position */
|
||||
#define CMSDK_Watchdog_CTRL_INTEN_Msk (0x1ul << CMSDK_Watchdog_CTRL_INTEN_Pos) /* CMSDK_Watchdog CTRL_INTEN: Int Enable Mask */
|
||||
#define CMSDK_WATCHDOG_CTRL_INTEN_Pos 0 /* CMSDK_WATCHDOG CTRL_INTEN: Int Enable Position */
|
||||
#define CMSDK_WATCHDOG_CTRL_INTEN_Msk (0x1ul << CMSDK_WATCHDOG_CTRL_INTEN_Pos) /* CMSDK_WATCHDOG CTRL_INTEN: Int Enable Mask */
|
||||
|
||||
#define CMSDK_Watchdog_INTCLR_Pos 0 /* CMSDK_Watchdog INTCLR: Int Clear Position */
|
||||
#define CMSDK_Watchdog_INTCLR_Msk (0x1ul << CMSDK_Watchdog_INTCLR_Pos) /* CMSDK_Watchdog INTCLR: Int Clear Mask */
|
||||
#define CMSDK_WATCHDOG_INTCLR_Pos 0 /* CMSDK_WATCHDOG INTCLR: Int Clear Position */
|
||||
#define CMSDK_WATCHDOG_INTCLR_Msk (0x1ul << CMSDK_WATCHDOG_INTCLR_Pos) /* CMSDK_WATCHDOG INTCLR: Int Clear Mask */
|
||||
|
||||
#define CMSDK_Watchdog_RAWINTSTAT_Pos 0 /* CMSDK_Watchdog RAWINTSTAT: Raw Int Status Position */
|
||||
#define CMSDK_Watchdog_RAWINTSTAT_Msk (0x1ul << CMSDK_Watchdog_RAWINTSTAT_Pos) /* CMSDK_Watchdog RAWINTSTAT: Raw Int Status Mask */
|
||||
#define CMSDK_WATCHDOG_RAWINTSTAT_Pos 0 /* CMSDK_WATCHDOG RAWINTSTAT: Raw Int Status Position */
|
||||
#define CMSDK_WATCHDOG_RAWINTSTAT_Msk (0x1ul << CMSDK_WATCHDOG_RAWINTSTAT_Pos) /* CMSDK_WATCHDOG RAWINTSTAT: Raw Int Status Mask */
|
||||
|
||||
#define CMSDK_Watchdog_MASKINTSTAT_Pos 0 /* CMSDK_Watchdog MASKINTSTAT: Mask Int Status Position */
|
||||
#define CMSDK_Watchdog_MASKINTSTAT_Msk (0x1ul << CMSDK_Watchdog_MASKINTSTAT_Pos) /* CMSDK_Watchdog MASKINTSTAT: Mask Int Status Mask */
|
||||
#define CMSDK_WATCHDOG_MASKINTSTAT_Pos 0 /* CMSDK_WATCHDOG MASKINTSTAT: Mask Int Status Position */
|
||||
#define CMSDK_WATCHDOG_MASKINTSTAT_Msk (0x1ul << CMSDK_WATCHDOG_MASKINTSTAT_Pos) /* CMSDK_WATCHDOG MASKINTSTAT: Mask Int Status Mask */
|
||||
|
||||
#define CMSDK_Watchdog_LOCK_Pos 0 /* CMSDK_Watchdog LOCK: LOCK Position */
|
||||
#define CMSDK_Watchdog_LOCK_Msk (0x1ul << CMSDK_Watchdog_LOCK_Pos) /* CMSDK_Watchdog LOCK: LOCK Mask */
|
||||
#define CMSDK_WATCHDOG_LOCK_Pos 0 /* CMSDK_WATCHDOG LOCK: LOCK Position */
|
||||
#define CMSDK_WATCHDOG_LOCK_Msk (0x1ul << CMSDK_WATCHDOG_LOCK_Pos) /* CMSDK_WATCHDOG LOCK: LOCK Mask */
|
||||
|
||||
#define CMSDK_Watchdog_INTEGTESTEN_Pos 0 /* CMSDK_Watchdog INTEGTESTEN: Integration Test Enable Position */
|
||||
#define CMSDK_Watchdog_INTEGTESTEN_Msk (0x1ul << CMSDK_Watchdog_INTEGTESTEN_Pos) /* CMSDK_Watchdog INTEGTESTEN: Integration Test Enable Mask */
|
||||
#define CMSDK_WATCHDOG_INTEGTESTEN_Pos 0 /* CMSDK_WATCHDOG INTEGTESTEN: Integration Test Enable Position */
|
||||
#define CMSDK_WATCHDOG_INTEGTESTEN_Msk (0x1ul << CMSDK_WATCHDOG_INTEGTESTEN_Pos) /* CMSDK_WATCHDOG INTEGTESTEN: Integration Test Enable Mask */
|
||||
|
||||
#define CMSDK_Watchdog_INTEGTESTOUTSET_Pos 1 /* CMSDK_Watchdog INTEGTESTOUTSET: Integration Test Output Set Position */
|
||||
#define CMSDK_Watchdog_INTEGTESTOUTSET_Msk (0x1ul << CMSDK_Watchdog_INTEGTESTOUTSET_Pos) /* CMSDK_Watchdog INTEGTESTOUTSET: Integration Test Output Set Mask */
|
||||
#define CMSDK_WATCHDOG_INTEGTESTOUTSET_Pos 1 /* CMSDK_WATCHDOG INTEGTESTOUTSET: Integration Test Output Set Position */
|
||||
#define CMSDK_WATCHDOG_INTEGTESTOUTSET_Msk (0x1ul << CMSDK_WATCHDOG_INTEGTESTOUTSET_Pos) /* CMSDK_WATCHDOG INTEGTESTOUTSET: Integration Test Output Set Mask */
|
||||
|
||||
/*------------------------- Real Time Clock(RTC) ----------------------------------------------*/
|
||||
typedef struct
|
||||
|
@ -792,8 +695,8 @@ typedef struct
|
|||
__O uint32_t RTCICR; /* 0x1C WO RTC Interrupt Clear Register */
|
||||
} CMSDK_RTC_TypeDef;
|
||||
|
||||
#define CMSDK_RTC_Enable_Pos 0 /* CMSDK_RTC Enable: Real Time Clock Enable Position */
|
||||
#define CMSDK_RTC_Enable_Msk (0x1ul << CMSDK_RTC_Enable_Pos) /* CMSDK_RTC Enable: Real Time Clock Enable Mask */
|
||||
#define CMSDK_RTC_ENABLE_Pos 0 /* CMSDK_RTC Enable: Real Time Clock Enable Position */
|
||||
#define CMSDK_RTC_ENABLE_Msk (0x1ul << CMSDK_RTC_ENABLE_Pos) /* CMSDK_RTC Enable: Real Time Clock Enable Mask */
|
||||
|
||||
/* -------------------- End of section using anonymous unions ------------------- */
|
||||
#if defined ( __CC_ARM )
|
||||
|
@ -810,9 +713,6 @@ typedef struct
|
|||
#warning Not supported compiler type
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
/* ================================================================================ */
|
||||
/* ================ Peripheral memory map ================ */
|
||||
/* ================================================================================ */
|
||||
|
@ -855,21 +755,20 @@ typedef struct
|
|||
/* ================ Peripheral declaration ================ */
|
||||
/* ================================================================================ */
|
||||
|
||||
#define CMSDK_UART0 ((CMSDK_UART_TypeDef *) CMSDK_UART0_BASE )
|
||||
#define CMSDK_UART1 ((CMSDK_UART_TypeDef *) CMSDK_UART1_BASE )
|
||||
#define CMSDK_UART2 ((CMSDK_UART_TypeDef *) CMSDK_UART2_BASE )
|
||||
#define CMSDK_UART3 ((CMSDK_UART_TypeDef *) CMSDK_UART3_BASE )
|
||||
#define CMSDK_UART4 ((CMSDK_UART_TypeDef *) CMSDK_UART4_BASE )
|
||||
#define CMSDK_TIMER0 ((CMSDK_TIMER_TypeDef *) CMSDK_TIMER0_BASE )
|
||||
#define CMSDK_TIMER1 ((CMSDK_TIMER_TypeDef *) CMSDK_TIMER1_BASE )
|
||||
#define CMSDK_UART0 ((CMSDK_UART_TypeDef *) CMSDK_UART0_BASE )
|
||||
#define CMSDK_UART1 ((CMSDK_UART_TypeDef *) CMSDK_UART1_BASE )
|
||||
#define CMSDK_UART2 ((CMSDK_UART_TypeDef *) CMSDK_UART2_BASE )
|
||||
#define CMSDK_UART3 ((CMSDK_UART_TypeDef *) CMSDK_UART3_BASE )
|
||||
#define CMSDK_UART4 ((CMSDK_UART_TypeDef *) CMSDK_UART4_BASE )
|
||||
#define CMSDK_TIMER0 ((CMSDK_TIMER_TypeDef *) CMSDK_TIMER0_BASE )
|
||||
#define CMSDK_TIMER1 ((CMSDK_TIMER_TypeDef *) CMSDK_TIMER1_BASE )
|
||||
#define CMSDK_DUALTIMER ((CMSDK_DUALTIMER_BOTH_TypeDef *) CMSDK_DUALTIMER_BASE )
|
||||
#define CMSDK_DUALTIMER1 ((CMSDK_DUALTIMER_SINGLE_TypeDef *) CMSDK_DUALTIMER_1_BASE )
|
||||
#define CMSDK_DUALTIMER2 ((CMSDK_DUALTIMER_SINGLE_TypeDef *) CMSDK_DUALTIMER_2_BASE )
|
||||
#define CMSDK_RTC ((CMSDK_RTC_TypeDef *) CMSDK_RTC_BASE )
|
||||
#define CMSDK_WATCHDOG ((CMSDK_WATCHDOG_TypeDef *) CMSDK_WATCHDOG_BASE )
|
||||
#define CMSDK_DMA ((CMSDK_PL230_TypeDef *) CMSDK_PL230_BASE )
|
||||
#define CMSDK_GPIO0 ((CMSDK_GPIO_TypeDef *) CMSDK_GPIO0_BASE )
|
||||
#define CMSDK_GPIO1 ((CMSDK_GPIO_TypeDef *) CMSDK_GPIO1_BASE )
|
||||
#define CMSDK_WATCHDOG ((CMSDK_WATCHDOG_TypeDef *) CMSDK_WATCHDOG_BASE )
|
||||
#define CMSDK_GPIO0 ((CMSDK_GPIO_TypeDef *) CMSDK_GPIO0_BASE )
|
||||
#define CMSDK_GPIO1 ((CMSDK_GPIO_TypeDef *) CMSDK_GPIO1_BASE )
|
||||
#define CMSDK_GPIO2 ((CMSDK_GPIO_TypeDef *) CMSDK_GPIO2_BASE )
|
||||
#define CMSDK_GPIO3 ((CMSDK_GPIO_TypeDef *) CMSDK_GPIO3_BASE )
|
||||
#define CMSDK_GPIO4 ((CMSDK_GPIO_TypeDef *) CMSDK_GPIO4_BASE )
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue