mirror of https://github.com/ARMmbed/mbed-os.git
MBED_ASSERT - mbed assert implementation
parent
48cc27f405
commit
be43ebc182
|
|
@ -0,0 +1,35 @@
|
|||
#ifndef ASSERT_H
|
||||
#define ASSERT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** This function is active only if NDEBUG is not defined prior to including this
|
||||
* assert header file.
|
||||
* Internal mbed assert function which is invoked when MBED_ASSERT macro failes.
|
||||
* In case of MBED_ASSERT failing condition, the assertation message is printed
|
||||
* to stderr and mbed_die() is called.
|
||||
* @param expr Expresion to be checked.
|
||||
* @param file File where assertation failed.
|
||||
* @param line Failing assertation line number.
|
||||
*/
|
||||
void mbed_assert_internal(const char *expr, const char *file, int line);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define MBED_ASSERT(expr) ((void)0)
|
||||
|
||||
#else
|
||||
#define MBED_ASSERT(expr) \
|
||||
do { \
|
||||
if (!expr) { \
|
||||
mbed_assert_internal(#expr, __FILE__, __LINE__); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#include "assert.h"
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_STDIO_MESSAGES
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "mbed_interface.h"
|
||||
|
||||
void mbed_assert_internal(const char *expr, const char *file, int line)
|
||||
{
|
||||
#if DEVICE_STDIO_MESSAGES
|
||||
fprintf(stderr, "mbed assertation failed: %s, file: %s, line %d \n", expr, file, line);
|
||||
#endif
|
||||
mbed_die();
|
||||
}
|
||||
|
|
@ -396,15 +396,6 @@ extern "C" WEAK void __cxa_pure_virtual(void) {
|
|||
|
||||
#endif
|
||||
|
||||
#include "mbed_interface.h"
|
||||
// mbed abort invokes only mbed die. The abort function is called from failing assert for example.
|
||||
namespace std {
|
||||
extern "C" void abort(void) {
|
||||
mbed_die();
|
||||
while(1);
|
||||
}
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
// mbed_main is a function that is called before main()
|
||||
// mbed_sdk_init() is also a function that is called before main(), but unlike
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogin_api.h"
|
||||
|
||||
#include "cmsis.h"
|
||||
|
|
@ -38,7 +38,7 @@ static const PinMap PinMap_ADC[] = {
|
|||
|
||||
void analogin_init(analogin_t *obj, PinName pin) {
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
|
||||
assert(obj->adc != (ADCName)NC);
|
||||
MBED_ASSERT(obj->adc != (ADCName)NC);
|
||||
|
||||
SIM->SCGC6 |= SIM_SCGC6_ADC0_MASK;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "gpio_api.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
uint32_t gpio_set(PinName pin) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
pin_function(pin, 1);
|
||||
return 1 << ((pin & 0x7F) >> 2);
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) {
|
|||
}
|
||||
|
||||
void gpio_dir(gpio_t *obj, PinDirection direction) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
switch (direction) {
|
||||
case PIN_INPUT :
|
||||
*obj->reg_dir &= ~obj->mask;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef MBED_GPIO_OBJECT_H
|
||||
#define MBED_GPIO_OBJECT_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -33,7 +33,7 @@ typedef struct {
|
|||
} gpio_t;
|
||||
|
||||
static inline void gpio_write(gpio_t *obj, int value) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
if (value) {
|
||||
*obj->reg_set = obj->mask;
|
||||
} else {
|
||||
|
|
@ -42,7 +42,7 @@ static inline void gpio_write(gpio_t *obj, int value) {
|
|||
}
|
||||
|
||||
static inline int gpio_read(gpio_t *obj) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
return ((*obj->reg_in & obj->mask) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "i2c_api.h"
|
||||
|
||||
#include "cmsis.h"
|
||||
|
|
@ -54,7 +54,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
|
|||
I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA);
|
||||
I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL);
|
||||
obj->i2c = (I2C_Type*)pinmap_merge(i2c_sda, i2c_scl);
|
||||
assert((int)obj->i2c != NC);
|
||||
MBED_ASSERT((int)obj->i2c != NC);
|
||||
|
||||
SIM->SCGC4 |= SIM_SCGC4_I2C0_MASK;
|
||||
SIM->SCGC5 |= SIM_SCGC5_PORTB_MASK;
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
void pin_function(PinName pin, int function) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
|
||||
uint32_t port_n = (uint32_t)pin >> PORT_SHIFT;
|
||||
uint32_t pin_n = (uint32_t)(pin & 0x7C) >> 2;
|
||||
|
|
@ -30,7 +30,7 @@ void pin_function(PinName pin, int function) {
|
|||
}
|
||||
|
||||
void pin_mode(PinName pin, PinMode mode) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
__IO uint32_t* pin_pcr = (__IO uint32_t*)(PORTA_BASE + pin);
|
||||
|
||||
// pin pullup bits: [1:0] -> 11 = (0x3)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pwmout_api.h"
|
||||
|
||||
#include "cmsis.h"
|
||||
|
|
@ -53,7 +53,7 @@ static float pwm_clock = 0;
|
|||
void pwmout_init(pwmout_t* obj, PinName pin) {
|
||||
// determine the channel
|
||||
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
|
||||
assert(pwm != (PWMName)NC);
|
||||
MBED_ASSERT(pwm != (PWMName)NC);
|
||||
|
||||
uint32_t clkdiv = 0;
|
||||
float clkval = SystemCoreClock / 1000000.0f;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "serial_api.h"
|
||||
|
||||
// math.h required for floating point operations for baud rate calculation
|
||||
|
|
@ -47,7 +47,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
|
|||
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
|
||||
UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
|
||||
UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
|
||||
assert((int)uart != NC);
|
||||
MBED_ASSERT((int)uart != NC);
|
||||
|
||||
obj->uart = (UART_Type *)uart;
|
||||
// enable clk
|
||||
|
|
@ -116,9 +116,9 @@ void serial_baud(serial_t *obj, int baudrate) {
|
|||
}
|
||||
|
||||
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) {
|
||||
assert((stop_bits == 1) || (stop_bits == 2));
|
||||
assert((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven));
|
||||
assert((data_bits == 8) || (data_bits == 9));
|
||||
MBED_ASSERT((stop_bits == 1) || (stop_bits == 2));
|
||||
MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven));
|
||||
MBED_ASSERT((data_bits == 8) || (data_bits == 9));
|
||||
|
||||
// save C2 state
|
||||
uint32_t c2_state = (obj->uart->C2 & (UART_C2_RE_MASK | UART_C2_TE_MASK));
|
||||
|
|
@ -144,7 +144,7 @@ void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_b
|
|||
|
||||
// 9 data bits + parity - only uart0 support
|
||||
if (data_bits == 2) {
|
||||
assert(obj->index == 0);
|
||||
MBED_ASSERT(obj->index == 0);
|
||||
data_bits = 0;
|
||||
m10 = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "spi_api.h"
|
||||
|
||||
#include <math.h>
|
||||
|
|
@ -56,7 +56,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel);
|
||||
|
||||
obj->spi = (SPI_Type*)pinmap_merge(spi_data, spi_cntl);
|
||||
assert((int)obj->spi != NC);
|
||||
MBED_ASSERT((int)obj->spi != NC);
|
||||
|
||||
SIM->SCGC5 |= SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK;
|
||||
SIM->SCGC6 |= SIM_SCGC6_SPI0_MASK;
|
||||
|
|
@ -88,8 +88,8 @@ void spi_free(spi_t *obj) {
|
|||
// [TODO]
|
||||
}
|
||||
void spi_format(spi_t *obj, int bits, int mode, int slave) {
|
||||
assert((bits > 4) || (bits < 16));
|
||||
assert((mode >= 0) && (mode <= 3));
|
||||
MBED_ASSERT((bits > 4) || (bits < 16));
|
||||
MBED_ASSERT((mode >= 0) && (mode <= 3));
|
||||
|
||||
uint32_t polarity = (mode & 0x2) ? 1 : 0;
|
||||
uint32_t phase = (mode & 0x1) ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel);
|
||||
|
||||
obj->spi = (SPI_Type*)pinmap_merge(spi_data, spi_cntl);
|
||||
assert((int)obj->spi != NC);
|
||||
MBED_ASSERT((int)obj->spi != NC);
|
||||
|
||||
// enable power and clocking
|
||||
switch ((int)obj->spi) {
|
||||
|
|
@ -84,8 +84,8 @@ void spi_free(spi_t *obj) {
|
|||
// [TODO]
|
||||
}
|
||||
void spi_format(spi_t *obj, int bits, int mode, int slave) {
|
||||
assert(bits == 8);
|
||||
assert((mode >= 0) && (mode <= 3));
|
||||
MBED_ASSERT(bits == 8);
|
||||
MBED_ASSERT((mode >= 0) && (mode <= 3));
|
||||
|
||||
uint8_t polarity = (mode & 0x2) ? 1 : 0;
|
||||
uint8_t phase = (mode & 0x1) ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel);
|
||||
|
||||
obj->spi = (SPI_Type*)pinmap_merge(spi_data, spi_cntl);
|
||||
assert((int)obj->spi != NC);
|
||||
MBED_ASSERT((int)obj->spi != NC);
|
||||
|
||||
// enable power and clocking
|
||||
switch ((int)obj->spi) {
|
||||
|
|
@ -64,8 +64,8 @@ void spi_free(spi_t *obj) {
|
|||
// [TODO]
|
||||
}
|
||||
void spi_format(spi_t *obj, int bits, int mode, int slave) {
|
||||
assert(bits == 8);
|
||||
assert((mode >= 0) && (mode <= 3));
|
||||
MBED_ASSERT(bits == 8);
|
||||
MBED_ASSERT((mode >= 0) && (mode <= 3));
|
||||
|
||||
uint8_t polarity = (mode & 0x2) ? 1 : 0;
|
||||
uint8_t phase = (mode & 0x1) ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "spi_api.h"
|
||||
|
||||
#include <math.h>
|
||||
|
|
@ -90,7 +90,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel);
|
||||
|
||||
obj->spi = (SPI_Type*)pinmap_merge(spi_data, spi_cntl);
|
||||
assert((int)obj->spi != NC);
|
||||
MBED_ASSERT((int)obj->spi != NC);
|
||||
|
||||
// enable power and clocking
|
||||
switch ((int)obj->spi) {
|
||||
|
|
@ -123,8 +123,8 @@ void spi_free(spi_t *obj) {
|
|||
// [TODO]
|
||||
}
|
||||
void spi_format(spi_t *obj, int bits, int mode, int slave) {
|
||||
assert((bits == 8) || (bits == 16));
|
||||
assert((mode >= 0) && (mode <= 3));
|
||||
MBED_ASSERT((bits == 8) || (bits == 16));
|
||||
MBED_ASSERT((mode >= 0) && (mode <= 3));
|
||||
|
||||
uint8_t polarity = (mode & 0x2) ? 1 : 0;
|
||||
uint8_t phase = (mode & 0x1) ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogin_api.h"
|
||||
|
||||
#include "cmsis.h"
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
void analogin_init(analogin_t *obj, PinName pin) {
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
|
||||
assert(obj->adc != (ADCName)NC);
|
||||
MBED_ASSERT(obj->adc != (ADCName)NC);
|
||||
|
||||
SIM->SCGC6 |= SIM_SCGC6_ADC0_MASK;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogout_api.h"
|
||||
|
||||
#include "cmsis.h"
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
void analogout_init(dac_t *obj, PinName pin) {
|
||||
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
|
||||
assert(obj->dac != (DACName)NC);
|
||||
MBED_ASSERT(obj->dac != (DACName)NC);
|
||||
|
||||
SIM->SCGC6 |= SIM_SCGC6_DAC0_MASK;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "gpio_api.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
uint32_t gpio_set(PinName pin) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
pin_function(pin, 1);
|
||||
return 1 << ((pin & 0x7F) >> 2);
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) {
|
|||
}
|
||||
|
||||
void gpio_dir(gpio_t *obj, PinDirection direction) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
switch (direction) {
|
||||
case PIN_INPUT :
|
||||
*obj->reg_dir &= ~obj->mask;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef MBED_GPIO_OBJECT_H
|
||||
#define MBED_GPIO_OBJECT_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -33,7 +33,7 @@ typedef struct {
|
|||
} gpio_t;
|
||||
|
||||
static inline void gpio_write(gpio_t *obj, int value) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
if (value)
|
||||
*obj->reg_set = obj->mask;
|
||||
else
|
||||
|
|
@ -41,7 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) {
|
|||
}
|
||||
|
||||
static inline int gpio_read(gpio_t *obj) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
return ((*obj->reg_in & obj->mask) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "i2c_api.h"
|
||||
|
||||
#include "cmsis.h"
|
||||
|
|
@ -43,7 +43,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
|
|||
I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA);
|
||||
I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL);
|
||||
obj->i2c = (I2C_Type*)pinmap_merge(i2c_sda, i2c_scl);
|
||||
assert((int)obj->i2c != NC);
|
||||
MBED_ASSERT((int)obj->i2c != NC);
|
||||
|
||||
// enable power
|
||||
switch ((int)obj->i2c) {
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
void pin_function(PinName pin, int function) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
|
||||
uint32_t port_n = (uint32_t)pin >> PORT_SHIFT;
|
||||
uint32_t pin_n = (uint32_t)(pin & 0x7C) >> 2;
|
||||
|
|
@ -30,7 +30,7 @@ void pin_function(PinName pin, int function) {
|
|||
}
|
||||
|
||||
void pin_mode(PinName pin, PinMode mode) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
|
||||
__IO uint32_t* pin_pcr = (__IO uint32_t*)(PORTA_BASE + pin);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pwmout_api.h"
|
||||
|
||||
#include "cmsis.h"
|
||||
|
|
@ -26,7 +26,7 @@ static float pwm_clock;
|
|||
void pwmout_init(pwmout_t* obj, PinName pin) {
|
||||
// determine the channel
|
||||
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
|
||||
assert(pwm != (PWMName)NC);
|
||||
MBED_ASSERT(pwm != (PWMName)NC);
|
||||
|
||||
uint32_t clkdiv = 0;
|
||||
float clkval;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "serial_api.h"
|
||||
|
||||
// math.h required for floating point operations for baud rate calculation
|
||||
|
|
@ -61,7 +61,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
|
|||
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
|
||||
UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
|
||||
UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
|
||||
assert((int)uart != NC);
|
||||
MBED_ASSERT((int)uart != NC);
|
||||
|
||||
obj->uart = (UARTLP_Type *)uart;
|
||||
// enable clk
|
||||
|
|
@ -148,9 +148,9 @@ void serial_baud(serial_t *obj, int baudrate) {
|
|||
}
|
||||
|
||||
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) {
|
||||
assert((stop_bits == 1) || (stop_bits == 2));
|
||||
assert((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven));
|
||||
assert(data_bits == 8); // TODO: Support other number of data bits (also in the write method!)
|
||||
MBED_ASSERT((stop_bits == 1) || (stop_bits == 2));
|
||||
MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven));
|
||||
MBED_ASSERT(data_bits == 8); // TODO: Support other number of data bits (also in the write method!)
|
||||
|
||||
// save C2 state
|
||||
uint8_t c2_state = (obj->uart->C2 & (UARTLP_C2_RE_MASK | UARTLP_C2_TE_MASK));
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogin_api.h"
|
||||
|
||||
#include "cmsis.h"
|
||||
|
|
@ -49,7 +49,7 @@ static const PinMap PinMap_ADC[] = {
|
|||
|
||||
void analogin_init(analogin_t *obj, PinName pin) {
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
|
||||
assert(obj->adc != (ADCName)NC);
|
||||
MBED_ASSERT(obj->adc != (ADCName)NC);
|
||||
|
||||
uint32_t instance = obj->adc >> ADC_INSTANCE_SHIFT;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "gpio_api.h"
|
||||
#include "pinmap.h"
|
||||
#include "fsl_port_hal.h"
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
#include "fsl_sim_hal.h"
|
||||
|
||||
uint32_t gpio_set(PinName pin) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
uint32_t pin_num = pin & 0xFF;
|
||||
|
||||
pin_function(pin, (int)kPortMuxAsGpio);
|
||||
|
|
@ -44,7 +44,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) {
|
|||
}
|
||||
|
||||
void gpio_dir(gpio_t *obj, PinDirection direction) {
|
||||
assert(obj->pinName != (PinName)NC);
|
||||
MBED_ASSERT(obj->pinName != (PinName)NC);
|
||||
uint32_t port = obj->pinName >> GPIO_PORT_SHIFT;
|
||||
uint32_t pin_num = obj->pinName & 0xFF;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef MBED_GPIO_OBJECT_H
|
||||
#define MBED_GPIO_OBJECT_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "fsl_gpio_hal.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -28,7 +28,7 @@ typedef struct {
|
|||
} gpio_t;
|
||||
|
||||
static inline void gpio_write(gpio_t *obj, int value) {
|
||||
assert(obj->pinName != (PinName)NC);
|
||||
MBED_ASSERT(obj->pinName != (PinName)NC);
|
||||
uint32_t port = obj->pinName >> GPIO_PORT_SHIFT;
|
||||
uint32_t pin = obj->pinName & 0xFF;
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ static inline void gpio_write(gpio_t *obj, int value) {
|
|||
}
|
||||
|
||||
static inline int gpio_read(gpio_t *obj) {
|
||||
assert(obj->pinName != (PinName)NC);
|
||||
MBED_ASSERT(obj->pinName != (PinName)NC);
|
||||
uint32_t port = obj->pinName >> GPIO_PORT_SHIFT;
|
||||
uint32_t pin = obj->pinName & 0xFF;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "i2c_api.h"
|
||||
|
||||
#include "cmsis.h"
|
||||
|
|
@ -50,7 +50,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
|
|||
uint32_t i2c_sda = pinmap_peripheral(sda, PinMap_I2C_SDA);
|
||||
uint32_t i2c_scl = pinmap_peripheral(scl, PinMap_I2C_SCL);
|
||||
obj->instance = pinmap_merge(i2c_sda, i2c_scl);
|
||||
assert((int)obj->instance != NC);
|
||||
MBED_ASSERT((int)obj->instance != NC);
|
||||
|
||||
clock_manager_set_gate(kClockModuleI2C, obj->instance, true);
|
||||
clock_manager_set_gate(kClockModulePORT, sda >> GPIO_PORT_SHIFT, true);
|
||||
|
|
|
|||
|
|
@ -13,20 +13,20 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pinmap.h"
|
||||
#include "error.h"
|
||||
#include "fsl_clock_manager.h"
|
||||
#include "fsl_port_hal.h"
|
||||
|
||||
void pin_function(PinName pin, int function) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
clock_manager_set_gate(kClockModulePORT, pin >> GPIO_PORT_SHIFT, true);
|
||||
port_hal_mux_control(pin >> GPIO_PORT_SHIFT, pin & 0xFF, (port_mux_t)function);
|
||||
}
|
||||
|
||||
void pin_mode(PinName pin, PinMode mode) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
uint32_t instance = pin >> GPIO_PORT_SHIFT;
|
||||
uint32_t pinName = pin & 0xFF;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pwmout_api.h"
|
||||
|
||||
#include "cmsis.h"
|
||||
|
|
@ -73,7 +73,7 @@ static float pwm_clock_mhz;
|
|||
|
||||
void pwmout_init(pwmout_t* obj, PinName pin) {
|
||||
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
|
||||
assert(pwm != (PWMName)NC);
|
||||
MBED_ASSERT(pwm != (PWMName)NC);
|
||||
|
||||
obj->pwm_name = pwm;
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
// math.h required for floating point operations for baud rate calculation
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
|
|||
uint32_t uart_tx = pinmap_peripheral(tx, PinMap_UART_TX);
|
||||
uint32_t uart_rx = pinmap_peripheral(rx, PinMap_UART_RX);
|
||||
obj->index = (UARTName)pinmap_merge(uart_tx, uart_rx);
|
||||
assert((int)obj->index != NC);
|
||||
MBED_ASSERT((int)obj->index != NC);
|
||||
|
||||
uart_config_t uart_config;
|
||||
uart_config.baudRate = 9600;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
|
||||
#include "spi_api.h"
|
||||
#include "cmsis.h"
|
||||
|
|
@ -93,7 +93,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
uint32_t spi_cntl = pinmap_merge(spi_sclk, spi_ssel);
|
||||
|
||||
obj->instance = pinmap_merge(spi_data, spi_cntl);
|
||||
assert((int)obj->instance != NC);
|
||||
MBED_ASSERT((int)obj->instance != NC);
|
||||
|
||||
// enable power and clocking
|
||||
clock_manager_set_gate(kClockModuleSPI, obj->instance, true);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogin_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -37,7 +37,7 @@ void analogin_init(analogin_t *obj, PinName pin) {
|
|||
const PinMap *map = PinMap_ADC;
|
||||
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC); //(NRF_ADC_Type *)
|
||||
assert(obj->adc != (ADCName)NC);
|
||||
MBED_ASSERT(obj->adc != (ADCName)NC);
|
||||
|
||||
while (map->pin != NC) {
|
||||
if (map->pin == pin){
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "gpio_api.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) {
|
|||
}
|
||||
|
||||
void gpio_dir(gpio_t *obj, PinDirection direction) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
switch (direction) {
|
||||
case PIN_INPUT :
|
||||
NRF_GPIO->PIN_CNF[obj->pin] = (GPIO_PIN_CNF_SENSE_Disabled << GPIO_PIN_CNF_SENSE_Pos)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef MBED_GPIO_OBJECT_H
|
||||
#define MBED_GPIO_OBJECT_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -33,7 +33,7 @@ typedef struct {
|
|||
} gpio_t;
|
||||
|
||||
static inline void gpio_write(gpio_t *obj, int value) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
if (value)
|
||||
*obj->reg_set = obj->mask;
|
||||
else
|
||||
|
|
@ -41,7 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) {
|
|||
}
|
||||
|
||||
static inline int gpio_read(gpio_t *obj) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
return ((*obj->reg_in & obj->mask) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "i2c_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -62,7 +62,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
|
|||
I2CName i2c = (I2CName)pinmap_merge(i2c_sda,i2c_scl);
|
||||
obj->i2c = (NRF_TWI_Type *)i2c;
|
||||
|
||||
assert((int)obj->i2c != NC);
|
||||
MBED_ASSERT((int)obj->i2c != NC);
|
||||
|
||||
obj->scl=scl;
|
||||
obj->sda=sda;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pinmap.h"
|
||||
#include "error.h"
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ void pin_function(PinName pin, int function) {
|
|||
}
|
||||
|
||||
void pin_mode(PinName pin, PinMode mode) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
|
||||
uint32_t pin_number = (uint32_t)pin;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pwmout_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -215,7 +215,7 @@ void pwmout_init(pwmout_t* obj, PinName pin) {
|
|||
uint8_t pwmOutSuccess = 0;
|
||||
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
|
||||
|
||||
assert(pwm != (PWMName)NC);
|
||||
MBED_ASSERT(pwm != (PWMName)NC);
|
||||
|
||||
|
||||
if(PWM_taken[(uint8_t)pwm]){
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
// math.h required for floating point operations for baud rate calculation
|
||||
//#include <math.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
|
||||
#include "serial_api.h"
|
||||
#include "cmsis.h"
|
||||
|
|
@ -66,7 +66,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
|
|||
UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
|
||||
UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
|
||||
|
||||
assert((int)uart != NC);
|
||||
MBED_ASSERT((int)uart != NC);
|
||||
|
||||
obj->uart = (NRF_UART_Type *)uart;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
//#include <math.h>
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "spi_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -69,7 +69,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
obj->spi = (NRF_SPI_Type*)NC;
|
||||
obj->spis = (NRF_SPIS_Type*)spi;
|
||||
}
|
||||
assert((int)obj->spi != NC && (int)obj->spis != NC);
|
||||
MBED_ASSERT((int)obj->spi != NC && (int)obj->spis != NC);
|
||||
|
||||
// pin out the spi pins
|
||||
if (ssel != NC) {//slave
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogin_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -50,7 +50,7 @@ static const PinMap PinMap_ADC[] = {
|
|||
void analogin_init(analogin_t *obj, PinName pin) {
|
||||
volatile uint32_t tmp;
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
|
||||
assert(obj->adc != (ADCName)NC);
|
||||
MBED_ASSERT(obj->adc != (ADCName)NC);
|
||||
|
||||
pinmap_pinout(pin, PinMap_ADC);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "gpio_api.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ static void gpio_enable(void) {
|
|||
}
|
||||
|
||||
uint32_t gpio_set(PinName pin) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
if (!gpio_enabled)
|
||||
gpio_enable();
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) {
|
|||
}
|
||||
|
||||
void gpio_dir(gpio_t *obj, PinDirection direction) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
switch (direction) {
|
||||
case PIN_INPUT :
|
||||
*obj->reg_dir &= ~obj->mask;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef MBED_GPIO_OBJECT_H
|
||||
#define MBED_GPIO_OBJECT_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -33,7 +33,7 @@ typedef struct {
|
|||
} gpio_t;
|
||||
|
||||
static inline void gpio_write(gpio_t *obj, int value) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
if (value)
|
||||
*obj->reg_set = obj->mask;
|
||||
else
|
||||
|
|
@ -41,7 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) {
|
|||
}
|
||||
|
||||
static inline int gpio_read(gpio_t *obj) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
return ((*obj->reg_in & obj->mask) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "i2c_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -95,7 +95,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
|
|||
I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA);
|
||||
I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL);
|
||||
obj->i2c = (LPC_I2C0_Type *)pinmap_merge(i2c_sda, i2c_scl);
|
||||
assert((int)obj->i2c != NC);
|
||||
MBED_ASSERT((int)obj->i2c != NC);
|
||||
|
||||
// enable power
|
||||
i2c_power_enable(obj);
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pinmap.h"
|
||||
#include "error.h"
|
||||
|
||||
void pin_function(PinName pin, int function) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
__IO uint32_t *reg = (__IO uint32_t*)(LPC_IOCON_BASE + (pin & 0x1FF));
|
||||
|
||||
// pin function bits: [2:0] -> 111 = (0x7)
|
||||
|
|
@ -26,7 +26,7 @@ void pin_function(PinName pin, int function) {
|
|||
}
|
||||
|
||||
void pin_mode(PinName pin, PinMode mode) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
if ((pin == P0_4) || (pin == P0_5)) {
|
||||
// The true open-drain pins PIO0_4 and PIO0_5 can be configured for different I2C-bus speeds.
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
// math.h required for floating point operations for baud rate calculation
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -68,7 +68,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
|
|||
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
|
||||
UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
|
||||
UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
|
||||
assert((int)uart != NC);
|
||||
MBED_ASSERT((int)uart != NC);
|
||||
|
||||
obj->uart = (LPC_USART0_Type *)uart;
|
||||
LPC_SYSCON->SYSAHBCLKCTRL |= ((1<<12) | (1<<20) | (1<<21) | (1<<22));
|
||||
|
|
@ -203,9 +203,9 @@ void serial_baud(serial_t *obj, int baudrate) {
|
|||
}
|
||||
|
||||
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) {
|
||||
assert((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits
|
||||
assert((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits
|
||||
assert((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) ||
|
||||
MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits
|
||||
MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits
|
||||
MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) ||
|
||||
(parity == ParityForced1) || (parity == ParityForced0));
|
||||
|
||||
stop_bits -= 1;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include <math.h>
|
||||
|
||||
#include "spi_api.h"
|
||||
|
|
@ -69,7 +69,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel);
|
||||
|
||||
obj->spi = (LPC_SSP0_Type*)pinmap_merge(spi_data, spi_cntl);
|
||||
assert((int)obj->spi != NC);
|
||||
MBED_ASSERT((int)obj->spi != NC);
|
||||
|
||||
// enable power and clocking
|
||||
switch ((int)obj->spi) {
|
||||
|
|
@ -109,7 +109,7 @@ void spi_free(spi_t *obj) {}
|
|||
|
||||
void spi_format(spi_t *obj, int bits, int mode, int slave) {
|
||||
ssp_disable(obj);
|
||||
assert(((bits >= 4) && (bits <= 16)) || ((mode >= 0) && (mode <= 3)));
|
||||
MBED_ASSERT(((bits >= 4) && (bits <= 16)) || ((mode >= 0) && (mode <= 3)));
|
||||
|
||||
int polarity = (mode & 0x2) ? 1 : 0;
|
||||
int phase = (mode & 0x1) ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogin_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -47,7 +47,7 @@ static const PinMap PinMap_ADC[] = {
|
|||
|
||||
void analogin_init(analogin_t *obj, PinName pin) {
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
|
||||
assert(obj->adc != (ADCName)NC);
|
||||
MBED_ASSERT(obj->adc != (ADCName)NC);
|
||||
|
||||
// Power up ADC
|
||||
LPC_SYSCON->PDRUNCFG &= ~ (1 << 4);
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "gpio_api.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
uint32_t gpio_set(PinName pin) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
int f = ((pin == P0_0) ||
|
||||
(pin == P0_10) ||
|
||||
(pin == P0_11) ||
|
||||
|
|
@ -52,7 +52,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) {
|
|||
}
|
||||
|
||||
void gpio_dir(gpio_t *obj, PinDirection direction) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
switch (direction) {
|
||||
case PIN_INPUT :
|
||||
*obj->reg_dir &= ~obj->mask;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef MBED_GPIO_OBJECT_H
|
||||
#define MBED_GPIO_OBJECT_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -33,7 +33,7 @@ typedef struct {
|
|||
} gpio_t;
|
||||
|
||||
static inline void gpio_write(gpio_t *obj, int value) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
if (value)
|
||||
*obj->reg_set = obj->mask;
|
||||
else
|
||||
|
|
@ -41,7 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) {
|
|||
}
|
||||
|
||||
static inline int gpio_read(gpio_t *obj) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
return ((*obj->reg_in & obj->mask) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "i2c_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -87,7 +87,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
|
|||
I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA);
|
||||
I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL);
|
||||
obj->i2c = (LPC_I2C_Type *)pinmap_merge(i2c_sda, i2c_scl);
|
||||
assert((int)obj->i2c != NC);
|
||||
MBED_ASSERT((int)obj->i2c != NC);
|
||||
|
||||
// enable power
|
||||
i2c_power_enable(obj);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pinmap.h"
|
||||
#include "error.h"
|
||||
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
#define LPC_IOCON1_BASE (LPC_IOCON_BASE + 0x60)
|
||||
|
||||
void pin_function(PinName pin, int function) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
if (pin == (PinName)NC) return;
|
||||
|
||||
uint32_t pin_number = (uint32_t)pin;
|
||||
|
|
@ -35,7 +35,7 @@ void pin_function(PinName pin, int function) {
|
|||
}
|
||||
|
||||
void pin_mode(PinName pin, PinMode mode) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
uint32_t pin_number = (uint32_t)pin;
|
||||
uint32_t drain = ((uint32_t) mode & (uint32_t) OpenDrain) >> 2;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pwmout_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -69,7 +69,7 @@ static LPC_CTxxBx_Type *Timers[4] = {
|
|||
void pwmout_init(pwmout_t* obj, PinName pin) {
|
||||
// determine the channel
|
||||
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
|
||||
assert(pwm != (PWMName)NC);
|
||||
MBED_ASSERT(pwm != (PWMName)NC);
|
||||
|
||||
obj->pwm = pwm;
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
|
|||
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
|
||||
UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
|
||||
UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
|
||||
assert((int)uart != NC);
|
||||
MBED_ASSERT((int)uart != NC);
|
||||
|
||||
obj->uart = (LPC_USART_Type *)uart;
|
||||
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12);
|
||||
|
|
@ -185,9 +185,9 @@ void serial_baud(serial_t *obj, int baudrate) {
|
|||
}
|
||||
|
||||
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) {
|
||||
assert((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits
|
||||
assert((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits
|
||||
assert((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) ||
|
||||
MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits
|
||||
MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits
|
||||
MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) ||
|
||||
(parity == ParityForced1) || (parity == ParityForced0));
|
||||
|
||||
stop_bits -= 1;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include <math.h>
|
||||
#include "spi_api.h"
|
||||
#include "cmsis.h"
|
||||
|
|
@ -63,7 +63,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel);
|
||||
|
||||
obj->spi = (LPC_SSPx_Type*)pinmap_merge(spi_data, spi_cntl);
|
||||
assert((int)obj->spi != NC);
|
||||
MBED_ASSERT((int)obj->spi != NC);
|
||||
|
||||
// enable power and clocking
|
||||
switch ((int)obj->spi) {
|
||||
|
|
@ -102,7 +102,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
void spi_free(spi_t *obj) {}
|
||||
|
||||
void spi_format(spi_t *obj, int bits, int mode, int slave) {
|
||||
assert((bits >= 4 && bits <= 16) || (mode >= 0 && mode <= 3));
|
||||
MBED_ASSERT((bits >= 4 && bits <= 16) || (mode >= 0 && mode <= 3));
|
||||
|
||||
ssp_disable(obj);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogin_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -44,7 +44,7 @@ static inline int div_round_up(int x, int y) {
|
|||
|
||||
void analogin_init(analogin_t *obj, PinName pin) {
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
|
||||
assert(obj->adc != (uint32_t)NC);
|
||||
MBED_ASSERT(obj->adc != (uint32_t)NC);
|
||||
|
||||
// Power up ADC
|
||||
LPC_SYSCON->PDRUNCFG &= ~ (1 << 4);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "gpio_api.h"
|
||||
#include "pinmap.h"
|
||||
#include "reserved_pins.h"
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
static const PinName reserved_pins[] = TARGET_RESERVED_PINS;
|
||||
|
||||
uint32_t gpio_set(PinName pin) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
// PIO default value of following ports are not same as others
|
||||
unsigned i;
|
||||
int f = 0;
|
||||
|
|
@ -53,7 +53,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) {
|
|||
}
|
||||
|
||||
void gpio_dir(gpio_t *obj, PinDirection direction) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
int pin_number = ((obj->pin & 0x0F00) >> 8);
|
||||
switch (direction) {
|
||||
case PIN_INPUT :
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef MBED_GPIO_OBJECT_H
|
||||
#define MBED_GPIO_OBJECT_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -30,7 +30,7 @@ typedef struct {
|
|||
} gpio_t;
|
||||
|
||||
static inline void gpio_write(gpio_t *obj, int value) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
uint32_t pin_number = ((obj->pin & 0x0F00) >> 8);
|
||||
if (value)
|
||||
*obj->reg_write |= (1 << pin_number);
|
||||
|
|
@ -39,7 +39,7 @@ static inline void gpio_write(gpio_t *obj, int value) {
|
|||
}
|
||||
|
||||
static inline int gpio_read(gpio_t *obj) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
return ((*obj->reg_mask_read) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "i2c_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -88,7 +88,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
|
|||
I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA);
|
||||
I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL);
|
||||
obj->i2c = (LPC_I2C_TypeDef *)pinmap_merge(i2c_sda, i2c_scl);
|
||||
assert((int)obj->i2c != NC);
|
||||
MBED_ASSERT((int)obj->i2c != NC);
|
||||
|
||||
// enable power
|
||||
i2c_power_enable(obj);
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pinmap.h"
|
||||
#include "error.h"
|
||||
|
||||
void pin_function(PinName pin, int function) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
uint32_t offset = (uint32_t)pin & 0xff;
|
||||
__IO uint32_t *reg = (__IO uint32_t*)(LPC_IOCON_BASE + offset);
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ void pin_function(PinName pin, int function) {
|
|||
}
|
||||
|
||||
void pin_mode(PinName pin, PinMode mode) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
uint32_t offset = (uint32_t)pin & 0xff;
|
||||
uint32_t drain = ((uint32_t)mode & (uint32_t)OpenDrain) >> 2;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pwmout_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -64,7 +64,7 @@ static LPC_TMR_TypeDef *Timers[3] = {
|
|||
void pwmout_init(pwmout_t* obj, PinName pin) {
|
||||
// determine the channel
|
||||
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
|
||||
assert(pwm != (uint32_t)NC);
|
||||
MBED_ASSERT(pwm != (uint32_t)NC);
|
||||
|
||||
obj->pwm = pwm;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
// math.h required for floating point operations for baud rate calculation
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -57,7 +57,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
|
|||
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
|
||||
UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
|
||||
UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
|
||||
assert((int)uart != NC);
|
||||
MBED_ASSERT((int)uart != NC);
|
||||
|
||||
obj->uart = (LPC_UART_TypeDef *)uart;
|
||||
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12);
|
||||
|
|
@ -181,9 +181,9 @@ void serial_baud(serial_t *obj, int baudrate) {
|
|||
}
|
||||
|
||||
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) {
|
||||
assert((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits
|
||||
assert((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits
|
||||
assert((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) ||
|
||||
MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits
|
||||
MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits
|
||||
MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) ||
|
||||
(parity == ParityForced1) || (parity == ParityForced0));
|
||||
|
||||
stop_bits -= 1;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include <math.h>
|
||||
#include "spi_api.h"
|
||||
#include "cmsis.h"
|
||||
|
|
@ -59,7 +59,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel);
|
||||
|
||||
obj->spi = (LPC_SSP_TypeDef*)pinmap_merge(spi_data, spi_cntl);
|
||||
assert((int)obj->spi != NC);
|
||||
MBED_ASSERT((int)obj->spi != NC);
|
||||
|
||||
// enable power and clocking
|
||||
switch ((int)obj->spi) {
|
||||
|
|
@ -98,7 +98,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
void spi_free(spi_t *obj) {}
|
||||
|
||||
void spi_format(spi_t *obj, int bits, int mode, int slave) {
|
||||
assert((bits >= 4 && bits <= 16) || (mode >= 0 && mode <= 3));
|
||||
MBED_ASSERT((bits >= 4 && bits <= 16) || (mode >= 0 && mode <= 3));
|
||||
ssp_disable(obj);
|
||||
|
||||
int polarity = (mode & 0x2) ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogin_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -47,7 +47,7 @@ static const PinMap PinMap_ADC[] = {
|
|||
|
||||
void analogin_init(analogin_t *obj, PinName pin) {
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
|
||||
assert(obj->adc != (ADCName)NC);
|
||||
MBED_ASSERT(obj->adc != (ADCName)NC);
|
||||
|
||||
// Power up ADC
|
||||
LPC_SYSCON->PDRUNCFG &= ~ (1 << 4);
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "gpio_api.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
uint32_t gpio_set(PinName pin) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
int f = ((pin == P0_11) || (pin == P0_12) ||
|
||||
(pin == P0_13) || (pin == P0_14)) ? (1) : (0);
|
||||
pin_function(pin, f);
|
||||
|
|
@ -46,7 +46,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) {
|
|||
}
|
||||
|
||||
void gpio_dir(gpio_t *obj, PinDirection direction) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
switch (direction) {
|
||||
case PIN_INPUT :
|
||||
*obj->reg_dir &= ~obj->mask;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef MBED_GPIO_OBJECT_H
|
||||
#define MBED_GPIO_OBJECT_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -33,7 +33,7 @@ typedef struct {
|
|||
} gpio_t;
|
||||
|
||||
static inline void gpio_write(gpio_t *obj, int value) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
if (value)
|
||||
*obj->reg_set = obj->mask;
|
||||
else
|
||||
|
|
@ -41,7 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) {
|
|||
}
|
||||
|
||||
static inline int gpio_read(gpio_t *obj) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
return ((*obj->reg_in & obj->mask) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "i2c_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -88,7 +88,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
|
|||
I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA);
|
||||
I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL);
|
||||
obj->i2c = (LPC_I2C_Type *)pinmap_merge(i2c_sda, i2c_scl);
|
||||
assert((int)obj->i2c != NC);
|
||||
MBED_ASSERT((int)obj->i2c != NC);
|
||||
|
||||
// enable power
|
||||
i2c_power_enable(obj);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pinmap.h"
|
||||
#include "error.h"
|
||||
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
#define LPC_IOCON1_BASE (LPC_IOCON_BASE + 0x60)
|
||||
|
||||
void pin_function(PinName pin, int function) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
|
||||
uint32_t pin_number = (uint32_t)pin;
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ void pin_function(PinName pin, int function) {
|
|||
}
|
||||
|
||||
void pin_mode(PinName pin, PinMode mode) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
|
||||
uint32_t pin_number = (uint32_t)pin;
|
||||
uint32_t drain = ((uint32_t) mode & (uint32_t) OpenDrain) >> 2;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pwmout_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -71,7 +71,7 @@ static unsigned int pwm_clock_mhz;
|
|||
void pwmout_init(pwmout_t* obj, PinName pin) {
|
||||
// determine the channel
|
||||
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
|
||||
assert(pwm != (uint32_t)NC);
|
||||
MBED_ASSERT(pwm != (uint32_t)NC);
|
||||
|
||||
obj->pwm = pwm;
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
// math.h required for floating point operations for baud rate calculation
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -55,7 +55,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
|
|||
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
|
||||
UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
|
||||
UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
|
||||
assert((int)uart != NC);
|
||||
MBED_ASSERT((int)uart != NC);
|
||||
|
||||
obj->uart = (LPC_USART_Type *)uart;
|
||||
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<12);
|
||||
|
|
@ -184,9 +184,9 @@ void serial_baud(serial_t *obj, int baudrate) {
|
|||
}
|
||||
|
||||
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) {
|
||||
assert((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits
|
||||
assert((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits
|
||||
assert((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) ||
|
||||
MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits
|
||||
MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits
|
||||
MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) ||
|
||||
(parity == ParityForced1) || (parity == ParityForced0));
|
||||
|
||||
stop_bits -= 1;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include <math.h>
|
||||
#include "spi_api.h"
|
||||
#include "cmsis.h"
|
||||
|
|
@ -63,7 +63,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel);
|
||||
|
||||
obj->spi = (LPC_SSPx_Type*)pinmap_merge(spi_data, spi_cntl);
|
||||
assert((int)obj->spi != NC);
|
||||
MBED_ASSERT((int)obj->spi != NC);
|
||||
|
||||
// enable power and clocking
|
||||
switch ((int)obj->spi) {
|
||||
|
|
@ -103,7 +103,7 @@ void spi_free(spi_t *obj) {}
|
|||
|
||||
void spi_format(spi_t *obj, int bits, int mode, int slave) {
|
||||
ssp_disable(obj);
|
||||
assert((bits >= 4 && bits <= 16) || (mode >= 0 && mode <= 3));
|
||||
MBED_ASSERT((bits >= 4 && bits <= 16) || (mode >= 0 && mode <= 3));
|
||||
|
||||
int polarity = (mode & 0x2) ? 1 : 0;
|
||||
int phase = (mode & 0x1) ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogin_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -54,7 +54,7 @@ static const PinMap PinMap_ADC[] = {
|
|||
|
||||
void analogin_init(analogin_t *obj, PinName pin) {
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
|
||||
assert(obj->adc != (ADCName)NC);
|
||||
MBED_ASSERT(obj->adc != (ADCName)NC);
|
||||
|
||||
uint32_t port = (pin >> 5);
|
||||
// enable clock for GPIOx
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogout_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
void analogout_init(dac_t *obj, PinName pin) {
|
||||
assert(pin == P0_12);
|
||||
MBED_ASSERT(pin == P0_12);
|
||||
|
||||
LPC_SYSCON->SYSAHBCLKCTRL0 |= (1 << 29);
|
||||
LPC_SYSCON->PDRUNCFG &= ~(1 << 12);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "gpio_api.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ static void gpio_enable(void) {
|
|||
}
|
||||
|
||||
uint32_t gpio_set(PinName pin) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
if (!gpio_enabled)
|
||||
gpio_enable();
|
||||
|
||||
|
|
@ -54,7 +54,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) {
|
|||
}
|
||||
|
||||
void gpio_dir(gpio_t *obj, PinDirection direction) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
switch (direction) {
|
||||
case PIN_INPUT :
|
||||
*obj->reg_dir &= ~obj->mask;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef MBED_GPIO_OBJECT_H
|
||||
#define MBED_GPIO_OBJECT_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -33,7 +33,7 @@ typedef struct {
|
|||
} gpio_t;
|
||||
|
||||
static inline void gpio_write(gpio_t *obj, int value) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
|
||||
if (value)
|
||||
*obj->reg_set = obj->mask;
|
||||
|
|
@ -42,7 +42,7 @@ static inline void gpio_write(gpio_t *obj, int value) {
|
|||
}
|
||||
|
||||
static inline int gpio_read(gpio_t *obj) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
return ((*obj->reg_in & obj->mask) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "i2c_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -41,7 +41,7 @@ static inline void i2c_interface_enable(i2c_t *obj) {
|
|||
}
|
||||
|
||||
void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
|
||||
assert((sda == P0_23) || (scl == P0_22));
|
||||
MBED_ASSERT((sda == P0_23) || (scl == P0_22));
|
||||
|
||||
// Enables clock for I2C0
|
||||
LPC_SYSCON->SYSAHBCLKCTRL1 |= (1 << 13);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pinmap.h"
|
||||
#include "error.h"
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ void pin_function(PinName pin, int function) {
|
|||
}
|
||||
|
||||
void pin_mode(PinName pin, PinMode mode) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
|
||||
if ((pin == P0_22) || (pin == P0_23)) {
|
||||
// The true open-drain pins PIO0_22 and PIO0_23 can be configured for different I2C-bus speeds.
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pwmout_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -38,7 +38,7 @@ static int get_available_sct(void) {
|
|||
}
|
||||
|
||||
void pwmout_init(pwmout_t* obj, PinName pin) {
|
||||
assert(pin != (uint32_t)NC);
|
||||
MBED_ASSERT(pin != (uint32_t)NC);
|
||||
|
||||
int sct_n = get_available_sct();
|
||||
if (sct_n == -1) {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
// math.h required for floating point operations for baud rate calculation
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
@ -196,9 +196,9 @@ void serial_baud(serial_t *obj, int baudrate) {
|
|||
}
|
||||
|
||||
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) {
|
||||
assert((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits
|
||||
assert((data_bits > 6) && (data_bits < 10)); // 0: 7 data bits ... 2: 9 data bits
|
||||
assert((parity == ParityNone) || (parity == ParityEven) || (parity == ParityOdd));
|
||||
MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits
|
||||
MBED_ASSERT((data_bits > 6) && (data_bits < 10)); // 0: 7 data bits ... 2: 9 data bits
|
||||
MBED_ASSERT((parity == ParityNone) || (parity == ParityEven) || (parity == ParityOdd));
|
||||
|
||||
stop_bits -= 1;
|
||||
data_bits -= 7;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include <math.h>
|
||||
|
||||
#include "spi_api.h"
|
||||
|
|
@ -127,7 +127,7 @@ void spi_free(spi_t *obj) {}
|
|||
|
||||
void spi_format(spi_t *obj, int bits, int mode, int slave) {
|
||||
spi_disable(obj);
|
||||
assert((bits >= 1 && bits <= 16) && (mode >= 0 && mode <= 3));
|
||||
MBED_ASSERT((bits >= 1 && bits <= 16) && (mode >= 0 && mode <= 3));
|
||||
|
||||
int polarity = (mode & 0x2) ? 1 : 0;
|
||||
int phase = (mode & 0x1) ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogin_api.h"
|
||||
|
||||
#include "cmsis.h"
|
||||
|
|
@ -44,7 +44,7 @@ static const PinMap PinMap_ADC[] = {
|
|||
|
||||
void analogin_init(analogin_t *obj, PinName pin) {
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
|
||||
assert(obj->adc != (ADCName)NC);
|
||||
MBED_ASSERT(obj->adc != (ADCName)NC);
|
||||
|
||||
// ensure power is turned on
|
||||
LPC_SC->PCONP |= (1 << 12);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogout_api.h"
|
||||
|
||||
#include "cmsis.h"
|
||||
|
|
@ -26,7 +26,7 @@ static const PinMap PinMap_DAC[] = {
|
|||
|
||||
void analogout_init(dac_t *obj, PinName pin) {
|
||||
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
|
||||
assert(obj->dac != (DACName)NC);
|
||||
MBED_ASSERT(obj->dac != (DACName)NC);
|
||||
|
||||
// power is on by default, set DAC clk divider is /4
|
||||
LPC_SC->PCLKSEL0 &= ~(0x3 << 22);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "can_api.h"
|
||||
|
||||
#include "cmsis.h"
|
||||
|
|
@ -258,7 +258,7 @@ void can_init(can_t *obj, PinName rd, PinName td) {
|
|||
CANName can_rd = (CANName)pinmap_peripheral(rd, PinMap_CAN_RD);
|
||||
CANName can_td = (CANName)pinmap_peripheral(td, PinMap_CAN_TD);
|
||||
obj->dev = (LPC_CAN_TypeDef *)pinmap_merge(can_rd, can_td);
|
||||
assert((int)obj->dev != NC);
|
||||
MBED_ASSERT((int)obj->dev != NC);
|
||||
|
||||
switch ((int)obj->dev) {
|
||||
case CAN_1: LPC_SC->PCONP |= 1 << 13; break;
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "gpio_api.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
uint32_t gpio_set(PinName pin) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
pin_function(pin, 0);
|
||||
return (1 << ((int)pin & 0x1F));
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ void gpio_mode(gpio_t *obj, PinMode mode) {
|
|||
}
|
||||
|
||||
void gpio_dir(gpio_t *obj, PinDirection direction) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
switch (direction) {
|
||||
case PIN_INPUT :
|
||||
*obj->reg_dir &= ~obj->mask;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef MBED_GPIO_OBJECT_H
|
||||
#define MBED_GPIO_OBJECT_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -33,7 +33,7 @@ typedef struct {
|
|||
} gpio_t;
|
||||
|
||||
static inline void gpio_write(gpio_t *obj, int value) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
if (value)
|
||||
*obj->reg_set = obj->mask;
|
||||
else
|
||||
|
|
@ -41,7 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) {
|
|||
}
|
||||
|
||||
static inline int gpio_read(gpio_t *obj) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
return ((*obj->reg_in & obj->mask) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "i2c_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -96,7 +96,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
|
|||
I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA);
|
||||
I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL);
|
||||
obj->i2c = (LPC_I2C_TypeDef *)pinmap_merge(i2c_sda, i2c_scl);
|
||||
assert((int)obj->i2c != NC);
|
||||
MBED_ASSERT((int)obj->i2c != NC);
|
||||
|
||||
// enable power
|
||||
i2c_power_enable(obj);
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pinmap.h"
|
||||
#include "error.h"
|
||||
|
||||
void pin_function(PinName pin, int function) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
|
||||
uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0;
|
||||
int index = pin_number >> 4;
|
||||
|
|
@ -29,7 +29,7 @@ void pin_function(PinName pin, int function) {
|
|||
}
|
||||
|
||||
void pin_mode(PinName pin, PinMode mode) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
|
||||
uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0;
|
||||
int index = pin_number >> 5;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pwmout_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -57,7 +57,7 @@ static unsigned int pwm_clock_mhz;
|
|||
void pwmout_init(pwmout_t* obj, PinName pin) {
|
||||
// determine the channel
|
||||
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
|
||||
assert(pwm != (PWMName)NC);
|
||||
MBED_ASSERT(pwm != (PWMName)NC);
|
||||
|
||||
obj->pwm = pwm;
|
||||
obj->MR = PWM_MATCH[pwm];
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
// math.h required for floating point operations for baud rate calculation
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -89,7 +89,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
|
|||
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
|
||||
UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
|
||||
UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
|
||||
assert((int)uart != NC);
|
||||
MBED_ASSERT((int)uart != NC);
|
||||
|
||||
obj->uart = (LPC_UART_TypeDef *)uart;
|
||||
// enable power
|
||||
|
|
@ -148,7 +148,7 @@ void serial_free(serial_t *obj) {
|
|||
// serial_baud
|
||||
// set the baud rate, taking in to account the current SystemFrequency
|
||||
void serial_baud(serial_t *obj, int baudrate) {
|
||||
assert((int)obj->uart <= UART_3);
|
||||
MBED_ASSERT((int)obj->uart <= UART_3);
|
||||
// The LPC2300 and LPC1700 have a divider and a fractional divider to control the
|
||||
// baud rate. The formula is:
|
||||
//
|
||||
|
|
@ -244,9 +244,9 @@ void serial_baud(serial_t *obj, int baudrate) {
|
|||
}
|
||||
|
||||
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) {
|
||||
assert((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits
|
||||
assert((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits
|
||||
assert((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) ||
|
||||
MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits
|
||||
MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits
|
||||
MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) ||
|
||||
(parity == ParityForced1) || (parity == ParityForced0));
|
||||
|
||||
stop_bits -= 1;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include <math.h>
|
||||
|
||||
#include "spi_api.h"
|
||||
|
|
@ -65,7 +65,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
SPIName spi_data = (SPIName)pinmap_merge(spi_mosi, spi_miso);
|
||||
SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel);
|
||||
obj->spi = (LPC_SSP_TypeDef*)pinmap_merge(spi_data, spi_cntl);
|
||||
assert((int)obj->spi != NC);
|
||||
MBED_ASSERT((int)obj->spi != NC);
|
||||
|
||||
// enable power and clocking
|
||||
switch ((int)obj->spi) {
|
||||
|
|
@ -97,7 +97,7 @@ void spi_free(spi_t *obj) {}
|
|||
|
||||
void spi_format(spi_t *obj, int bits, int mode, int slave) {
|
||||
ssp_disable(obj);
|
||||
assert(((bits >= 4) && (bits <= 16)) && (mode >= 0 && mode <= 3));
|
||||
MBED_ASSERT(((bits >= 4) && (bits <= 16)) && (mode >= 0 && mode <= 3));
|
||||
|
||||
int polarity = (mode & 0x2) ? 1 : 0;
|
||||
int phase = (mode & 0x1) ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogin_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -42,7 +42,7 @@ static const PinMap PinMap_ADC[] = {
|
|||
|
||||
void analogin_init(analogin_t *obj, PinName pin) {
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
|
||||
assert(obj->adc != (ADCName)NC);
|
||||
MBED_ASSERT(obj->adc != (ADCName)NC);
|
||||
|
||||
// ensure power is turned on
|
||||
LPC_SC->PCONP |= (1 << 12);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogout_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -25,7 +25,7 @@ static const PinMap PinMap_DAC[] = {
|
|||
|
||||
void analogout_init(dac_t *obj, PinName pin) {
|
||||
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
|
||||
assert(obj->dac != (DACName)NC);
|
||||
MBED_ASSERT(obj->dac != (DACName)NC);
|
||||
|
||||
// power is on by default, set DAC clk divider is /4
|
||||
LPC_SC->PCLKSEL0 &= ~(0x3 << 22);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "can_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -161,7 +161,7 @@ void can_init(can_t *obj, PinName rd, PinName td) {
|
|||
CANName can_rd = (CANName)pinmap_peripheral(rd, PinMap_CAN_RD);
|
||||
CANName can_td = (CANName)pinmap_peripheral(td, PinMap_CAN_TD);
|
||||
obj->dev = (LPC_CAN_TypeDef *)pinmap_merge(can_rd, can_td);
|
||||
assert((int)obj->dev != NC);
|
||||
MBED_ASSERT((int)obj->dev != NC);
|
||||
|
||||
switch ((int)obj->dev) {
|
||||
case CAN_1: LPC_SC->PCONP |= 1 << 13; break;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "gpio_api.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#ifndef MBED_GPIO_OBJECT_H
|
||||
#define MBED_GPIO_OBJECT_H
|
||||
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -33,7 +33,7 @@ typedef struct {
|
|||
} gpio_t;
|
||||
|
||||
static inline void gpio_write(gpio_t *obj, int value) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
if (value)
|
||||
*obj->reg_set = obj->mask;
|
||||
else
|
||||
|
|
@ -41,7 +41,7 @@ static inline void gpio_write(gpio_t *obj, int value) {
|
|||
}
|
||||
|
||||
static inline int gpio_read(gpio_t *obj) {
|
||||
assert(obj->pin != (PinName)NC);
|
||||
MBED_ASSERT(obj->pin != (PinName)NC);
|
||||
return ((*obj->reg_in & obj->mask) ? 1 : 0);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ void i2c_init(i2c_t *obj, PinName sda, PinName scl) {
|
|||
I2CName i2c_sda = (I2CName)pinmap_peripheral(sda, PinMap_I2C_SDA);
|
||||
I2CName i2c_scl = (I2CName)pinmap_peripheral(scl, PinMap_I2C_SCL);
|
||||
obj->i2c = (LPC_I2C_TypeDef *)pinmap_merge(i2c_sda, i2c_scl);
|
||||
assert((int)obj->i2c != NC);
|
||||
MBED_ASSERT((int)obj->i2c != NC);
|
||||
|
||||
// enable power
|
||||
i2c_power_enable(obj);
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pinmap.h"
|
||||
#include "error.h"
|
||||
|
||||
void pin_function(PinName pin, int function) {
|
||||
assert(pin != (PinName)NC);
|
||||
MBED_ASSERT(pin != (PinName)NC);
|
||||
|
||||
uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0;
|
||||
int index = pin_number >> 4;
|
||||
|
|
@ -29,7 +29,7 @@ void pin_function(PinName pin, int function) {
|
|||
}
|
||||
|
||||
void pin_mode(PinName pin, PinMode mode) {
|
||||
assert((pin != (PinName)NC) && (mode != OpenDrain));
|
||||
MBED_ASSERT((pin != (PinName)NC) && (mode != OpenDrain));
|
||||
|
||||
uint32_t pin_number = (uint32_t)pin - (uint32_t)P0_0;
|
||||
int index = pin_number >> 5;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "pwmout_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -57,7 +57,7 @@ static unsigned int pwm_clock_mhz;
|
|||
void pwmout_init(pwmout_t* obj, PinName pin) {
|
||||
// determine the channel
|
||||
PWMName pwm = (PWMName)pinmap_peripheral(pin, PinMap_PWM);
|
||||
assert(pwm != (PWMName)NC);
|
||||
MBED_ASSERT(pwm != (PWMName)NC);
|
||||
|
||||
obj->pwm = pwm;
|
||||
obj->MR = PWM_MATCH[pwm];
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
// math.h required for floating point operations for baud rate calculation
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -65,7 +65,7 @@ void serial_init(serial_t *obj, PinName tx, PinName rx) {
|
|||
UARTName uart_tx = (UARTName)pinmap_peripheral(tx, PinMap_UART_TX);
|
||||
UARTName uart_rx = (UARTName)pinmap_peripheral(rx, PinMap_UART_RX);
|
||||
UARTName uart = (UARTName)pinmap_merge(uart_tx, uart_rx);
|
||||
assert((int)uart != NC);
|
||||
MBED_ASSERT((int)uart != NC);
|
||||
|
||||
obj->uart = (LPC_UART_TypeDef *)uart;
|
||||
// enable power
|
||||
|
|
@ -121,7 +121,7 @@ void serial_free(serial_t *obj) {
|
|||
// serial_baud
|
||||
// set the baud rate, taking in to account the current SystemFrequency
|
||||
void serial_baud(serial_t *obj, int baudrate) {
|
||||
assert((int)obj->uart <= UART_3);
|
||||
MBED_ASSERT((int)obj->uart <= UART_3);
|
||||
// The LPC2300 and LPC1700 have a divider and a fractional divider to control the
|
||||
// baud rate. The formula is:
|
||||
//
|
||||
|
|
@ -217,9 +217,9 @@ void serial_baud(serial_t *obj, int baudrate) {
|
|||
}
|
||||
|
||||
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits) {
|
||||
assert((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits
|
||||
assert((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits
|
||||
assert((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) ||
|
||||
MBED_ASSERT((stop_bits == 1) || (stop_bits == 2)); // 0: 1 stop bits, 1: 2 stop bits
|
||||
MBED_ASSERT((data_bits > 4) && (data_bits < 9)); // 0: 5 data bits ... 3: 8 data bits
|
||||
MBED_ASSERT((parity == ParityNone) || (parity == ParityOdd) || (parity == ParityEven) ||
|
||||
(parity == ParityForced1) || (parity == ParityForced0));
|
||||
|
||||
stop_bits -= 1;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include "assert.h"
|
||||
#include <math.h>
|
||||
|
||||
#include "spi_api.h"
|
||||
|
|
@ -64,7 +65,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
SPIName spi_data = (SPIName)pinmap_merge(spi_mosi, spi_miso);
|
||||
SPIName spi_cntl = (SPIName)pinmap_merge(spi_sclk, spi_ssel);
|
||||
obj->spi = (LPC_SSP_TypeDef*)pinmap_merge(spi_data, spi_cntl);
|
||||
assert((int)obj->spi != NC);
|
||||
MBED_ASSERT((int)obj->spi != NC);
|
||||
|
||||
// enable power and clocking
|
||||
switch ((int)obj->spi) {
|
||||
|
|
@ -95,7 +96,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
|
|||
void spi_free(spi_t *obj) {}
|
||||
|
||||
void spi_format(spi_t *obj, int bits, int mode, int slave) {
|
||||
assert(((bits >= 4) && (bits <= 16)) && (((mode >= 0) && (mode <= 3)));
|
||||
MBED_ASSERT(((bits >= 4) && (bits <= 16)) && ((mode >= 0) && (mode <= 3)));
|
||||
ssp_disable(obj);
|
||||
|
||||
int polarity = (mode & 0x2) ? 1 : 0;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogin_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -44,7 +44,7 @@ static const PinMap PinMap_ADC[] = {
|
|||
|
||||
void analogin_init(analogin_t *obj, PinName pin) {
|
||||
obj->adc = (ADCName)pinmap_peripheral(pin, PinMap_ADC);
|
||||
assert(obj->adc != (ADCName)NC);
|
||||
MBED_ASSERT(obj->adc != (ADCName)NC);
|
||||
|
||||
// ensure power is turned on
|
||||
LPC_SC->PCONP |= (1 << 12);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include "assert.h"
|
||||
#include "analogout_api.h"
|
||||
#include "cmsis.h"
|
||||
#include "pinmap.h"
|
||||
|
|
@ -25,7 +25,7 @@ static const PinMap PinMap_DAC[] = {
|
|||
|
||||
void analogout_init(dac_t *obj, PinName pin) {
|
||||
obj->dac = (DACName)pinmap_peripheral(pin, PinMap_DAC);
|
||||
assert(obj->dac != (DACName)NC);
|
||||
MBED_ASSERT(obj->dac != (DACName)NC);
|
||||
|
||||
// DAC enable bit must be set
|
||||
LPC_IOCON->P0_26 |= (1 << 16); // DACEN
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue