first commit

This commit is contained in:
pvvx 2016-11-09 03:56:41 +03:00
parent 2ee525362e
commit d108756e9b
792 changed files with 336059 additions and 0 deletions

View file

@ -0,0 +1,39 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_ANALOGIN_API_H
#define MBED_ANALOGIN_API_H
#include "device.h"
#if DEVICE_ANALOGIN
#ifdef __cplusplus
extern "C" {
#endif
typedef struct analogin_s analogin_t;
void analogin_init (analogin_t *obj, PinName pin);
float analogin_read (analogin_t *obj);
uint16_t analogin_read_u16(analogin_t *obj);
#ifdef __cplusplus
}
#endif
#endif
#endif

View file

@ -0,0 +1,42 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_ANALOGOUT_API_H
#define MBED_ANALOGOUT_API_H
#include "device.h"
#if DEVICE_ANALOGOUT
#ifdef __cplusplus
extern "C" {
#endif
typedef struct dac_s dac_t;
void analogout_init (dac_t *obj, PinName pin);
void analogout_free (dac_t *obj);
void analogout_write (dac_t *obj, float value);
void analogout_write_u16(dac_t *obj, uint16_t value);
float analogout_read (dac_t *obj);
uint16_t analogout_read_u16 (dac_t *obj);
#ifdef __cplusplus
}
#endif
#endif
#endif

View file

@ -0,0 +1,80 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_CAN_API_H
#define MBED_CAN_API_H
#include "device.h"
#if DEVICE_CAN
#include "PinNames.h"
#include "PeripheralNames.h"
#include "can_helper.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
IRQ_RX,
IRQ_TX,
IRQ_ERROR,
IRQ_OVERRUN,
IRQ_WAKEUP,
IRQ_PASSIVE,
IRQ_ARB,
IRQ_BUS,
IRQ_READY
} CanIrqType;
typedef enum {
MODE_RESET,
MODE_NORMAL,
MODE_SILENT,
MODE_TEST_GLOBAL,
MODE_TEST_LOCAL,
MODE_TEST_SILENT
} CanMode;
typedef void (*can_irq_handler)(uint32_t id, CanIrqType type);
typedef struct can_s can_t;
void can_init (can_t *obj, PinName rd, PinName td);
void can_free (can_t *obj);
int can_frequency(can_t *obj, int hz);
void can_irq_init (can_t *obj, can_irq_handler handler, uint32_t id);
void can_irq_free (can_t *obj);
void can_irq_set (can_t *obj, CanIrqType irq, uint32_t enable);
int can_write (can_t *obj, CAN_Message, int cc);
int can_read (can_t *obj, CAN_Message *msg, int handle);
int can_mode (can_t *obj, CanMode mode);
int can_filter(can_t *obj, uint32_t id, uint32_t mask, CANFormat format, int32_t handle);
void can_reset (can_t *obj);
unsigned char can_rderror (can_t *obj);
unsigned char can_tderror (can_t *obj);
void can_monitor (can_t *obj, int silent);
#ifdef __cplusplus
};
#endif
#endif // MBED_CAN_API_H
#endif

View file

@ -0,0 +1,63 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_ETHERNET_API_H
#define MBED_ETHERNET_API_H
#include "device.h"
#if DEVICE_ETHERNET
#ifdef __cplusplus
extern "C" {
#endif
// Connection constants
int ethernet_init(void);
void ethernet_free(void);
// write size bytes from data to ethernet buffer
// return num bytes written
// or -1 if size is too big
int ethernet_write(const char *data, int size);
// send ethernet write buffer, returning the packet size sent
int ethernet_send(void);
// recieve from ethernet buffer, returning packet size, or 0 if no packet
int ethernet_receive(void);
// read size bytes in to data, return actual num bytes read (0..size)
// if data == NULL, throw the bytes away
int ethernet_read(char *data, int size);
// get the ethernet address
void ethernet_address(char *mac);
// see if the link is up
int ethernet_link(void);
// force link settings
void ethernet_set_link(int speed, int duplex);
#ifdef __cplusplus
}
#endif
#endif
#endif

View file

@ -0,0 +1,51 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_GPIO_API_H
#define MBED_GPIO_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Set the given pin as GPIO
* @param pin The pin to be set as GPIO
* @return The GPIO port mask for this pin
**/
uint32_t gpio_set(PinName pin);
/* GPIO object */
void gpio_init(gpio_t *obj, PinName pin);
void gpio_mode (gpio_t *obj, PinMode mode);
void gpio_dir (gpio_t *obj, PinDirection direction);
void gpio_write(gpio_t *obj, int value);
int gpio_read (gpio_t *obj);
// the following set of functions are generic and are implemented in the common gpio.c file
void gpio_init_in(gpio_t* gpio, PinName pin);
void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode);
void gpio_init_out(gpio_t* gpio, PinName pin);
void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value);
void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,47 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_GPIO_IRQ_API_H
#define MBED_GPIO_IRQ_API_H
#include "device.h"
#if DEVICE_INTERRUPTIN
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
IRQ_NONE,
IRQ_RISE,
IRQ_FALL
} gpio_irq_event;
typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event);
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id);
void gpio_irq_free(gpio_irq_t *obj);
void gpio_irq_set (gpio_irq_t *obj, gpio_irq_event event, uint32_t enable);
void gpio_irq_enable(gpio_irq_t *obj);
void gpio_irq_disable(gpio_irq_t *obj);
#ifdef __cplusplus
}
#endif
#endif
#endif

View file

@ -0,0 +1,59 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_I2C_API_H
#define MBED_I2C_API_H
#include "device.h"
#if DEVICE_I2C
#ifdef __cplusplus
extern "C" {
#endif
typedef struct i2c_s i2c_t;
enum {
I2C_ERROR_NO_SLAVE = -1,
I2C_ERROR_BUS_BUSY = -2
};
void i2c_init (i2c_t *obj, PinName sda, PinName scl);
void i2c_frequency (i2c_t *obj, int hz);
int i2c_start (i2c_t *obj);
int i2c_stop (i2c_t *obj);
int i2c_read (i2c_t *obj, int address, char *data, int length, int stop);
int i2c_write (i2c_t *obj, int address, const char *data, int length, int stop);
void i2c_reset (i2c_t *obj);
int i2c_byte_read (i2c_t *obj, int last);
int i2c_byte_write (i2c_t *obj, int data);
#if DEVICE_I2CSLAVE
void i2c_slave_mode (i2c_t *obj, int enable_slave);
int i2c_slave_receive(i2c_t *obj);
int i2c_slave_read (i2c_t *obj, char *data, int length);
int i2c_slave_write (i2c_t *obj, const char *data, int length);
void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask);
#endif
#ifdef __cplusplus
}
#endif
#endif
#endif

View file

@ -0,0 +1,43 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_PINMAP_H
#define MBED_PINMAP_H
#include "PinNames.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct {
PinName pin;
int peripheral;
int function;
} PinMap;
void pin_function(PinName pin, int function);
void pin_mode (PinName pin, PinMode mode);
uint32_t pinmap_peripheral(PinName pin, const PinMap* map);
uint32_t pinmap_merge (uint32_t a, uint32_t b);
void pinmap_pinout (PinName pin, const PinMap *map);
uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,42 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_PORTMAP_H
#define MBED_PORTMAP_H
#include "device.h"
#if DEVICE_PORTIN || DEVICE_PORTOUT
#ifdef __cplusplus
extern "C" {
#endif
typedef struct port_s port_t;
PinName port_pin(PortName port, int pin_n);
void port_init (port_t *obj, PortName port, int mask, PinDirection dir);
void port_mode (port_t *obj, PinMode mode);
void port_dir (port_t *obj, PinDirection dir);
void port_write(port_t *obj, int value);
int port_read (port_t *obj);
#ifdef __cplusplus
}
#endif
#endif
#endif

View file

@ -0,0 +1,49 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_PWMOUT_API_H
#define MBED_PWMOUT_API_H
#include "device.h"
#if DEVICE_PWMOUT
#ifdef __cplusplus
extern "C" {
#endif
typedef struct pwmout_s pwmout_t;
void pwmout_init (pwmout_t* obj, PinName pin);
void pwmout_free (pwmout_t* obj);
void pwmout_write (pwmout_t* obj, float percent);
float pwmout_read (pwmout_t* obj);
void pwmout_period (pwmout_t* obj, float seconds);
void pwmout_period_ms (pwmout_t* obj, int ms);
void pwmout_period_us (pwmout_t* obj, int us);
void pwmout_pulsewidth (pwmout_t* obj, float seconds);
void pwmout_pulsewidth_ms(pwmout_t* obj, int ms);
void pwmout_pulsewidth_us(pwmout_t* obj, int us);
#ifdef __cplusplus
}
#endif
#endif
#endif

View file

@ -0,0 +1,42 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_RTC_API_H
#define MBED_RTC_API_H
#include "device.h"
#if DEVICE_RTC
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
void rtc_init(void);
void rtc_free(void);
int rtc_isenabled(void);
time_t rtc_read(void);
void rtc_write(time_t t);
#ifdef __cplusplus
}
#endif
#endif
#endif

View file

@ -0,0 +1,78 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_SERIAL_API_H
#define MBED_SERIAL_API_H
#include "device.h"
#if DEVICE_SERIAL
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
ParityNone = 0,
ParityOdd = 1,
ParityEven = 2,
ParityForced1 = 3,
ParityForced0 = 4
} SerialParity;
typedef enum {
RxIrq,
TxIrq
} SerialIrq;
typedef enum {
FlowControlNone,
FlowControlRTS,
FlowControlCTS,
FlowControlRTSCTS
} FlowControl;
typedef void (*uart_irq_handler)(uint32_t id, SerialIrq event);
typedef struct serial_s serial_t;
void serial_init (serial_t *obj, PinName tx, PinName rx);
void serial_free (serial_t *obj);
void serial_baud (serial_t *obj, int baudrate);
void serial_format (serial_t *obj, int data_bits, SerialParity parity, int stop_bits);
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id);
void serial_irq_set (serial_t *obj, SerialIrq irq, uint32_t enable);
int serial_getc (serial_t *obj);
void serial_putc (serial_t *obj, int c);
int serial_readable (serial_t *obj);
int serial_writable (serial_t *obj);
void serial_clear (serial_t *obj);
void serial_break_set (serial_t *obj);
void serial_break_clear(serial_t *obj);
void serial_pinout_tx(PinName tx);
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow);
#ifdef __cplusplus
}
#endif
#endif
#endif

View file

@ -0,0 +1,64 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_SLEEP_API_H
#define MBED_SLEEP_API_H
#include "device.h"
#if DEVICE_SLEEP
#ifdef __cplusplus
extern "C" {
#endif
/** Send the microcontroller to sleep
*
* The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the
* system clock to the core is stopped until a reset or an interrupt occurs. This eliminates
* dynamic power used by the processor, memory systems and buses. The processor, peripheral and
* memory state are maintained, and the peripherals continue to work and can generate interrupts.
*
* The processor can be woken up by any internal peripheral interrupt or external pin interrupt.
*
* @note
* The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
* able to access the LocalFileSystem
*/
void sleep(void);
/** Send the microcontroller to deep sleep
*
* This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode
* has the same sleep features as sleep plus it powers down peripherals and clocks. All state
* is still maintained.
*
* The processor can only be woken up by an external interrupt on a pin or a watchdog timer.
*
* @note
* The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
* able to access the LocalFileSystem
*/
void deepsleep(void);
#ifdef __cplusplus
}
#endif
#endif
#endif

View file

@ -0,0 +1,45 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_SPI_API_H
#define MBED_SPI_API_H
#include "device.h"
#if DEVICE_SPI
#ifdef __cplusplus
extern "C" {
#endif
typedef struct spi_s spi_t;
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);
void spi_frequency (spi_t *obj, int hz);
int spi_master_write (spi_t *obj, int value);
int spi_slave_receive(spi_t *obj);
int spi_slave_read (spi_t *obj);
void spi_slave_write (spi_t *obj, int value);
int spi_busy (spi_t *obj);
#ifdef __cplusplus
}
#endif
#endif
#endif

View file

@ -0,0 +1,51 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 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_US_TICKER_API_H
#define MBED_US_TICKER_API_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef uint64_t timestamp_t;
uint32_t us_ticker_read(void);
typedef void (*ticker_event_handler)(uint32_t id);
void us_ticker_set_handler(ticker_event_handler handler);
typedef struct ticker_event_s {
timestamp_t timestamp;
uint32_t id;
struct ticker_event_s *next;
} ticker_event_t;
void us_ticker_init(void);
void us_ticker_set_interrupt(timestamp_t timestamp);
void us_ticker_disable_interrupt(void);
void us_ticker_clear_interrupt(void);
void us_ticker_irq_handler(void);
void us_ticker_insert_event(ticker_event_t *obj, timestamp_t timestamp, uint32_t id);
void us_ticker_remove_event(ticker_event_t *obj);
#ifdef __cplusplus
}
#endif
#endif