ameba micropython sdk first commit

This commit is contained in:
xidameng 2020-07-31 22:16:12 +08:00
commit 8508ee6139
5619 changed files with 1874619 additions and 0 deletions

View file

@ -0,0 +1,66 @@
/* 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_ERROR_H
#define MBED_ERROR_H
/** To generate a fatal compile-time error, you can use the pre-processor #error directive.
*
* @code
* #error "That shouldn't have happened!"
* @endcode
*
* If the compiler evaluates this line, it will report the error and stop the compile.
*
* For example, you could use this to check some user-defined compile-time variables:
*
* @code
* #define NUM_PORTS 7
* #if (NUM_PORTS > 4)
* #error "NUM_PORTS must be less than 4"
* #endif
* @endcode
*
* Reporting Run-Time Errors:
* To generate a fatal run-time error, you can use the mbed error() function.
*
* @code
* error("That shouldn't have happened!");
* @endcode
*
* If the mbed running the program executes this function, it will print the
* message via the USB serial port, and then die with the blue lights of death!
*
* The message can use printf-style formatting, so you can report variables in the
* message too. For example, you could use this to check a run-time condition:
*
* @code
* if(x >= 5) {
* error("expected x to be less than 5, but got %d", x);
* }
* #endcode
*/
#ifdef __cplusplus
extern "C" {
#endif
void error(const char* format, ...);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,50 @@
/* 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_ASSERT_H
#define MBED_ASSERT_H
#ifdef __cplusplus
extern "C" {
#endif
/** Internal mbed assert function which is invoked when MBED_ASSERT macro failes.
* This function is active only if NDEBUG is not defined prior to including this
* assert header file.
* 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

View file

@ -0,0 +1,74 @@
/* 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.
*/
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Implementation of the C time.h functions
*
* Provides mechanisms to set and read the current time, based
* on the microcontroller Real-Time Clock (RTC), plus some
* standard C manipulation and formating functions.
*
* Example:
* @code
* #include "mbed.h"
*
* int main() {
* set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37
*
* while(1) {
* time_t seconds = time(NULL);
*
* printf("Time as seconds since January 1, 1970 = %d\n", seconds);
*
* printf("Time as a basic string = %s", ctime(&seconds));
*
* char buffer[32];
* strftime(buffer, 32, "%I:%M %p\n", localtime(&seconds));
* printf("Time as a custom formatted string = %s", buffer);
*
* wait(1);
* }
* }
* @endcode
*/
/** Set the current time
*
* Initialises and sets the time of the microcontroller Real-Time Clock (RTC)
* to the time represented by the number of seconds since January 1, 1970
* (the UNIX timestamp).
*
* @param t Number of seconds since January 1, 1970 (the UNIX timestamp)
*
* Example:
* @code
* #include "mbed.h"
*
* int main() {
* set_time(1256729737); // Set time to Wed, 28 Oct 2009 11:35:37
* }
* @endcode
*/
void set_time(time_t t);
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,66 @@
/* 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_WAIT_API_H
#define MBED_WAIT_API_H
#ifdef __cplusplus
extern "C" {
#endif
/** Generic wait functions.
*
* These provide simple NOP type wait capabilities.
*
* Example:
* @code
* #include "mbed.h"
*
* DigitalOut heartbeat(LED1);
*
* int main() {
* while (1) {
* heartbeat = 1;
* wait(0.5);
* heartbeat = 0;
* wait(0.5);
* }
* }
*/
/** Waits for a number of seconds, with microsecond resolution (within
* the accuracy of single precision floating point).
*
* @param s number of seconds to wait
*/
void wait(float s);
/** Waits a number of milliseconds.
*
* @param ms the whole number of milliseconds to wait
*/
void wait_ms(int ms);
/** Waits a number of microseconds.
*
* @param us the whole number of microseconds to wait
*/
void wait_us(int us);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,81 @@
/** mbed Microcontroller Library
******************************************************************************
* @file analogin_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed Analog_in API
******************************************************************************
* @attention
*
* 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"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup analog_in ANALOG_IN
* @ingroup hal
* @brief analog_in functions
* @{
*/
///@name Ameba Common
///@{
typedef struct analogin_s analogin_t;
/**
* @brief Initializes the ADC device, include clock/function/ADC registers.
* @param obj: adc object define in application software.
* @param pin: adc PinName according to pinmux spec.
* @retval none
*/
void analogin_init(analogin_t *obj, PinName pin);
/**
* @brief Deinitializes the ADC device, include clock/function/ADC registers.
* @param obj: adc object define in application software.
* @retval none
*/
void analogin_deinit(analogin_t *obj);
/**
* @brief Reads data from the specified adc channel fifo.
* @param obj: adc object define in application software.
* @retval : adc channel data(float)
*/
float analogin_read(analogin_t *obj);
/**
* @brief Reads data from the specified adc channel fifo.
* @param obj: adc object define in application software.
* @retval : 16bit adc channel data(int)
*/
uint16_t analogin_read_u16(analogin_t *obj);
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif//MBED_ANALOGIN_API_H

View file

@ -0,0 +1,97 @@
/** mbed Microcontroller Library
******************************************************************************
* @file analogout_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed Analog_out API
******************************************************************************
* @attention
*
* 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"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup analog_out ANALOG_OUT
* @ingroup hal
* @brief analog_out functions
* @{
*/
#if defined(CONFIG_PLATFORM_8195A) && (CONFIG_PLATFORM_8195A == 1)
///@name Ameba1 Only
///@{
typedef struct dac_s dac_t;
/**
* @brief Initialize DAC
* @param obj: dac object define in application software.
* @param pin: dac PinName according to pinmux spec.
* @retval none
*/
void analogout_init(dac_t *obj, PinName pin);
/**
* @brief Free DAC
* @param obj: dac object define in application software.
* @retval none
*/
void analogout_free(dac_t *obj);
/**
* @brief Execute analog output
* @para obj: dac object define in application software.
* @para value: analog ratio value, should be transfered to register value.
* @retval none
* @note This function is mainly to execute analog output and the value is a ratio.
* The upper/lower bound of DAC register input value is defined by
* DAC_XXXXX_FULL_SCALE. The parameter "value" of this function should be
* transfered to register value.
*/
void analogout_write(dac_t *obj, float value);
/**
* @brief Execute analog output 16bit
* @para obj: dac object define in application software.
* @para value: analog ratio value, should be transfered to register value.
* @retval none
* @note The register value of DAC input is a format of 2's complement.
* The most maximum value of positive value drives DAC to output a voltage about 3.3V.
* The most mimimum value of negative value drives DAC to output a voltage about 0.
* And the middle value of 0x000 will drive DAC to output a voltage of half of max voltage.
*/
void analogout_write_u16(dac_t *obj, uint16_t value);
///@}
#endif //CONFIG_PLATFORM_8195A
/**@}*/
#ifdef __cplusplus
}
#endif
#endif//MBED_ANALOGOUT_API_H

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,178 @@
/** mbed Microcontroller Library
******************************************************************************
* @file timer_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed I2C API
******************************************************************************
* @attention
*
* 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.
******************************************************************************
*/
#include "device.h"
#ifndef __RTK_DCT_H__
#define __RTK_DCT_H__
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup dct DCT
* @ingroup hal
* @brief dct functions
* @{
*/
///@name Ameba Common
///@{
enum{
DCT_SUCCESS = 0,
DCT_ERR = -1,
DCT_ERR_CRC = -2,
DCT_ERR_NO_SPACE = -3,
DCT_ERR_NO_MEMORY = -4,
DCT_ERR_FLASH_RW = -5,
DCT_ERR_NOT_FIND = -6,
DCT_ERR_INVALID = -7,
DCT_ERR_SIZE_OVER = -8,
DCT_ERR_MODULE_BUSY = -9,
};
enum{
DCT_MODULE_STATE_INIT = 0xFFFFFFFF,
DCT_MODULE_STATE_VALID = 0xFFFFFFFE,
DCT_MODULE_STATE_DELETING = 0xFFFFFFFC,
DCT_MODULE_STATE_DELETED = 0xFFFFFFF8,
};
/**
* @brief Initialize device configuration table.
* @param none
* @retval 32 bit
*/
int32_t dct_init(void);
/**
* @brief Deinitialize device configuration table.
* @retval none
*/
void dct_deinit(void);
/**
* @brief Register module in DCT.
* @param module_name : module name
* @retval 0 : SUCCESS
* @retval <0 : ERROR
*/
int32_t dct_register_module(char *module_name);
/**
* @brief Unregister and delete module in DCT.
* @param module_name : module name
* @retval 0 : SUCCESS
* @retval <0 : ERROR
*/
int32_t dct_unregister_module(char *module_name);
/**
* @brief Open module in DCT.
* @param dct_handle : setup module informations in dct handler
* @param module_name : module name
* @retval 0 : SUCCESS
* @retval <0 : ERROR
*/
int32_t dct_open_module(dct_handle_t *dct_handle, char *module_name);
/**
* @brief Close module in DCT.
* @param dct_handle : dct handler
* @retval 0 : SUCCESS
* @retval <0 : ERROR
*/
int32_t dct_close_module(dct_handle_t *dct_handle);
/**
* @brief Write variable name and value in opened module.
* @param dct_handle : dct handler
* @param variable_name : variable name which you want to store in module
* @param variable_value : variable value which you want to store in module
* @retval 0 : SUCCESS
* @retval <0 : ERROR
*/
int32_t dct_set_variable(dct_handle_t *dct_handle, char *variable_name, char *variable_value);
/**
* @brief Read value of variable name in opened module.
* @param dct_handle : dct handler
* @param variable_name : variable name which you want to get from module
* @param buffer : read variable value
* @param buffer_size : the buffer size
* @retval 0 : SUCCESS
* @retval <0 : ERROR
*/
int32_t dct_get_variable(dct_handle_t *dct_handle, char *variable_name, char *buffer, uint16_t buffer_size);
/**
* @brief Delete variable name and value in opened module.
* @param dct_handle : dct handler
* @param variable_name : variable name which you want to delete in module
* @retval 0 : SUCCESS
* @retval <0 : ERROR
*/
int32_t dct_delete_variable(dct_handle_t *dct_handle, char *variable_name);
#ifdef __cplusplus
}
#endif
#endif/* MBED_TIMER_API_H */

View file

@ -0,0 +1,126 @@
/* 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
/** @addtogroup ethernet ETHERNET
* @ingroup hal
* @brief ETHERNET functions
* @{
*/
/**
* @brief To initialize the Ethernet MAC controller.
*
* @param None
*
* @returns The result.
*/
int ethernet_init(void);
/**
* @brief To de-initialize the Ethernet MAC controller.
*
* @param None
*
* @returns void.
*/
void ethernet_free(void);
/**
* @brief To write "size" bytes of data from "data" to the Tx packet buffer.
*
* @param[in] data The buffer of packet data.
* @param[in] size The size of the packet data.
*
* @returns The number of bytes written, or (-1) if errors.
*/
int ethernet_write(const char *data, int size);
/**
* @brief To send the packet from Tx packet buffer.
*
* @param None
*
* @returns The packet size.
*/
int ethernet_send(void);
/**
* @brief To receive a packet into the Rx packet buffer.
*
* @param None
*
* @returns The packet size, or 0 if no packet received.
*/
int ethernet_receive(void);
/**
* @brief To read packet data from Rx packet buffer to the "data" buffer.
*
* @param[in] data A buffer for the packet data.
* @param[in] size The specified length (in bytes) to be read.
*
* @returns The actual size (in bytes) of data read.
*/
int ethernet_read(char *data, int size);
/**
* @brief To get the ethernet MAC address.
*
* @param[in] mac The buffer of MAC address.
*
* @returns void.
*/
void ethernet_address(char *mac);
/**
* @brief To get the link status.
*
* @param None
*
* @returns 1 for link up, 0 for link down.
*/
int ethernet_link(void);
/**
* @brief To set the link speed and duplex mode.
*
* @param[in] speed The specified link speed.
* @param[in] duplex The specifed duplex mode.
*
* @returns void.
*/
void ethernet_set_link(int speed, int duplex);
/** @} */ /* End of group ethernet */
#ifdef __cplusplus
}
#endif
#endif
#endif

View file

@ -0,0 +1,109 @@
/** mbed Microcontroller Library
******************************************************************************
* @file gpio_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed GPIO API
******************************************************************************
* @attention
*
* 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
/** @addtogroup gpio GPIO
* @ingroup hal
* @brief gpio functions
* @{
*/
///@name Ameba Common
///@{
/**
* @brief Initializes the GPIO device, include mode/direction/pull control registers.
* @param obj: gpio object define in application software.
* @param pin: PinName according to pinmux spec.
* @retval none
*/
void gpio_init(gpio_t *obj, PinName pin);
/**
* @brief Set the given pin as GPIO.
* @param pin: PinName according to pinmux spec.
* @retval : The given pin with GPIO function
*/
uint32_t gpio_set(PinName pin);
/**
* @brief Set GPIO mode.
* @param obj: gpio object define in application software.
* @param mode: this parameter can be one of the following values:
* @arg PullNone: HighZ, user can input high or low use this pin
* @arg OpenDrain(is OpenDrain output): no pull + OUT + GPIO[gpio_bit] = 0
* @arg PullDown: pull down
* @arg PullUp: pull up
* @retval none
*/
void gpio_mode(gpio_t *obj, PinMode mode);
/**
* @brief Set GPIO direction.
* @param obj: gpio object define in application software.
* @param direction: this parameter can be one of the following values:
* @arg PIN_INPUT: this pin is input
* @arg PIN_OUTPUT: this pin is output
* @retval none
*/
void gpio_dir(gpio_t *obj, PinDirection direction);
/**
* @brief Sets value to the selected output port pin.
* @param obj: gpio object define in application software.
* @param value: specifies the value to be written to the selected pin
* This parameter can be one of the following values:
* @arg 0: Pin state set to low
* @arg 1: Pin state set to high
* @retval none
*/
void gpio_write(gpio_t *obj, int value);
/**
* @brief Reads the specified gpio port pin.
* @param obj: gpio object define in application software.
* @retval 1: pin state is high
* @retval 0: pin state is low
*/
int gpio_read(gpio_t *obj);
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif//MBED_GPIO_API_H

View file

@ -0,0 +1,121 @@
/** mbed Microcontroller Library
******************************************************************************
* @file gpio_irq_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed GPIO IRQ API
******************************************************************************
* @attention
*
* 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"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup gpio_irq_api GPIO_IRQ
* @ingroup hal
* @brief gpio IRQ functions
* @{
*/
///@name Ameba Common
///@{
typedef enum {
IRQ_NONE,
IRQ_RISE,
IRQ_FALL
} gpio_irq_event;
typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event);
/**
* @brief Initializes the GPIO device interrupt mode, include mode/trigger/polarity registers.
* @param obj: gpio irq object define in application software.
* @param pin: PinName according to pinmux spec.
* @param handler: Interrupt handler to be assigned to the specified pin.
* @param id: handler id.
* @retval none
* @note this API only works for Port A pins
*/
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id);
/**
* @brief Deinitializes the GPIO device interrupt mode, include mode/trigger/polarity registers.
* @param obj: gpio irq object define in application software.
* @retval none
* @note this API only works for Port A pins
*/
void gpio_irq_free(gpio_irq_t *obj);
/**
* @brief Enable/Disable gpio interrupt.
* @param obj: gpio irq object define in application software.
* @param event: gpio interrupt event, this parameter can be one of the following values:
* @arg IRQ_RISE: rising edge interrupt event
* @arg IRQ_FALL: falling edge interrupt event
* @arg IRQ_LOW: low level interrupt event
* @arg IRQ_HIGH: high level interrupt event
* @arg IRQ_NONE: no interrupt event
* @param enable: this parameter can be one of the following values:
* @arg 0 disable gpio interrupt
* @arg 1 enable gpio interrupt
* @retval none
*/
void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable);
/**
* @brief Enable gpio interrupt.
* @param obj: gpio irq object define in application software.
* @retval none
*/
void gpio_irq_enable(gpio_irq_t *obj);
/**
* @brief Disable gpio interrupt.
* @param obj: gpio irq object define in application software.
* @retval none
*/
void gpio_irq_disable(gpio_irq_t *obj);
/**
* @brief Enable the specified gpio interrupt event.
* @param obj: gpio irq object define in application software.
* @param event: gpio interrupt event, this parameter can be one of the following values:
* @arg IRQ_RISE: rising edge interrupt event
* @arg IRQ_FALL: falling edge interrupt event
* @arg IRQ_LOW: low level interrupt event
* @arg IRQ_HIGH: high level interrupt event
* @arg IRQ_NONE: no interrupt event
* @retval none
*/
void gpio_irq_set_event(gpio_irq_t *obj, gpio_irq_event event);
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,212 @@
/** mbed Microcontroller Library
******************************************************************************
* @file i2c_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed I2C API
******************************************************************************
* @attention
*
* 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"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup i2c I2C
* @ingroup hal
* @brief I2C functions
* @{
*/
///@name Ameba Common
///@{
typedef struct i2c_s i2c_t;
enum {
I2C_ERROR_NO_SLAVE = -1,
I2C_ERROR_BUS_BUSY = -2
};
/**
* @brief Initializes the I2C device, include clock/function/I2C registers.
* @param obj: i2c object define in application software.
* @param sda: SDA PinName according to pinmux spec.
* @param scl: SCL PinName according to pinmux spec.
* @retval none
*/
void i2c_init(i2c_t *obj, PinName sda, PinName scl);
/**
* @brief Set i2c frequency.
* @param obj: i2c object define in application software.
* @param hz: i2c clock(unit is Hz).
* @retval none
*/
void i2c_frequency(i2c_t *obj, int hz);
/**
* @brief Start i2c device.
* @param obj: i2c object define in application software.
* @retval 0
*/
int i2c_start(i2c_t *obj);
/**
* @brief Stop i2c device.
* @param obj: i2c object define in application software.
* @retval 0
*/
int i2c_stop(i2c_t *obj);
/**
* @brief Deinitializes the I2C device
* @param obj: i2c object define in application software.
* @retval none
*/
void i2c_reset(i2c_t *obj);
/**
* @brief I2C master receive single byte.
* @param obj: i2c object define in application software.
* @param last: hold the received data.
* @retval : the received data.
*/
int i2c_byte_read(i2c_t *obj, int last);
/**
* @brief I2C master send single byte.
* @param obj: i2c object define in application software.
* @param data: the data to be sent.
* @retval : result.
*/
int i2c_byte_write(i2c_t *obj, int data);
/**
* @brief Set i2c device to be slave.
* @param obj: i2c object define in application software.
* @param enable_slave: enable slave function, this parameter can be one of the following values:
* @arg 0 disable
* @arg 1 enable
* @retval none
*/
void i2c_slave_mode(i2c_t *obj, int enable_slave);
/**
* @brief Get i2c slave state.
* @param obj: i2c object define in application software.
* @retval : the state of i2c slave.
*/
int i2c_slave_receive(i2c_t *obj);
/**
* @brief Set i2c slave address.
* @param obj: i2c object define in application software.
* @param idx: i2c index, this parameter can be one of the following values:
* @arg 0 I2C0 Device
* @arg 1 I2C1 Device
* @param address: slave address.
* @param mask: the mask of address
* @retval none
*/
void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask);
/**
* @brief I2C master read in poll mode.
* @param obj: i2c object define in application software.
* @param address: slave address which will be transmitted.
* @param data: point to the buffer to hold the received data.
* @param length: the length of data that to be received.
* @param stop: specifies whether a STOP is issued after all the bytes are received.
* @retval : the length of data received.
*/
int i2c_read(i2c_t *obj, int address, char *data, int length, int stop);
/**
* @brief I2C master write in poll mode.
* @param obj: i2c object define in application software.
* @param address: slave address which will be transmitted.
* @param data: point to the data to be sent.
* @param length: the length of data that to be sent.
* @param stop: specifies whether a STOP is issued after all the bytes are sent.
* @retval : the length of data send.
*/
int i2c_write(i2c_t *obj, int address, const char *data, int length, int stop);
/**
* @brief I2C slave read in poll mode.
* @param obj: i2c object define in application software.
* @param data: point to the buffer to hold the received data.
* @param length: the length of data that to be received.
* @retval : the length of data received.
*/
int i2c_slave_read(i2c_t *obj, char *data, int length);
/**
* @brief I2C slave write in poll mode.
* @param obj: i2c object define in application software.
* @param data: point to the data to be sent.
* @param length: the length of data that to be sent.
* @retval 0: FAIL
* @retval 1: SUCCESS
*/
int i2c_slave_write(i2c_t *obj, const char *data, int length);
/**
* @brief Set/clear i2c slave RD_REQ interrupt mask.
* @param obj: i2c object define in application software.
* @param set: set or clear for read request.
* @retval 1: SUCCESS
*/
int i2c_slave_set_for_rd_req(i2c_t *obj, int set);
/**
* @brief Set/clear i2c slave NAK or ACK data part in transfer.
* @param obj: i2c object define in application software.
* @param set_nak: set or clear for data NAK.
* @retval 1: SUCCESS
*/
int i2c_slave_set_for_data_nak(i2c_t *obj, int set_nak);
///@}
#if ((defined(CONFIG_PLATFORM_8711B) && (CONFIG_PLATFORM_8711B == 1)) || (defined (CONFIG_PLATFORM_8721D) && (CONFIG_PLATFORM_8721D == 1)))
///@name AmebaZ and AmebaD
///@{
/**
* @brief I2C master send data and read data in poll mode.
* @param obj: i2c object define in application software.
* @param address: slave address which will be transmitted.
* @param pWriteBuf: point to the data to be sent.
* @param Writelen: the length of data that to be sent.
* @param pReadBuf: point to the buffer to hold the received data.
* @param Readlen: the length of data that to be received.
* @retval the length of data received.
*/
int i2c_repeatread(i2c_t *obj, int address, u8 *pWriteBuf, int Writelen, u8 *pReadBuf, int Readlen) ;
///@}
#endif //(CONFIG_PLATFORM_8711B||CONFIG_PLATFORM_8721D)
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif/* MBED_I2C_API_H */

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,116 @@
/** mbed Microcontroller Library
******************************************************************************
* @file port_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed GPIO PORT API
******************************************************************************
* @attention
*
* 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"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup port PORT
* @ingroup hal
* @brief port functions
* @{
*/
///@name Ameba Common
///@{
typedef struct port_s port_t;
/**
* @brief Initializes the GPIO device port, include data direction registers.
* @param obj: gpio port object define in application software.
* @param port: PortName according to pinmux spec, this parameter can be one of the following values:
* @arg PortA: port A, has 32 pins
* @arg PortB: port B, has 7 pins
* @param mask: One bit one gpio pin, select one or multiple pins of the specified port.
* @param dir: gpio port direction, this parameter can be one of the following values:
* @arg PIN_INPUT: port pins are input
* @arg PIN_OUTPUT: port pins are output
* @retval none
*/
void port_init(port_t *obj, PortName port, int mask, PinDirection dir);
/**
* @brief Get GPIO port pin name
* @param port: PortName according to pinmux spec, this parameter can be one of the following values:
* @arg PortA: port number is A, has 32 pins
* @arg PortB: port number is B, has 7 pins
* @param pin_n: pin number.
* @retval none
* @note pin_n must be set to a value in the 0~31 range when PortA
* @note pin_n must be set to a value in the 0~6 range when PortB
*/
PinName port_pin(PortName port, int pin_n);
/**
* @brief Configure GPIO port pins pull up/pull down.
* @param obj: gpio port object define in application software.
* @param mode: this parameter can be one of the following values:
* @arg PullNone: HighZ
* @arg OpenDrain(is OpenDrain output): no pull + OUT + GPIO[gpio_bit] = 0
* @arg PullDown: pull down
* @arg PullUp: pull up
* @retval none
*/
void port_mode(port_t *obj, PinMode mode);
/**
* @brief Set GPIO port pins data direction.
* @param obj: gpio port object define in application software.
* @param dir: this parameter can be one of the following values:
* @arg PIN_INPUT: port pins are input
* @arg PIN_OUTPUT: port pins are output
* @retval none
*/
void port_dir(port_t *obj, PinDirection dir);
/**
* @brief Sets value to the selected port pins.
* @param obj: gpio port object define in application software.
* @param value: One bit one gpio pin, set value to one or multiple pins of the specified port.
* @retval none
* @note corresponding bit is 1, pin state set to high; corresponding bit is 0, pin state set to low
*/
void port_write(port_t *obj, int value);
/**
* @brief Reads the specified gpio port pins.
* @param obj: gpio port object define in application software.
* @retval : state of the specified gpio port pins
* @note corresponding bit is 1, pin state is high; corresponding bit is 0, pin state is low
*/
int port_read(port_t *obj);
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,151 @@
/** mbed Microcontroller Library
******************************************************************************
* @file pwmout_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed pwm API
******************************************************************************
* @attention
*
* 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"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup pwm PWM
* @ingroup hal
* @brief pwm functions
* @{
*/
///@name Ameba Common
///@{
typedef struct pwmout_s pwmout_t;
/**
* @brief Initializes the PWM function/registers of the specified pin with default parameters.
* @param obj: PWM object define in application software.
* @param pin: the pinname of specified channel to be set.
* @retval none
* @note
* - default period: 1638us
* - default pulse width: 102us
* - default duty cycle: 6.227%
*/
void pwmout_init(pwmout_t* obj, PinName pin);
/**
* @brief Deinitializes the PWM device of the specified channel.
* @param obj: PWM object define in application software.
* @retval none
* @note If all channels are released, TIM5 will also be disabled.
*/
void pwmout_free(pwmout_t* obj);
/**
* @brief Set the duty cycle of the specified channel.
* @param obj: PWM object define in application software.
* @param percent: The duty cycle value to be set.
* @retval none
*/
void pwmout_write(pwmout_t* obj, float percent);
/**
* @brief Get the duty cycle value of the specified channel.
* @param obj: PWM object define in application software.
* @retval : the duty cycle value of the specified channel.
*/
float pwmout_read(pwmout_t* obj);
/**
* @brief Set the period of the specified channel in seconds.
* @param obj: PWM object define in application software.
* @param seconds: The period value to be set in seconds.
* @retval none
*/
void pwmout_period(pwmout_t* obj, float seconds);
/**
* @brief Set the period of the specified channel in millseconds.
* @param obj: PWM object define in application software.
* @param ms: The period value to be set in millseconds.
* @retval none
*/
void pwmout_period_ms(pwmout_t* obj, int ms);
/**
* @brief Set the period of the specified channel in microseconds.
* @param obj: PWM object define in application software.
* @param us: The period value to be set in microseconds.
* @retval none
*/
void pwmout_period_us(pwmout_t* obj, int us);
/**
* @brief Set the pulse width of the specified channel in seconds.
* @param obj: PWM object define in application software.
* @param seconds: The pulse width value to be set in seconds.
* @retval none
*/
void pwmout_pulsewidth(pwmout_t* obj, float seconds);
/**
* @brief Set the pulse width of the specified channel in milliseconds.
* @param obj: PWM object define in application software.
* @param ms: The pulse width value to be set in milliseconds.
* @retval none
*/
void pwmout_pulsewidth_ms(pwmout_t* obj, int ms);
/**
* @brief Set the pulse width of the specified channel in microseconds.
* @param obj: PWM object define in application software.
* @param us: The pulse width value to be set in microseconds.
* @retval none
*/
void pwmout_pulsewidth_us(pwmout_t* obj, int us);
///@}
#if (defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)) || (defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1))|| (defined(CONFIG_PLATFORM_8710C) && (CONFIG_PLATFORM_8710C == 1))
///@name AmebaPro & AmebaZ2
///@{
/**
* @brief Set the polarity of the specified PWM channel.
* @param obj: PWM object define in application software.
* @param polarity:
0: Output low when timer count < setvalue.
1: Output high when timer count < setvalue.(default)
* note: use before setting duty cycle or pulse width.
* @retval none
*/
void pwmout_set_polarity(pwmout_t* obj, int polarity);
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP) || defined(CONFIG_PLATFORM_8195BLP) || (defined(CONFIG_PLATFORM_8710C)"
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,132 @@
/** mbed Microcontroller Library
******************************************************************************
* @file rtc_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed RTC API
******************************************************************************
* @attention
*
* 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"
#include <time.h>
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup rtc RTC
* @ingroup hal
* @brief rtc functions
* @{
*/
#if (defined(CONFIG_PLATFORM_8711B) && (CONFIG_PLATFORM_8711B == 1)) || \
(defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1)) || \
(defined(CONFIG_PLATFORM_8721D) && (CONFIG_PLATFORM_8721D == 1)) || \
(defined(CONFIG_PLATFORM_8710C) && (CONFIG_PLATFORM_8710C == 1))
///@name AmebaZ and AmebaPro and AmebaD and AmebaZ2
///@{
typedef void (*alarm_irq_handler)(void);
struct alarm_s {
uint32_t yday;//which day of the year
uint32_t hour;
uint32_t min;
uint32_t sec;
};
typedef struct alarm_s alarm_t;
///@}
#endif //CONFIG_PLATFORM_8711B || CONFIG_PLATFORM_8195BLP || CONFIG_PLATFORM_8721D || CONFIG_PLATFORM_8710C
///@name Ameba Common
///@{
/**
* @brief Initializes the RTC device, include clock, RTC registers and function.
* @param none
* @retval none
*/
void rtc_init(void);
/**
* @brief Deinitializes the RTC device.
* @param none
* @retval none
*/
void rtc_free(void);
/**
* @brief This function tells whether RTC is enabled or not.
* @param none
* @retval 1: RTC is enable.
* @retval 0: RTC is disable.
*/
int rtc_isenabled(void);
/**
* @brief Get current timestamp in seconds from RTC.
* @param none
* @retval : The current timestamp in seconds which is calculated from 1970.1.1 00:00:00.
*/
time_t rtc_read(void);
/**
* @brief Set the specified timestamp in seconds to RTC.
* @param t: Seconds from 1970.1.1 00:00:00 to specified data and time which is to be set.
* @retval none
*/
void rtc_write(time_t t);
///@}
#if (defined(CONFIG_PLATFORM_8711B) && (CONFIG_PLATFORM_8711B == 1)) || \
(defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1)) || \
(defined(CONFIG_PLATFORM_8721D) && (CONFIG_PLATFORM_8721D == 1)) || \
(defined(CONFIG_PLATFORM_8710C) && (CONFIG_PLATFORM_8710C == 1))
///@name AmebaZ and AmebaPro
///@{
/**
* @brief Set the specified RTC Alarm and interrupt.
* @param alarm: alarm object define in application software.
* @param alarmHandler: alarm interrupt callback function.
* @retval status:
* - 1: success
* - Others: failure
*/
u32 rtc_set_alarm(alarm_t *alrm, alarm_irq_handler alarmHandler);
/**
* @brief Disable RTC Alarm and function.
* @param none
* @retval none
*/
void rtc_disable_alarm(void);
///@}
#endif //CONFIG_PLATFORM_8711B || CONFIG_PLATFORM_8195BLP || CONFIG_PLATFORM_8721D || CONFIG_PLATFORM_8710C
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,232 @@
/** mbed Microcontroller Library
******************************************************************************
* @file serial_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed API for UART.
******************************************************************************
* @attention
*
* 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"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup uart UART
* @ingroup hal
* @brief uart functions
* @{
*/
///@name Ameba Common
///@{
/**
* @brief UART Parity mode
* used by serial_format
*/
typedef enum {
ParityNone = 0, /*!<parity disable */
ParityOdd = 1, /*!<odd parity enable */
ParityEven = 2, /*!<even paroty enable */
ParityForced1 = 3, /*!<same action with ParityOdd */
ParityForced0 = 4 /*!<same action with ParityEven */
} SerialParity;
/**
* @brief UART Interrupt enable/disable
* used by serial_irq_set
*/
typedef enum {
RxIrq, /*!<RX IRQ enable/disable */
TxIrq /*!<TX IRQ enable/disable */
} SerialIrq;
/**
* @brief UART FlowControl mode
* used by serial_set_flow_control
*/
typedef enum {
FlowControlNone, /*!<none RTS/CTS */
FlowControlRTS, /*!<RTS enable */
FlowControlCTS, /*!<CTS enable */
FlowControlRTSCTS /*!<RTS/CTS enable */
} FlowControl;
typedef void (*uart_irq_handler)(uint32_t id, SerialIrq event);
typedef struct serial_s serial_t;
/**
* @brief Initializes the UART device, include clock/function/interrupt/UART registers.
* @param obj: uart object define in application software.
* @param tx: Tx PinName according to pinmux spec.
* @param rx: Rx PinName according to pinmux spec.
* @retval none
*/
void serial_init(serial_t *obj, PinName tx, PinName rx);
/**
* @brief Deinitializes the UART device, include clock/function/interrupt/UART registers.
* @param obj: uart object define in application software.
* @retval none
*/
void serial_free(serial_t *obj);
/**
* @brief Set UART device baudrate.
* @param obj: uart object define in application software.
* @param baudrate: Baud Rate Val, like 115200 (unit is HZ).
* @retval none
*/
void serial_baud(serial_t *obj, int baudrate);
/**
* @brief Set UART format.
* @param obj: uart object define in application software.
* @param data_bits: data bits, this parameter can be one of the following values:
* @arg 7
* @arg 8
* @param parity: this parameter can be one of the following values:
* @arg ParityNone
* @arg ParityOdd
* @arg ParityEven
* @arg ParityForced1: same action with ParityOdd
* @arg ParityForced0: same action with ParityEven
* @param stop_bits: this parameter can be one of the following values:
* @arg 2
* @arg 1
* @retval none
*/
void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits);
/**
* @brief Set UART interrupt hander if needed.
* @param obj: uart object define in application software.
* @param handler: interrupt callback function
* @param id: interrupt callback parameter
* @retval none
*/
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id);
/**
* @brief Enable/Disable UART interrupt.
* @param obj: uart object define in application software.
* @param irq: Tx or Rx interrupt, this parameter can be one of the following values:
* @arg RxIrq
* @arg TxIrq
* @param enable: this parameter can be one of the following values:
* @arg 0 disable
* @arg 1 enable
* @retval none
*/
void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable);
/**
* @brief get one byte from UART.
* @param obj: uart object define in application software.
* @retval : received character
* @note this function is asynchronous API.
*/
int serial_getc(serial_t *obj);
/**
* @brief send one byte use UART.
* @param obj: uart object define in application software.
* @param c: the data to transmit.
* @retval none
* @note this function is asynchronous API.
*/
void serial_putc(serial_t *obj, int c);
/**
* @brief check if there is data in rx fifo.
* @param obj: uart object define in application software.
* @retval 1: TRUE
* @retval 0: FALSE
*/
int serial_readable(serial_t *obj);
/**
* @brief check if write data to tx fifo is permitted.
* @param obj: uart object define in application software.
* @retval 1: TRUE
* @retval 0: FALSE
*/
int serial_writable(serial_t *obj);
/**
* @brief Clear Rx fifo.
* @param obj: uart object define in application software.
* @retval none
*/
void serial_clear(serial_t *obj);
/**
* @brief enable UART break contol function.
* @param obj: uart object define in application software.
* @retval none
*/
void serial_break_set(serial_t *obj);
/**
* @brief disable UART break contol function.
* @param obj: uart object define in application software.
* @retval none
*/
void serial_break_clear(serial_t *obj);
/**
* @brief set tx pinmux.
* @param tx: Tx PinName according to pinmux spec.
* @retval none
*/
void serial_pinout_tx(PinName tx);
/**
* @brief uart autoflow control setting.
* @param obj: uart object define in application software.
* @param type: autoflow control type.
* @param rxflow: RTS pin.
* @param txflow: CTS pin.
* @retval none
*/
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow);
/**
* @brief controls the RTS signal.
* @param obj: uart object define in application software.
* @param rts_state: RTS signal control value.
* @retval none
*/
void serial_rts_control(serial_t *obj, BOOLEAN rts_state);
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,85 @@
/** mbed Microcontroller Library
******************************************************************************
* @file sleep_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed SLEEP API
******************************************************************************
* @attention
*
* 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"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup sleep SLEEP
* @ingroup hal
* @brief sleep functions
* @{
*/
///@name Ameba Common
///@{
/** 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.
*
* @retval None
* @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.
*
* @retval None
* @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

View file

@ -0,0 +1,165 @@
/** mbed Microcontroller Library
******************************************************************************
* @file spi_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed SPI API
******************************************************************************
* @attention
*
* 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"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup spi SPI
* @ingroup hal
* @brief spi functions
* @{
*/
#if ((defined(CONFIG_PLATFORM_8711B) && (CONFIG_PLATFORM_8711B == 1)) || (defined (CONFIG_PLATFORM_8721D) && (CONFIG_PLATFORM_8721D == 1)))
///@name AmebaZ and AmebaD
///@{
typedef enum {
MBED_SPI0 = 0xF0, /*!< means SPI0 */
MBED_SPI1 = 0xF1, /*!< means SPI1 */
} MBED_SPI_IDX;
///@}
#endif //CONFIG_PLATFORM_8711B || CONFIG_PLATFORM_8721D
///@name Ameba Common
///@{
typedef struct spi_s spi_t;
/**
* @brief Initializes the SPI device, include clock/function/interrupt/SPI registers.
* @param obj: spi object define in application software.
* @param mosi: MOSI PinName according to pinmux spec.
* @param miso: MISO PinName according to pinmux spec.
* @param sclk: SCLK PinName according to pinmux spec.
* @param ssel: CS PinName according to pinmux spec.
* @retval none
* @note must set obj->spi_index to MBED_SPI0 or MBED_SPI1 before using spi_init
*/
void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel);
/**
* @brief Deinitializes the SPI device, include interrupt/DMA/DISABLE SPI.
* @param obj: spi object define in application software.
* @retval none
*/
void spi_free(spi_t *obj);
/**
* @brief Set SPI format,include DFS/Phase/Polarity.
* @param obj: spi object define in application software.
* @param bits: data frame size, 4-16 supported.
* @param mode: this parameter can be one of the following values:
* @arg 0 : [Polarity,Phase]=[0,0]
* @arg 1 : [Polarity,Phase]=[0,1]
* @arg 2 : [Polarity,Phase]=[1,0]
* @arg 3 : [Polarity,Phase]=[1,1]
* @param slave: this parameter can be one of the following values:
* @arg 0 : indicates role-master
* @arg 1 : indicates role-slave
* @retval none
*/
void spi_format(spi_t *obj, int bits, int mode, int slave);
/**
* @brief Set SPI baudrate.
* @param obj: spi master object define in application software.
* @param hz: baudrate for SPI bus
* @retval none
* @note "hz" should be less or equal to half of the SPI IpClk
*/
void spi_frequency(spi_t *obj, int hz);
/**
* @brief Master send one frame use SPI.
* @param obj: spi master object define in application software.
* @param value: the data to transmit.
* @retval : data received from slave
*/
int spi_master_write(spi_t *obj, int value);
/**
* @brief Get slave readable && busy state.
* @param obj: spi slave object define in application software.
* @retval : slave Readable && Busy State
*/
int spi_slave_receive(spi_t *obj);
/**
* @brief Slave receive one frame use SPI.
* @param obj: spi slave object define in application software.
* @retval : data received from master
*/
int spi_slave_read(spi_t *obj);
/**
* @brief Slave send one frame use SPI.
* @param obj: spi slave object define in application software.
* @param value: the data to transmit.
* @retval none
*/
void spi_slave_write(spi_t *obj, int value);
/**
* @brief Get SPI busy state.
* @param obj: spi object define in application software.
* @retval : current busy state
*/
int spi_busy(spi_t *obj);
/**
* @brief SPI device to flush rx fifo.
* @param obj: spi object define in application software.
* @retval none
*/
void spi_flush_rx_fifo(spi_t *obj);
/**
* @brief Open SPI device clock.
* @param obj: spi object define in application software.
* @retval none
*/
void spi_enable(spi_t *obj);
/**
* @brief Close SPI device clock.
* @param obj: spi object define in application software.
* @retval none
*/
void spi_disable(spi_t *obj);
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,245 @@
/** mbed Microcontroller Library
******************************************************************************
* @file timer_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed I2C API
******************************************************************************
* @attention
*
* 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_EXT_TIMER_API_EXT_H
#define MBED_EXT_TIMER_API_EXT_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup timer TIMER
* @ingroup hal
* @brief timer functions
* @{
*/
///@name Ameba Common
///@{
typedef struct gtimer_s gtimer_t;
typedef void (*gtimer_irq_handler)(uint32_t id);
/**
* @brief Initializes the timer, including clock/function/timer registers.
* @param obj: gtimer object defined in application software.
* @param tid: the timer struct ID defined in gtimer structure.
* @retval none
*/
void gtimer_init (gtimer_t *obj, uint32_t tid);
/**
* @brief Deinitializes the timer, including clock/function/timer registers.
* @param obj: gtimer object defined in application software.
* @retval none
*/
void gtimer_deinit (gtimer_t *obj);
/**
* @brief Read current timer tick in Gtimer clock(0~32768).
* @param obj: gtimer object defined in application software.
* @retval 32 bit tick time
*/
uint32_t gtimer_read_tick (gtimer_t *obj);
/**
* @brief Read current timer tick in microsecond.
* @param obj: gtimer object defined in application software.
* @retval 64 bit tick time
*/
uint64_t gtimer_read_us (gtimer_t *obj);
/**
* @brief Reload timer
* @param obj: gtimer object defined in application software.
* @param duration_us: the time in microsecond of gtimer to reload.
* @retval none
*/
void gtimer_reload (gtimer_t *obj, uint32_t duration_us);
/**
* @brief Start the timer
* @param obj: gtimer object defined in application software.
* @retval none
*/
void gtimer_start (gtimer_t *obj);
/**
* @brief Set up a shout timer, including clock/function/timer registers.
* @param obj: gtimer object defined in application software.
* @param duration_us: the period in microsecond of gtimer.
* @param handler: The Pointer to the function that program runs into when timer is up.
* @param hid: the timer struct ID defined in gtimer structure.
* @retval none
*/
void gtimer_start_one_shout (gtimer_t *obj, uint32_t duration_us, void* handler, uint32_t hid);
/**
* @brief Set up a periodic timer, including clock/function/timer registers.
* @param obj: gtimer object defined in application software.
* @param duration_us: the period in microsecond of gtimer.
* @param handler: The Pointer to function that program runs into when timer is up.
* @param hid: the timer struct ID defined in gtimer structure.
* @retval none
*/
void gtimer_start_periodical (gtimer_t *obj, uint32_t duration_us, void* handler, uint32_t hid);
/**
* @brief Stop the timer, including clock/function/timer registers.
* @param obj: gtimer object defined in application software.
* @retval none
*/
void gtimer_stop (gtimer_t *obj);
#if defined(CONFIG_PLATFORM_8195A) && (CONFIG_PLATFORM_8195A == 1)
///@name Ameba Only
///@{
enum {
TIMER0 = 2,
TIMER1 = 3,
TIMER2 = 4,
TIMER3 = 5,
TIMER4 = 0,
GTIMER_MAX = 5
};
///@}
#endif //CONFIG_PLATFORM_8195A
#if (defined(CONFIG_PLATFORM_8711B) && (CONFIG_PLATFORM_8711B == 1)) || (defined(CONFIG_PLATFORM_8721D) && (CONFIG_PLATFORM_8721D == 1))
///@name AmebaZ and AmebaD Only
///@{
enum {
TIMER0 = 0, /*!< GTimer 0, 32k timer, share with us_tick(wait_ms()) functions. This timer is reserved and users are not recommended to use it */
TIMER1 = 1, /*!< GTimer 1, 32k timer, share with APP_TIM_ID */
TIMER2 = 2, /*!< GTimer 2, 32k timer, users can use it */
TIMER3 = 3, /*!< GTimer 3, 32k timer, users can use it */
GTIMER_MAX = 4
};
///@}
#endif //CONFIG_PLATFORM_8711B || CONFIG_PLATFORM_8721D
#if (defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)) || (defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1)) \
|| (defined(CONFIG_PLATFORM_8710C) && (CONFIG_PLATFORM_8710C == 1))
///@name AmebaPro and AmebaZ2 Only
///@{
#if defined (CONFIG_PLATFORM_8195BLP) || defined (CONFIG_PLATFORM_8710C)
enum {
TIMER0 = 1,
TIMER1 = 2,
TIMER2 = 3,
TIMER3 = 4,
TIMER4 = 5,
TIMER5 = 6,
TIMER6 = 7,
GTIMER_MAX = 7
};
#elif defined (CONFIG_PLATFORM_8195BHP)
#if defined (CONFIG_BUILD_NONSECURE)
enum {
TIMER0 = 9,
TIMER1 = 10,
TIMER2 = 11,
TIMER3 = 12,
TIMER4 = 13,
TIMER5 = 14,
TIMER6 = 15,
GTIMER_MAX = 15
};
#elif defined (CONFIG_BUILD_SECURE)
enum {
TIMER0 = 1,
TIMER1 = 2,
TIMER2 = 3,
TIMER3 = 4,
TIMER4 = 5,
TIMER5 = 6,
TIMER6 = 7,
GTIMER_MAX = 7
};
#else
enum {
TIMER0 = 1,
TIMER1 = 2,
TIMER2 = 3,
TIMER3 = 4,
TIMER4 = 5,
TIMER5 = 6,
TIMER6 = 7,
TIMER7 = 8,
TIMER8 = 9,
TIMER9 = 10,
TIMER10 = 11,
TIMER11 = 12,
TIMER12 = 13,
TIMER13 = 14,
TIMER14 = 15,
GTIMER_MAX = 15
};
#endif
#endif
// define the G-Timer Alarm ID, a G-Timer has 4 alarm
typedef enum {
TIMER_ALARM0 = GTimerMatchEvent0,
TIMER_ALARM1 = GTimerMatchEvent1,
TIMER_ALARM2 = GTimerMatchEvent2,
TIMER_ALARM3 = GTimerMatchEvent3,
TIMER_ALARM_NUM = 4
} alarmid_t;
void gtimer_enable_alarm (gtimer_t *obj, alarmid_t almid, uint32_t time_us, void *handler, uint32_t hid);
void gtimer_disable_alarm (gtimer_t *obj, alarmid_t almid);
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP) || defined(CONFIG_PLATFORM_8195BLP) || defined(CONFIG_PLATFORM_8710C)"
#ifdef __cplusplus
}
#endif
#endif/* MBED_TIMER_API_H */

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

View file

@ -0,0 +1,36 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************
*/
#ifndef ANALOGIN_EX_API_H
#define ANALOGIN_EX_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
ANALOGIN_RX_DMA_COMPLETE = 0,
}AnalogInCallback;
void analogin_set_user_callback(analogin_t *obj, AnalogInCallback analogin_cb, void(*analogin_callback)(void *));
void analogin_clear_user_callback(analogin_t *obj, AnalogInCallback analogin_cb);
uint8_t analogin_read_u16_dma (analogin_t * obj, uint16_t *buf, uint16_t length);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,481 @@
/** mbed Microcontroller Library
******************************************************************************
* @file audio_api.h
* @author
* @version V1.0.0
* @brief
******************************************************************************
* @attention
*
* 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_EXT_AUDIO_API_EXT_H
#define MBED_EXT_AUDIO_API_EXT_H
#if defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)
///@name AmebaPro Only
///@{
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup audio AUDIO
* @ingroup hal
* @brief audio functions
* @{
*/
typedef enum {
WL_16BIT = AUDIO_WL_16,
WL_24BIT = AUDIO_WL_24,
WL_8BIT = AUDIO_WL_8
} audio_wl;
typedef enum {
ASR_8KHZ = AUDIO_SR_8KHZ,
ASR_16KHZ = AUDIO_SR_16KHZ,
ASR_32KHZ = AUDIO_SR_32KHZ,
ASR_44p1KHZ = AUDIO_SR_44p1KHZ,
ASR_48KHZ = AUDIO_SR_48KHZ,
ASR_88p2KHZ = AUDIO_SR_88p2KHZ,
ASR_96KHZ = AUDIO_SR_96KHZ
} audio_sr;
typedef enum {
OUTPUT_DISABLE = 0,
OUTPUT_SINGLE_EDNED = 1,
OUTPUT_DIFFERENTIAL = 2,
OUTPUT_CAPLESS = 3
} audio_output_mode;
typedef enum {
INPUT_DISABLE = 0,
LINE_IN_MODE = 1,
MIC_DIFFERENTIAL = 2,
MIC_SINGLE_EDNED = 3
} audio_input_mode;
typedef enum {
BIAS_0p9_AVDD = AUDIO_BIAS_0p9_AVDD,
BIAS_0p86_AVDD = AUDIO_BIAS_0p86_AVDD,
BIAS_0p75_AVDD = AUDIO_BIAS_0p75_AVDD
} audio_bias_voltage;
typedef enum {
MIC_0DB = AUDIO_MIC_0DB,
MIC_20DB = AUDIO_MIC_20DB,
MIC_30DB = AUDIO_MIC_30DB,
MIC_40DB = AUDIO_MIC_40DB
} audio_mic_gain;
typedef enum {
VREF_0p52VDD = AUDIO_VREF_0p52_VDD,
VREF_0p51VDD = AUDIO_VREF_0p51_VDD,
VREF_0p50VDD = AUDIO_VREF_0p50_VDD,
VREF_0p49VDD = AUDIO_VREF_0p49_VDD
} audio_vref_voltage;
typedef enum {
SIDETONE_120HZ = AUDIO_ST_120HZ,
SIDETONE_239HZ = AUDIO_ST_239HZ,
SIDETONE_358HZ = AUDIO_ST_358HZ,
SIDETONE_477HZ = AUDIO_ST_477HZ,
SIDETONE_597HZ = AUDIO_ST_597HZ,
SIDETONE_716HZ = AUDIO_ST_716HZ,
SIDETONE_835HZ = AUDIO_ST_835HZ,
SIDETONE_955HZ = AUDIO_ST_955HZ
} audio_sidetone_hpf;
typedef enum {
DVOL_ADC_0DB = 0x2F,
DVOL_DAC_0DB = 0xAF,
SIDETONE_0DB = 0x1F
} audio_dvol_0db;
typedef enum {
AUDIO_CODEC_1p8V = AUDIO_POWER_1p8V,
AUDIO_CODEC_2p8V = AUDIO_POWER_2p8V
} audio_power_sel;
typedef void (*audio_irq_handler)(u32 arg, u8 *pbuf);
typedef struct audio_s audio_t;
/**
* @brief Initializes the AUDIO device, include clock/function/interrupt/AUDIO registers.
* @param obj: Audio object define in application software.
* @param output_mode: Select the output mode.
* @arg OUTPUT_DISABLE: Disable audio output.
* @arg OUTPUT_SINGLE_EDNED: Single-Ended mode.
* @arg OUTPUT_DIFFERENTIAL: Differential mode.
* @arg OUTPUT_CAPLESS: Capless mode.
* @param input_mode: Select the input mode.
* @arg INPUT_DISABLE: Disable audio input.
* @arg LINE_IN_MODE: Line in mode.
* @arg MIC_DIFFERENTIAL: MIC differential mode.
* @arg MIC_SINGLE_EDNED: MIC Single-Ended mode.
* @param power_sel: Select audio codec LDO power.
* @arg AUDIO_CODEC_1p8V: Audio codec power 1.8V.
* @arg AUDIO_CODEC_2p8V: Audio codec power 2.8V.
* @retval none
*/
void audio_init(audio_t *obj, audio_output_mode output_mode, audio_input_mode input_mode, audio_power_sel power_sel);
/**
* @brief Deinitializes the AUDIO device, include function/interrupt/AUDIO registers.
* @param obj: Audio object define in application software.
* @retval none
*/
void audio_deinit(audio_t *obj);
/**
* @brief Set the audio sample rate and word length.
* @param obj: Audio object define in application software.
* @param sample_rate: this parameter can be one of the following values:
* @arg ASR_8KHZ: sample rate is 8kHz
* @arg ASR_16KHZ: sample rate is 16kHz
* @arg ASR_32KHZ: sample rate is 32kHz
* @arg ASR_44p1KHZ: sample rate is 44.1kHz
* @arg ASR_48KHZ: sample rate is 48kHz
* @arg ASR_88p2KHZ: sample rate is 88.2kHz
* @arg ASR_96KHZ: sample rate is 96kHz
* @param word_length: this parameter can be one of the following values:
* @arg WL_8BIT: sample bit is 8 bit
* @arg WL_16BIT: sample bit is 16 bit
* @arg WL_24BIT: sample bit is 24 bit (World length is 24bits but ADC and DAC are 16bits)
* @retval none
*/
void audio_set_param(audio_t *obj, audio_sr sample_rate, audio_wl word_length);
/**
* @brief Set the tx buffer address.
* @param obj: Audio object define in application software.
* @param tx_buf: Set the address of tx buffer. Need 4-byte aligned.
* @param tx_page_size: This unit is byte. This number needs to be a multiple of 64, and the maximum value is 4032.
* @retval none
*/
void audio_set_tx_dma_buffer(audio_t *obj, u8 *tx_buf, u32 tx_page_size);
/**
* @brief Set the rx buffer address.
* @param obj: Audio object define in application software.
* @param rx_buf: Set the address of tx buffer. Need 4-byte aligned.
* @param rx_page_size: This unit is byte. This number needs to be a multiple of 64, and the maximum value is 4032.
* @retval none
*/
void audio_set_rx_dma_buffer(audio_t *obj, u8 *rx_buf, u32 rx_page_size);
/**
* @brief Set tx interrupt handler.
* @param obj: Audio object define in application software.
* @param tx_handler: User defined IRQ callback function.
* @param arg: User defined IRQ callback parameter.
* @retval none
*/
void audio_tx_irq_handler(audio_t *obj, audio_irq_handler tx_handler, u32 arg);
/**
* @brief Set rx interrupt handler.
* @param obj: Audio object define in application software.
* @param rx_handler: User defined IRQ callback function.
* @param arg: User defined IRQ callback parameter.
* @retval none
*/
void audio_rx_irq_handler(audio_t *obj, audio_irq_handler rx_handler, u32 arg);
/**
* @brief Get the current tx page address.
* @param obj: Audio object define in application software.
* @retval Tx page address
*/
u8 *audio_get_tx_page_adr(audio_t *obj);
/**
* @brief Inform Audio the tx page data of the channel is ready.
* @param obj: Audio object define in application software.
* @param pbuf: tx buffer adderss.
* @retval none
*/
void audio_set_tx_page(audio_t *obj, u8 *pbuf);
/**
* @brief Inform Audio that finish receiving the rx page data of the channel.
* @param obj: Audio object define in application software.
* @retval none
*/
void audio_set_rx_page(audio_t *obj);
/**
* @brief Start the tx transmission.
* @param obj: Audio object define in application software.
* @retval none
*/
void audio_tx_start (audio_t *obj);
/**
* @brief Start the rx transmission.
* @param obj: Audio object define in application software.
* @retval none
*/
void audio_rx_start (audio_t *obj);
/**
* @brief Start the tx and rx transmission.
* @param obj: Audio object define in application software.
* @retval none
*/
void audio_trx_start (audio_t *obj);
/**
* @brief Stop the tx transmission.
* @param obj: Audio object define in application software.
* @retval none
*/
void audio_tx_stop (audio_t *obj);
/**
* @brief Stop the rx transmission.
* @param obj: Audio object define in application software.
* @retval none
*/
void audio_rx_stop (audio_t *obj);
/**
* @brief Stop the tx and rx transmission.
* @param obj: Audio object define in application software.
* @retval none
*/
void audio_trx_stop (audio_t *obj);
/**
* @brief Get the error count of tx transmission when happen the interrupt.
* @param obj: Audio object define in application software.
* @retval Tx error count
*/
u8 audio_get_tx_error_cnt (audio_t *obj);
/**
* @brief Get the error count of rx transmission when happen the interrupt.
* @param obj: Audio object define in application software.
* @retval Rx error count
*/
u8 audio_get_rx_error_cnt (audio_t *obj);
/**
* @brief clean the error count.
* @param obj: Audio object define in application software.
* @retval none
*/
void audio_clean_error_cnt (audio_t *obj);
/**
* @brief Make the data from tx to rx and bypass the audio codec.
* @param obj: Audio object define in application software.
* @retval none
*/
void audio_sport_loopback (audio_t *obj, BOOL en);
/**
* @brief Control the mute of the microphone.
* @param obj: Audio object define in application software.
* @param en: To enable or disable mute.
* @retval none
*/
void audio_mic_analog_mute (audio_t *obj, BOOL en);
/**
* @brief Control the boost gain of the microphone.
* @param obj: Audio object define in application software.
* @param en: To enable or disable.
* @param mic_gain: Select the microphone gain.
* @arg MIC_0DB: 0dB.
* @arg MIC_20DB: 20dB.
* @arg MIC_30DB: 30dB.
* @arg MIC_40DB: 40dB.
* @retval none
*/
void audio_mic_analog_gain (audio_t *obj, BOOL en, audio_mic_gain mic_gain);
/**
* @brief Control the mute of the line-in.
* @param obj: Audio object define in application software.
* @param en: To enable or disable mute.
* @retval none
*/
void audio_line_in_analog_mute (audio_t *obj, BOOL en);
/**
* @brief Control the digital gain of ADC.
* @param obj: Audio object define in application software.
* @param step: The digital volume. Every Step is 0.375dB.
* @arg 0x7F: 30dB.
* @arg ...
* @arg 0x2F: 0dB.
* @arg ...
* @arg 0x00: -17.625dB.
* @retval none
*/
void audio_adc_digital_vol (audio_t *obj, u8 step);
/**
* @brief Control the digital mute of ADC.
* @param obj: Audio object define in application software.
* @param mute_en: To enable or disable mute.
* @retval none
*/
void audio_adc_digital_mute (audio_t *obj, BOOL mute_en);
/**
* @brief Control the mute of the headphone.
* @param obj: Audio object define in application software.
* @param en: To enable or disable mute.
* @retval none
*/
void audio_headphone_analog_mute (audio_t *obj, BOOL en);
/**
* @brief Control the digital gain of DAC.
* @param obj: Audio object define in application software.
* @param step: The digital volume. Every Step is 0.375dB.
* @arg 0xAF: 0dB.
* @arg 0xAE: -0.375dB.
* @arg ...
* @arg 0x00: -65.625dB.
* @retval none
*/
void audio_dac_digital_vol (audio_t *obj, u8 step);
/**
* @brief Control the digital mute of DAC.
* @param obj: Audio object define in application software.
* @param mute_en: To enable or disable mute.
* @retval none
*/
void audio_dac_digital_mute (audio_t *obj, BOOL mute_en);
/**
* @brief Control the VREF voltage.
* @param obj: Audio object define in application software.
* @param voltage: Select the VREF voltage.
* @arg VREF_0p52VDD: 0.52*VDD.
* @arg VREF_0p51VDD: 0.51*VDD.
* @arg VREF_0p50VDD: 0.50*VDD.
* @arg VREF_0p49VDD: 0.49*VDD.
* @retval none
*/
void audio_vref_voltage_ctrl (audio_t *obj, audio_vref_voltage voltage);
/**
* @brief Initializes the sidetone function. Allows to hear mic voice in the headset.
* @param obj: Audio object define in application software.
* @retval none
*/
void audio_sidetone_init (audio_t *obj);
/**
* @brief Deinitializes the sidetone function.
* @param obj: Audio object define in application software.
* @retval none
*/
void audio_sidetone_deinit (audio_t *obj);
/**
* @brief Control the digital gain and boost of sidetone.
* @param obj: Audio object define in application software.
* @param sidetone_boost: Audio object define in application software.
* @arg 0x00: 0dB.
* @arg 0x01: 12dB.
* @param step: The digital volume. Every Step is 1.5dB.
* @arg 0x1F: 0dB.
* @arg 0x1E: -1.5dB.
* @arg ...
* @arg 0x00: -46.5dB.
* @retval none
*/
void audio_sidetone_vol (audio_t *obj, audio_sidetone_boost_t sidetone_boost, u8 step);
/**
* @brief Control the high pass filter of sidetone.
* @param obj: Audio object define in application software.
* @param en: 0 is disable, 1 is enable.
* @param sidetone_hpf: Select the cut-off frequency.
* @arg SIDETONE_120HZ: 120Hz.
* @arg SIDETONE_239HZ: 239Hz.
* @arg SIDETONE_358HZ: 358Hz.
* @arg SIDETONE_477HZ: 477Hz.
* @arg SIDETONE_597HZ: 597Hz.
* @arg SIDETONE_716HZ: 716Hz.
* @arg SIDETONE_835HZ: 835Hz.
* @arg SIDETONE_955HZ: 955Hz.
* @retval none
*/
void audio_sidetone_hpf_ctrl (audio_t *obj, BOOL en, audio_sidetone_hpf sidetone_hpf);
/**
* @brief The wind filter is implemented by a high pass filter.Remove wind noise at application mode.
* The cut-off frequency of wind filter is programmable and is varied according to different sample rate.
* @param obj: Audio object define in application software.
* @param en Enable control: 0 is disable, 1 is enable.
* @param sample_rate: this parameter can be one of the following values:
* @arg ASR_8KHZ: sample rate is 8kHz
* @arg ASR_16KHZ: sample rate is 16kHz
* @arg ASR_32KHZ: sample rate is 32kHz
* @arg ASR_44p1KHZ: sample rate is 44.1kHz
* @arg ASR_48KHZ: sample rate is 48kHz
* @arg ASR_88p2KHZ: sample rate is 88.2kHz
* @arg ASR_96KHZ: sample rate is 96kHz
* @param coef_num Set the wind filter coefficient " n ".
* For the formula of Fc calculation is also shown as: Fc = (Fs * tan-1(a/(2-a))) / pi.
* Sample rate Fs = 8K/12K/16K, a = 2 ^(-6) (1 + n).
* Sample rate Fs = 24K/32K, a = 2 ^(-7) (1 + n).
* Sample rate Fs = 44.1K/48K, a = 2 ^(-8) (1 + n).
* Sample rate Fs = 88.2K/96K, a = 2 ^(-9) (1 + n).
* n (coef_num) is the coefficient.
* @retval none
*/
void audio_wind_filter (audio_t *obj, BOOL en, audio_sr sample_rate, u8 coef_num);
/**
* @brief Control the mic bias.
* @param obj: Audio object define in application software.
* @param en: 0 is disable, 1 is enable.
* @param voltage: Select the bias voltage.
* @arg 00: 0.9AVDD. (default)
* @arg 01: 0.86AVDD.
* @arg 10: 0.75AVDD.
* @arg 11: reserved.
* @retval none
*/
void audio_mic_bias_ctrl (audio_t *obj, BOOL en, audio_bias_voltage voltage);
/**
* @brief Control the amplifier of the headphone. The default value is enabled.
* @param obj: Audio object define in application software.
* @param en: 0 is disable, 1 is enable.
* @retval none
*/
void audio_hpo_amplifier (audio_t *obj, BOOL en);
/*\@}*/
#ifdef __cplusplus
}
#endif
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP)"
#endif

View file

@ -0,0 +1,114 @@
/** mbed Microcontroller Library
******************************************************************************
* @file captouch_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed CAPTOUCH API
******************************************************************************
* @attention
*
* 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_CAPTOUCH_API_H
#define MBED_CAPTOUCH_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup captouch CAPTOUCH
* @ingroup hal
* @brief captouch functions
* @{
*/
#if ((defined (CONFIG_PLATFORM_8721D) && (CONFIG_PLATFORM_8721D == 1)))
///@name AmebaD Only
///@{
typedef struct captouch_s captouch_t;
/**
* @brief initializes the captouch device.
* @param obj: captouch object define in application software.
* @retval none
*/
void captouch_init (captouch_t *obj);
/**
* @brief deinitializes the captouch device.
* @param obj: captouch object define in application software.
* @retval none
*/
void captouch_deinit (captouch_t *obj);
/**
* @brief enable specified channel.
* @param obj: captouch object define in application software.
* @param Channel: specified channel index, which can be 0~3
* @retval none
*/
void captouch_ch_enable(captouch_t *obj, u8 Channel);
/**
* @brief disable specified channel.
* @param obj: captouch object define in application software.
* @param Channel: specified channel index, which can be 0~3
* @retval none
*/
void captouch_ch_disable(captouch_t *obj, u8 Channel);
/**
* @brief set captouch scan interval.
* @param obj: captouch object define in application software.
* @param Interval: scan interval in units of ms
* @retval none
*/
void captouch_set_scan_interval(captouch_t *obj, u32 Interval);
/**
* @brief read baseline data from specified channel.
* @param obj: captouch object define in application software.
* @param Channel: specified channel index, which can be 0~3
* @retval baseline data
*/
u32 captouch_get_ch_baseline(captouch_t *obj, u8 Channel);
/**
* @brief read average data from specified channel.
* @param obj: captouch object define in application software.
* @param Channel: specified channel index, which can be 0~3
* @retval average data
*/
u32 captouch_get_ch_data(captouch_t *obj, u8 Channel);
///@}
/*\@}*/
///@}
#endif //CONFIG_PLATFORM_8721D
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,42 @@
/*******************************************************************************
* Copyright (c) 2014, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************/
#ifndef MBED_EXT_CHG_API_EXT_H
#define MBED_EXT_CHG_API_EXT_H
#if (defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)) || (defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1))
///@name AmebaPro Only
///@{
#include "device.h"
#if defined (CONFIG_PLATFORM_8195BLP)
/** @addtogroup chg CHG
* @ingroup hal
* @brief chg functions
* @{
*/
///@name Ameba Common
///@{
typedef struct chg_s chg_t;
/**
* @brief Initializes the CHG registers with default parameters and run CHG state machine.
* @param obj: CHG object define in application software.
* @param cc: The Constant Current value, Uint:mA.
* @param cv: The Constant Voltage value, Uint:mV.
* @retval none
*/
void charger_sm(chg_t *obj, u16 cc, u16 cv);
///@}
/*\@}*/
#endif
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP) || defined(CONFIG_PLATFORM_8195BLP)"
#endif

View file

@ -0,0 +1,861 @@
/** mbed Microcontroller Library
******************************************************************************
* @file cir_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed I2S API
******************************************************************************
* @attention
*
* 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_EXT_CIR_API_EXT_H
#define MBED_EXT_CIR_API_EXT_H
#if (defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)) || (defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1))
///@name AmebaPro Only
///@{
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
NEC = 0x00,
SONY = 0x01,
PHILIPS = 0x02,
JVC = 0x03
} cir_protocol;
typedef enum {
INIT_OUTPUT_LOW = Init_Low,
INIT_OUTPUT_HIGH = Init_High
} cir_init_value;
typedef enum {
CIR_NO_CARRIER = No_Carrier,
CIR_CARRIER = Carrier
} cir_carrier;
typedef enum {
SCLK_DIV_AUTO = Auto
} cir_sclkdiv;
typedef enum {
STAT_SUCCESS = cir_success,
STAT_REPEAT = cir_repeat,
STAT_FAIL = cir_fail,
STAT_REPEAT_HEADER = cir_repeat_header
} cir_rx_status;
typedef enum {
NEC_NORMAL_TX = NEC_Tx_Normal,
NEC_REPEAT_TX = NEC_Tx_Repeat,
NEC_EXTEND_TX = NEC_Tx_Extend
} cir_nec_tx_format;
typedef enum {
NEC_NORMAL_RX = NEC_Rx_Normal,
NEC_EXTEND_RX = NEC_Rx_Extend
} cir_nec_rx_format;
typedef enum {
SONY_SIRC_12BITS = SonySIRC_12bits,
SONY_SIRC_15BITS = SonySIRC_15bits,
SONY_SIRC_20BITS = SonySIRC_20bits
} cir_sony_sirc_format;
typedef enum {
PHILIPS_RC5 = Philips_rc5_Normal,
} cir_philips_rc5_format;
typedef enum {
JVC_NORMAL_TX = Jvc_Tx_Normal,
JVC_REPEAT_HEADER_TX = Jvc_Tx_Repeat_Header,
JVC_REPEAT_NO_HEADER_TX = Jvc_Tx_Repeat_No_Header
} cir_jvc_tx_format;
typedef enum {
JVC_NORMAL_RX = Jvc_Rx_Normal,
} cir_jvc_rx_format;
typedef union {
__IOM uint32_t w;
struct {
__IOM uint32_t address : 8;
__IOM uint32_t command : 8;
} b;
} recv_nec_normal_format_t, *precv_nec_normal_format_t;
typedef union {
__IOM uint32_t w;
struct {
__IOM uint32_t address_l : 8;
__IOM uint32_t address_h : 8;
__IOM uint32_t command : 8;
} b;
} recv_nec_extend_format_t, *precv_nec_extend_format_t;
typedef union {
__IOM uint32_t w;
struct {
__IOM uint32_t command : 7;
__IOM uint32_t address : 5;
} b;
} recv_sony_src_12bits_t, *precv_sony_src_12bits_t;
typedef union {
__IOM uint32_t w;
struct {
__IOM uint32_t command : 7;
__IOM uint32_t address : 8;
} b;
} recv_sony_src_15bits_t, *precv_sony_src_15bits_t;
typedef union {
__IOM uint32_t w;
struct {
__IOM uint32_t command : 7;
__IOM uint32_t address : 5;
__IOM uint32_t extend : 8;
} b;
} recv_sony_src_20bits_t, *precv_sony_src_20bits_t;
typedef union {
__IOM uint32_t w;
struct {
__IOM uint32_t field : 1;
__IOM uint32_t toggle : 1;
__IOM uint32_t address : 5;
__IOM uint32_t command : 6;
} b;
} recv_philips_rc5_format_t, *precv_philips_rc5_format_t;
typedef union {
__IOM uint32_t w;
struct {
__IOM uint32_t address : 8;
__IOM uint32_t command : 8;
} b;
} recv_jvc_format_t, *precv_jvc_format_t;
/**
\brief Define the CIR symbol.
*/
enum cir_symbol_e {
SYMBOL_NONE_RX = 0x00,
SYMBOL_NONE_TX = 0x00,
SYMBOL01 = 0x01,
SYMBOL02 = 0x02,
SYMBOL03 = 0x03,
SYMBOL04 = 0x04,
SYMBOL05 = 0x05,
SYMBOL06 = 0x06,
SYMBOL07 = 0x07,
SYMBOL_END_TX = 0x08,
SYMBOL_NO_HEADER_TX = 0x08
};
typedef uint8_t cir_symbol_t;
/**
\brief The tx parameter table to describe the tx protocol .
*/
typedef struct cir_tx_protocol_s {
u32 carrier_frequency; /*!< Set the tx carrier frequency */
u16 symbol01_us; /*!< Set the symbol01 duration */
u16 symbol02_us; /*!< Set the symbol02 duration */
u16 symbol03_us; /*!< Set the symbol03 duration */
u16 symbol04_us; /*!< Set the symbol04 duration */
u16 symbol05_us; /*!< Set the symbol05 duration */
u16 symbol06_us; /*!< Set the symbol06 duration */
u16 symbol07_us; /*!< Set the symbol07 duration */
cir_symbol_t tx_start_first_symbol : 4; /*!< Set the first tx symbol of encoding the start symbol */
cir_symbol_t tx_start_second_symbol : 4; /*!< Set the second tx symbol of encoding the start symbol */
cir_symbol_t tx_bit0_first_symbol : 4; /*!< Set the first tx symbol of encoding bit0 */
cir_symbol_t tx_bit0_second_symbol : 4; /*!< Set the second tx symbol of encoding bit0 */
cir_symbol_t tx_bit1_first_symbol : 4; /*!< Set the first tx symbol of encoding bit1 */
cir_symbol_t tx_bit1_second_symbol : 4; /*!< Set the second tx symbol of encoding bit1 */
cir_symbol_t tx_end_first_symbol : 4; /*!< Set the first tx symbol of encoding the end symbol */
cir_symbol_t tx_end_second_symbol : 4; /*!< Set the second tx symbol of encoding the end symbol */
u8 symbol01_type : 1; /*!< Set symbol01 carrier, 0: No carrier. 1: Carrier. */
u8 symbol02_type : 1; /*!< Set symbol02 carrier, 0: No carrier. 1: Carrier. */
u8 symbol03_type : 1; /*!< Set symbol03 carrier, 0: No carrier. 1: Carrier. */
u8 symbol04_type : 1; /*!< Set symbol04 carrier, 0: No carrier. 1: Carrier. */
u8 symbol05_type : 1; /*!< Set symbol05 carrier, 0: No carrier. 1: Carrier. */
u8 symbol06_type : 1; /*!< Set symbol06 carrier, 0: No carrier. 1: Carrier. */
u8 symbol07_type : 1; /*!< Set symbol07 carrier, 0: No carrier. 1: Carrier. */
} cir_tx_protocol_t, *pcir_tx_protocol_t;
/**
\brief The rx parameter table to describe the rx protocol .
*/
typedef struct cir_rx_protocol_s {
u32 carrier_frequency; /*!< Set the rx carrier frequency */
u16 symbol01_us; /*!< Set the symbol01 duration */
u16 symbol02_us; /*!< Set the symbol02 duration */
u16 symbol03_us; /*!< Set the symbol03 duration */
u16 symbol04_us; /*!< Set the symbol04 duration */
u16 symbol05_us; /*!< Set the symbol05 duration */
u16 symbol06_us; /*!< Set the symbol06 duration */
u16 symbol07_us; /*!< Set the symbol07 duration */
u16 symbol08_us; /*!< Set the symbol08 duration */
cir_symbol_t rx_start_first_symbol_gp0 : 4; /*!< Start to decode the first symbol of the group 0 */
cir_symbol_t rx_start_second_symbol_gp0 : 4; /*!< Start to decode the second symbol of the group 0 */
cir_symbol_t rx_start_first_symbol_gp1 : 4; /*!< Start to decode the first symbol of the group 1 */
cir_symbol_t rx_start_second_symbol_gp1 : 4; /*!< Start to decode the second symbol of the group 1 */
cir_symbol_t rx_start_first_symbol_gp2 : 4; /*!< Start to decode the first symbol of the group 2 */
cir_symbol_t rx_start_second_symbol_gp2 : 4; /*!< Start to decode the second symbol of the group 2 */
cir_symbol_t rx_start_first_symbol_gp3 : 4; /*!< Start to decode the first symbol of the group 3 */
cir_symbol_t rx_start_second_symbol_gp3 : 4; /*!< Start to decode the second symbol of the group 3 */
cir_symbol_t rx_bit0_first_symbol_gp0 : 4; /*!< Set the first symbol of the group 0 to decode bit 0 */
cir_symbol_t rx_bit0_second_symbol_gp0 : 4; /*!< Set the second symbol of the group 0 to decode bit 0 */
cir_symbol_t rx_bit0_first_symbol_gp1 : 4; /*!< Set the first symbol of the group 1 to decode bit 0 */
cir_symbol_t rx_bit0_second_symbol_gp1 : 4; /*!< Set the second symbol of the group 1 to decode bit 0 */
cir_symbol_t rx_bit1_first_symbol_gp0 : 4; /*!< Set the first symbol of the group 0 to decode bit 1 */
cir_symbol_t rx_bit1_second_symbol_gp0 : 4; /*!< Set the second symbol of the group 0 to decode bit 1 */
cir_symbol_t rx_bit1_first_symbol_gp1 : 4; /*!< Set the first symbol of the group 1 to decode bit 1 */
cir_symbol_t rx_bit1_second_symbol_gp1 : 4; /*!< Set the second symbol of the group 1 to decode bit 1 */
cir_symbol_t rx_separate_symbol_in_gp0 : 4; /*!< Separate the rx symbol of the group 0 */
cir_symbol_t rx_separate_first_symbol_gp0 : 4; /*!< Set the first generated symbol of the group 0 */
cir_symbol_t rx_separate_second_symbol_gp0 : 4; /*!< Set the second generated symbol of the group 0 */
cir_symbol_t rx_separate_symbol_in_gp1 : 4; /*!< Separate the rx symbol of the group 1 */
cir_symbol_t rx_separate_first_symbol_gp1 : 4; /*!< Set the first generated symbol of the group 1 */
cir_symbol_t rx_separate_second_symbol_gp1 : 4; /*!< Set the second generated symbol of the group 1 */
u8 symbol01_type : 1; /*!< Set symbol01 carrier, 0: No carrier. 1: Carrier. */
u8 symbol02_type : 1; /*!< Set symbol02 carrier, 0: No carrier. 1: Carrier. */
u8 symbol03_type : 1; /*!< Set symbol03 carrier, 0: No carrier. 1: Carrier. */
u8 symbol04_type : 1; /*!< Set symbol04 carrier, 0: No carrier. 1: Carrier. */
u8 symbol05_type : 1; /*!< Set symbol05 carrier, 0: No carrier. 1: Carrier. */
u8 symbol06_type : 1; /*!< Set symbol06 carrier, 0: No carrier. 1: Carrier. */
u8 symbol07_type : 1; /*!< Set symbol07 carrier, 0: No carrier. 1: Carrier. */
u8 symbol08_type : 1; /*!< Set symbol08 carrier, 0: No carrier. 1: Carrier. */
} cir_rx_protocol_t, *pcir_rx_protocol_t;
typedef void (*cir_irq_handler)(void *);
typedef struct cir_s cir_t;
/**
* @brief Initializes the CIR device, include clock/function/interrupt/CIR registers.
* @param obj: CIR object define in application software.
* @param tx: Tx PinName according to pinmux spec. This pin is not configured when set PinName "NC".
* @param rx: Rx PinName according to pinmux spec. This pin is not configured when set PinName "NC".
* @retval none
*/
void cir_init (cir_t *obj, PinName tx, PinName rx);
/**
* @brief Deinitializes the CIR device, include function/interrupt/CIR registers.
* @param obj: CIR object define in application software.
* @retval none
*/
void cir_deinit (cir_t *obj);
/**
* @brief Set the protocol and tx parameters.
* @param obj: CIR object define in application software.
* @arg 0 : NEC protocol.
* @arg 1 : SONY protocol.
* @arg 2 : PHILIPS protocol.
* @arg 3 : JVC protocol.
* @param output_init: Set the initial output.
* @arg 0 : The output is low.
* @arg 1 : The output is high.
* @param carrier: Set the waveform with carrier or no carrier.
* @arg 0 : The carrier symbol has no carrier.
* @arg 1 : The carrier symbol has carrier.
* @param tx_sclkdiv: The divisor of the system clock to generate a proper tick time for the CIR carrier generation.
* @arg 0 : Generate the appropriate value automatically. (Suggestion)
* @arg 1 ~ 255 : SCLK / tx_sclkdiv.
* @param irq_tx_end_cb: User defined IRQ callback function. When finish the output, generate the interrupt.
* @param irq_tx_end_arg: User defined IRQ callback parameter.
* @param protocol: Set the protocol.
* @retval none
*/
void cir_set_tx_protocol (cir_t *obj, cir_protocol protocol, cir_init_value output_init, cir_carrier carrier, cir_sclkdiv tx_sclkdiv,
cir_irq_handler irq_tx_end_cb, void *irq_tx_end_arg);
/**
* @brief Set the protocol and tx parameters.
* @param obj: CIR object define in application software.
* @param protocol: Set the protocol.
* @arg 0 : NEC protocol.
* @arg 1 : SONY protocol.
* @arg 2 : PHILIPS protocol.
* @arg 3 : JVC protocol.
* @param output_init: Set the initial output.
* @arg 0 : The output is low.
* @arg 1 : The output is high.
* @param carrier: Set the waveform with carrier or no carrier.
* @arg 0 : The carrier symbol has no carrier.
* @arg 1 : The carrier symbol has carrier.
* @param rx_sclkdiv: The divisor of the system clock to generate a proper clock for the input sampling and trigger tick event.
* @arg 0 : Set the appropriate value automatically. (Suggestion)
* @arg 1 ~ 255 : SCLK / rx_sclkdiv.
* @param symbol_time_tolerance_us: Set the time tolerance for demodulating RX symbols. This unit is us.
* @param carrier_tolerance_cnt: Set the tolerance of carrier numbers for demodulating RX symbols.
* @arg 0 : This setting is "0" when this waveform is no carrier.
* @param check_frame_end_time_us: Set the end time after receiving the last symbol. This unit is us.
* @param irq_tx_end_cb: User defined IRQ callback function. When finish to receive data, generate the interrupt.
* @param irq_tx_end_arg: User defined IRQ callback parameter.
* @retval none
*/
void cir_set_rx_protocol (cir_t *obj, cir_protocol protocol, cir_init_value input_init, cir_carrier carrier, cir_sclkdiv rx_sclkdiv,
u16 symbol_time_tolerance_us, u16 carrier_tolerance_cnt, u16 check_frame_end_time_us,
cir_irq_handler irq_rx_end_cb, void *irq_rx_end_arg);
/**
* @brief Set the rx data pointer by using the normal NEC protocol.
* @param obj: CIR object define in application software.
* @param data: Rx data pointer.
* @retval none
*/
void cir_nec_recv_normal_format (cir_t *obj, u32 *data);
/**
* @brief Set the rx data pointer by using the extend NEC protocol.
* @param obj: CIR object define in application software.
* @param data: Rx data pointer.
* @retval none
*/
void cir_nec_recv_extend_format (cir_t *obj, u32 *data);
/**
* @brief Send the tx data by using the normal NEC protocol.
* @param obj: CIR object define in application software.
* @param address: The protocol address.
* @param command: The protocol command.
* @retval none
*/
void cir_nec_send_normal_format (cir_t *obj, u8 address, u8 command);
/**
* @brief Send the tx data by using the extend NEC protocol.
* @param obj: CIR object define in application software.
* @param address_l: The protocol high address.
* @param address_h: The protocol low address.
* @param command: The protocol command.
* @retval none
*/
void cir_nec_send_extend_format (cir_t *obj, u8 address_l, u8 address_h, u8 command);
/**
* @brief Send the repeat format by using the NEC protocol.
* @param obj: CIR object define in application software.
* @retval none
*/
void cir_nec_send_repeat_format (cir_t *obj);
/**
* @brief Monitor the specific rx data by using the normal NEC protocol, and generate the interrupt.
* @param obj: CIR object define in application software.
* @param address: Monitor this address.
* @param command: Monitor this command.
* @param irq_monitor_cb: User defined IRQ callback function.
* @param irq_monitor_arg: User defined IRQ callback parameter.
* @retval none
*/
void cir_monitor_nec_normal_format (cir_t *obj, u8 address, u8 command, cir_irq_handler irq_monitor_cb, void *irq_monitor_arg);
/**
* @brief Monitor the specific rx data by using the extend NEC protocol, and generate the interrupt.
* @param obj: CIR object define in application software.
* @param address_l: Monitor this low address.
* @param address_h: Monitor this high address.
* @param command: Monitor this command.
* @param irq_monitor_cb: User defined IRQ callback function.
* @param irq_monitor_arg: User defined IRQ callback parameter.
* @retval none
*/
void cir_monitor_nec_extend_format (cir_t *obj, u8 address_l, u8 address_h, u8 command, cir_irq_handler irq_monitor_cb, void *irq_monitor_arg);
/**
* @brief Get the address of the normal NEC protocol.
* @param obj: CIR object define in application software.
* @retval The 8-bit address.
*/
u8 cir_nec_get_normal_address (cir_t *obj);
/**
* @brief Get the command of the normal NEC protocol.
* @param obj: CIR object define in application software.
* @retval The 8-bit command.
*/
u8 cir_nec_get_normal_command (cir_t *obj);
/**
* @brief Get the address of the extend NEC protocol.
* @param obj: CIR object define in application software.
* @retval The 8-bit low address.
*/
u8 cir_nec_get_extend_address_low (cir_t *obj);
/**
* @brief Get the address of the extend NEC protocol.
* @param obj: CIR object define in application software.
* @retval The 8-bit high address.
*/
u8 cir_nec_get_extend_address_high (cir_t *obj);
/**
* @brief Get the command of the extend NEC protocol.
* @param obj: CIR object define in application software.
* @retval The 8-bit command.
*/
u8 cir_nec_get_extend_command (cir_t *obj);
/**
* @brief Set the rx data pointer by using the 12-bit SONY protocol.
* @param obj: CIR object define in application software.
* @param data: Rx data pointer.
* @retval none
*/
void cir_sony_recv_12bit_format (cir_t *obj, u32 *data);
/**
* @brief Set the rx data pointer by using the 15-bit SONY protocol.
* @param obj: CIR object define in application software.
* @param data: Rx data pointer.
* @retval none
*/
void cir_sony_recv_15bit_format (cir_t *obj, u32 *data);
/**
* @brief Set the rx data pointer by using the 20-bit SONY protocol.
* @param obj: CIR object define in application software.
* @param data: Rx data pointer.
* @retval none
*/
void cir_sony_recv_20bit_format (cir_t *obj, u32 *data);
/**
* @brief Send the tx data by using the 12-bit SONY protocol.
* @param obj: CIR object define in application software.
* @param address_5bits: The 5-bit address.
* @param command_7bits: The 7-bit command.
* @retval none
*/
void cir_sony_send_12bit_format (cir_t *obj, u8 address_5bits, u8 command_7bits);
/**
* @brief Send the tx data by using the 15-bit SONY protocol.
* @param obj: CIR object define in application software.
* @param address_8bits: The 8-bit address.
* @param command_7bits: The 7-bit command.
* @retval none
*/
void cir_sony_send_15bit_format (cir_t *obj, u8 address_8bits, u8 command_7bits);
/**
* @brief Send the tx data by using the 20-bit SONY protocol.
* @param obj: CIR object define in application software.
* @param address_5bits: The 5-bit address.
* @param command_7bits: The 7-bit command.
* @param extend_8bits: The 8-bit extend.
* @retval none
*/
void cir_sony_send_20bit_format (cir_t *obj, u8 address_5bits, u8 command_7bits, u8 extend_8bits);
/**
* @brief Monitor the specific rx data by using the 12-bit SONY protocol, and generate the interrupt.
* @param obj: CIR object define in application software.
* @param address_5bits: Monitor this 5-bit address.
* @param command_7bits: Monitor this 7-bit command.
* @param irq_monitor_cb: User defined IRQ callback function.
* @param irq_monitor_arg: User defined IRQ callback parameter.
* @retval none
*/
void cir_monitor_sony_12bit_format (cir_t *obj, u8 address_5bits, u8 command_7bits, cir_irq_handler irq_monitor_cb, void *irq_monitor_arg);
/**
* @brief Monitor the specific rx data by using the 15-bit SONY protocol, and generate the interrupt.
* @param obj: CIR object define in application software.
* @param address_8bits: Monitor this 8-bit address.
* @param command_7bits: Monitor this 7-bit command.
* @param irq_monitor_cb: User defined IRQ callback function.
* @param irq_monitor_arg: User defined IRQ callback parameter.
* @retval none
*/
void cir_monitor_sony_15bit_format (cir_t *obj, u8 address_8bits, u8 command_7bits, cir_irq_handler irq_monitor_cb, void *irq_monitor_arg);
/**
* @brief Monitor the specific rx data by using the 20-bit SONY protocol, and generate the interrupt.
* @param obj: CIR object define in application software.
* @param address_5bits: Monitor this 5-bit address.
* @param command_7bits: Monitor this 7-bit command.
* @param extend_8bits: Monitor this 8-bit extend.
* @param irq_monitor_cb: User defined IRQ callback function.
* @param irq_monitor_arg: User defined IRQ callback parameter.
* @retval none
*/
void cir_monitor_sony_20bit_format (cir_t *obj, u8 address_5bits, u8 command_7bits, u8 extend_8bits, cir_irq_handler irq_monitor_cb, void *irq_monitor_arg);
/**
* @brief Get the address of the 12-bit SONY protocol.
* @param obj: CIR object define in application software.
* @retval The 5-bit address.
*/
u8 cir_sony_get_12bit_format_address (cir_t *obj);
/**
* @brief Get the command of the 12-bit SONY protocol.
* @param obj: CIR object define in application software.
* @retval The 7-bit command.
*/
u8 cir_sony_get_12bit_format_command (cir_t *obj);
/**
* @brief Get the address of the 15-bit SONY protocol.
* @param obj: CIR object define in application software.
* @retval The 8-bit address.
*/
u8 cir_sony_get_15bit_format_address (cir_t *obj);
/**
* @brief Get the command of the 15-bit SONY protocol.
* @param obj: CIR object define in application software.
* @retval The 7-bit command.
*/
u8 cir_sony_get_15bit_format_command (cir_t *obj);
/**
* @brief Get the address of the 20-bit SONY protocol.
* @param obj: CIR object define in application software.
* @retval The 5-bit address.
*/
u8 cir_sony_get_20bit_format_address (cir_t *obj);
/**
* @brief Get the command of the 20-bit SONY protocol.
* @param obj: CIR object define in application software.
* @retval The 7-bit command.
*/
u8 cir_sony_get_20bit_format_command (cir_t *obj);
/**
* @brief Get the extend of the 20-bit SONY protocol.
* @param obj: CIR object define in application software.
* @retval The 8-bit extend.
*/
u8 cir_sony_get_20bit_format_extend (cir_t *obj);
/**
* @brief Set the rx data pointer by using the PHILIPS RC5 protocol.
* @param obj: CIR object define in application software.
* @param data: Rx data pointer.
* @retval none
*/
void cir_philips_rc5_recv_format (cir_t *obj, u32 *data);
/**
* @brief Send the tx data by using the PHILIPS RC5 protocol.
* @param obj: CIR object define in application software.
* @param field_1bits: The 1-bit field.
* @param toggle_1bits: The 1-bit toggle.
* @param address_5bits: The 5-bit address.
* @param command_6bits: The 6-bit command.
* @retval none
*/
void cir_philips_rc5_send_format (cir_t *obj, u8 field_1bits, u8 toggle_1bits, u8 address_5bits, u8 command_6bits);
/**
* @brief Monitor the specific rx data by using the PHILIPS RC5 protocol, and generate the interrupt.
* @param obj: CIR object define in application software.
* @param field_1bits: Monitor this 1-bit field.
* @param toggle_1bits: Monitor this 1-bit toggle.
* @param address_5bits: Monitor this 5-bit address.
* @param command_6bits: Monitor this 6-bit command.
* @param irq_monitor_cb: User defined IRQ callback function.
* @param irq_monitor_arg: User defined IRQ callback parameter.
* @retval none
*/
void cir_monitor_philips_rc5_format (cir_t *obj, u8 field_1bits, u8 toggle_1bits, u8 address_5bits, u8 command_6bits, cir_irq_handler irq_monitor_cb, void *irq_monitor_arg);
/**
* @brief Get the address of the PHILIPS RC5 protocol.
* @param obj: CIR object define in application software.
* @retval The 5-bit address.
*/
u8 cir_philips_rc5_get_address (cir_t *obj);
/**
* @brief Get the command of the PHILIPS RC5 protocol.
* @param obj: CIR object define in application software.
* @retval The 6-bit command.
*/
u8 cir_philips_rc5_get_command (cir_t *obj);
/**
* @brief Get the field of the PHILIPS RC5 protocol.
* @param obj: CIR object define in application software.
* @retval The 1-bit field.
*/
u8 cir_philips_rc5_get_format_field (cir_t *obj);
/**
* @brief Get the toggle of the PHILIPS RC5 protocol.
* @param obj: CIR object define in application software.
* @retval The 1-bit toggle.
*/
u8 cir_philips_rc5_get_format_toggle (cir_t *obj);
/**
* @brief Set the rx data pointer by using the JVC protocol.
* @param obj: CIR object define in application software.
* @param data: Rx data pointer.
* @retval none
*/
void cir_jvc_recv_format (cir_t *obj, u32 *data);
/**
* @brief Send the tx data by using the normal format of the JVC protocol.
* @param obj: CIR object define in application software.
* @param address_8bits: The 8-bit address.
* @param command_8bits: The 8-bit command.
* @retval none
*/
void cir_jvc_send_normal_format (cir_t *obj, u8 address_8bits, u8 command_8bits);
/**
* @brief Send the tx data by using the header and repeat format of the JVC protocol.
* @param obj: CIR object define in application software.
* @param address_8bits: The 8-bit address.
* @param command_8bits: The 8-bit command.
* @retval none
*/
void cir_jvc_send_repeat_header_format (cir_t *obj, u8 address_8bits, u8 command_8bits);
/**
* @brief Send the tx data by using the repeat format of the JVC protocol.
* @param obj: CIR object define in application software.
* @param address_8bits: The 8-bit address.
* @param command_8bits: The 8-bit command.
* @retval none
*/
void cir_jvc_send_repeat_no_header_format (cir_t *obj, u8 address_8bits, u8 command_8bits);
/**
* @brief Monitor the specific rx data by using the JVC protocol, and generate the interrupt.
* @param obj: CIR object define in application software.
* @param address_8bits: Monitor this 8-bit address.
* @param command_8bits: Monitor this 8-bit command.
* @param irq_monitor_cb: User defined IRQ callback function.
* @param irq_monitor_arg: User defined IRQ callback parameter.
* @retval none
*/
void cir_monitor_jvc_format (cir_t *obj, u8 address_8bits, u8 command_8bits, cir_irq_handler irq_monitor_cb, void *irq_monitor_arg);
/**
* @brief Get the address of the JVC protocol.
* @param obj: CIR object define in application software.
* @retval The 8-bit address.
*/
u8 cir_jvc_get_address (cir_t *obj);
/**
* @brief Get the command of the JVC protocol.
* @param obj: CIR object define in application software.
* @retval The 8-bit command.
*/
u8 cir_jvc_get_command (cir_t *obj);
/**
* @brief Get the receiving status by using NEC, SONY, PHILIPS RC5, or JVC protocol.
* @param obj: CIR object define in application software.
* @retval STAT_SUCCESS: The receiving is the normal format.
* @retval STAT_REPEAT: The receiving is the repeat format.
* @retval STAT_FAIL: The receiving is failed.
* @retval STAT_REPEAT_HEADER: The receiving is the header and repeat format of the JVC protocol.
*/
cir_rx_status cir_get_protocol_rx_status (cir_t *obj);
/**
* @brief Monitor the specific rx data, and generate the interrupt.
* @param obj: CIR object define in application software.
* @param en: To enable or disable.
* @param monitor_data: Monitor the data.
* @param monitor_cnt: Monitor the bit length. Monitor counts 1~32 from the LSB. 0 is inactive.
* @param irq_monitor_cb: User defined IRQ callback function.
* @param irq_monitor_arg: User defined IRQ callback parameter.
* @retval none
*/
void cir_recv_monitor_mode (cir_t *obj, BOOL en, u32 monitor_data, u32 monitor_cnt, cir_irq_handler monitor_cb, void *pmonitor_arg);
/**
* @brief Make the new tx protocol.
* @param obj: CIR object define in application software.
* @param ptx_protocol: Set the tx protocol table.
* @param output_init - Set the tx initial level.
* @param carrier - Let the carrier symbol of the tx protocol table generate the carrier.
* @arg 0 : The carrier symbol has no carrier.
* @arg 1 : The carrier symbol has carrier.
* @param tx_sclkdiv: The divisor of the system clock is to generate a proper tick time for the CIR carrier generation.
* @arg 0 : Generate the appropriate value automatically. (Suggestion)
* @arg 1 ~ 255 : SCLK / tx_sclkdiv.
* @param irq_tx_end_cb: User defined IRQ callback function.
* @param irq_tx_end_arg: User defined IRQ callback parameter.
* @retval none
*/
void cir_make_tx_protocol (cir_t *obj, cir_tx_protocol_t *ptx_protocol, cir_init_value output_init, cir_carrier carrier, cir_sclkdiv tx_sclkdiv,
cir_irq_handler irq_tx_end_cb, void *irq_tx_end_arg);
/**
* @brief Change the tx start symbol of tx protocol table according to the protocol header.
* @param obj: CIR object define in application software.
* @param first_symbol: Set the tx protocol table.
* @param second_symbol: Set the tx protocol table.
* @retval none
*/
void cir_change_tx_start_symbol (cir_t *obj, cir_symbol_t first_symbol, cir_symbol_t second_symbol);
/**
* @brief Change the tx bit0 symbol of tx protocol table.
* @param obj: CIR object define in application software.
* @param first_symbol: Set the tx protocol table.
* @param second_symbol: Set the tx protocol table.
* @retval none
*/
void cir_change_tx_bit0_symbol (cir_t *obj, cir_symbol_t first_symbol, cir_symbol_t second_symbol);
/**
* @brief Change the tx bit1 symbol of tx protocol table.
* @param obj: CIR object define in application software.
* @param first_symbol: Set the tx protocol table.
* @param second_symbol: Set the tx protocol table.
* @retval none
*/
void cir_change_tx_bit1_symbol (cir_t *obj, cir_symbol_t first_symbol, cir_symbol_t second_symbol);
/**
* @brief Change the tx end symbol of tx protocol table.
* @param obj: CIR object define in application software.
* @param first_symbol: Set the tx protocol table.
* @param second_symbol: Set the tx protocol table.
* @retval none
*/
void cir_change_tx_end_symbol (cir_t *obj, cir_symbol_t first_symbol, cir_symbol_t second_symbol);
/**
* @brief Send the tx data.
* @param obj: CIR object define in application software.
* @param data : The TX data pinter.
* @param length: The TX data length.
* @retval none
*/
void cir_send_make_protocol (cir_t *obj, u32 *data, u32 length);
/**
* @brief Set the protocol and tx parameters.
* @param obj: CIR object define in application software.
* @param prx_protocol: Set the rx protocol table.
* @param output_init: Set the initial output.
* @arg 0 : The output is low.
* @arg 1 : The output is high.
* @param carrier: Set the waveform with carrier or no carrier.
* @arg 0 : The carrier symbol has no carrier.
* @arg 1 : The carrier symbol has carrier.
* @param rx_sclkdiv: The divisor of the system clock to generate a proper clock for the input sampling and trigger tick event.
* @arg 0 : Set the appropriate value automatically. (Suggestion)
* @arg 1 ~ 255 : SCLK / rx_sclkdiv.
* @param symbol_time_tolerance_us: Set the time tolerance for demodulating RX symbols. This unit is us.
* @param carrier_tolerance_cnt: Set the tolerance of carrier numbers for demodulating RX symbols.
* @arg 0 : This setting is "0" when this waveform is no carrier.
* @param check_frame_end_time_us: Set the end time after receiving the last symbol. This unit is us.
* @param irq_tx_end_cb: User defined IRQ callback function. When finish to receive data, generate the interrupt.
* @param irq_tx_end_arg: User defined IRQ callback parameter.
* @retval none
*/
void cir_make_rx_protocol (cir_t *obj, cir_rx_protocol_t *prx_protocol, cir_init_value input_init, cir_carrier carrier, cir_sclkdiv rx_sclkdiv,
u16 symbol_time_tolerance_us, u16 carrier_tolerance_cnt, u16 check_frame_end_time_us,
cir_irq_handler irq_rx_end_cb, void *irq_rx_end_arg);
/**
* @brief Set the rx data pointer.
* @param obj: CIR object define in application software.
* @param data: Set the RX data pointer.
* @param data_32bits_num: Set the limit number of RX data, and the unit is 32 bits.
* @arg 0 : Do nothing.
* @arg 1 : the limit number <= 32bits.
* @arg 2 : 32bits < the limit number <= 64bits.
* @arg 3 : ...
* @arg n : (32*(n-1))bits < the limit number <= (32*n)bits.
* @retval none
*/
void cir_recv_make_protocol (cir_t *obj, u32 *data, u32 data_32bits_num);
/**
* @brief Get the number of decoded bits when receive the data.
* @param obj: CIR object define in application software.
* @retval The number of decoded bits.
*/
u32 cir_recv_bit_length (cir_t *obj);
/**
* @brief Check the matching status in order to recognize the decoding start-symbol.
* That is to say, use to recognize the different header.
* @param obj: CIR object define in application software.
* @retval The start matching status. 0: Not match the decoding symbols of group 0, 1: Match the decoding symbols of group 0.
*/
BOOL cir_get_start_match_gp0_status (cir_t *obj);
/**
* @brief Check the matching status in order to recognize the decoding start-symbol.
* That is to say, use to recognize the different header.
* @param obj: CIR object define in application software.
* @retval The start matching status. 0: Not match the decoding symbols of group 1, 1: Match the decoding symbols of group 1.
*/
BOOL cir_get_start_match_gp1_status (cir_t *obj);
/**
* @brief Reset CIR and registers.
* @retval none
*/
void cir_reset (void);
/*\@}*/
#ifdef __cplusplus
}
#endif
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP) || defined(CONFIG_PLATFORM_8195BLP)"
#endif

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,104 @@
/** mbed Microcontroller Library
******************************************************************************
* @file dma_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed GDMA API
******************************************************************************
* @attention
*
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
******************************************************************************
*/
#ifndef MBED_GDMA_API_H
#define MBED_GDMA_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup dma DMA
* @ingroup hal
* @brief dma functions
* @{
*/
///@name Ameba Common
///@{
typedef struct gdma_s gdma_t;
typedef void (*dma_irq_handler)(uint32_t id);
/**
* @brief Initial the GDMA
* @param dma_obj: the GDMA object
* @param handler: the callback function for a DMA transfer complete.
* @param id: the argument of the callback function.
* @retval None
*
*/
void dma_memcpy_init(gdma_t *dma_obj, dma_irq_handler handler, uint32_t id);
/**
* @brief De-Initial the GDMA
* @param dma_obj: the GDMA object
* @retval None
*
*/
void dma_memcpy_deinit(gdma_t *dma_obj);
/**
* @brief To do a memory copy by DMA
* @param dma_obj: the GDMA object
* @param dst: destination memory address
* @param src: source memory address
* @param len: copy data length
* @retval None
*/
void dma_memcpy(gdma_t *dma_obj, void *dst, void* src, uint32_t len);
///@}
#if defined(CONFIG_PLATFORM_8195A) && (CONFIG_PLATFORM_8195A == 1)
///@name Ameba1 Only
///@{
/**
* @brief Initial the GDMA
* @param dma_obj: the GDMA object
* @param handler: the callback function for a DMA transfer complete.
* @param id: the argument of the callback function.
* @retval None
*
*/
void dma_memcpy_aggr_init(gdma_t * dma_obj, dma_irq_handler handler, uint32_t id);
void dma_memcpy_aggr(gdma_t * dma_obj, PHAL_GDMA_BLOCK block_info);
///@}
#endif //CONFIG_PLATFORM_8195A
#if defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)
///@name AmebaPro Only
///@{
/**
* @brief To do a memory copy with multiple blocks by DMA
* @param dma_obj: the GDMA object
* @param phal_gdma_block: the struct contains source , destination informaiton
* @param block_num: number of blocks to be transferred
* @retval None
*/
void dma_multiblk_memcpy(gdma_t *dma_obj, phal_gdma_block_t phal_gdma_block, u8 block_num);
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP)"
/**@}*/
#ifdef __cplusplus
}
#endif
#endif // end of "#define MBED_GDMA_API_H"

View file

@ -0,0 +1,256 @@
/** mbed Microcontroller Library
******************************************************************************
* @file efuse_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed EFUSE API.
******************************************************************************
* @attention
*
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
******************************************************************************
*/
#ifndef MBED_EXT_EFUSE_API_EXT_H
#define MBED_EXT_EFUSE_API_EXT_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup efuse EFUSE
* @ingroup hal
* @brief efuse functions
* @{
*/
///@name Ameba Common
///@{
/**
* @brief Get remaining efuse length
* @retval : remaining efuse length
*/
int efuse_get_remaining_length(void);
/**
* @brief Read efuse contant of specified user
* @param data: Specified the address to save the readback data.
* @retval none
*/
void efuse_mtp_read(uint8_t * data);
/**
* @brief Write user's contant to efuse
* @param data: Specified the data to be programmed.
* @param len: Specifies the data length of programmed data.
* @retval value:
* - 0~32: Success
* - -1: Failure
*/
int efuse_mtp_write(uint8_t *data, uint8_t len);
/**
* @brief Read efuse OTP contant
* @param address: Specifies the offset of the OTP.
* @param len: Specifies the length of readback data.
* @param buf: Specified the address to save the readback data.
* @retval 0: Success
* @retval -1: Failure
*/
int efuse_otp_read(u8 address, u8 len, u8 *buf);
/**
* @brief Write user's contant to OTP efuse
* @param address: Specifies the offset of the programmed OTP.
* @param len: Specifies the data length of programmed data.
* @param buf: Specified the data to be programmed.
* @retval 0: Success
* @retval -1: Failure
*/
int efuse_otp_write(u8 address, u8 len, u8 *buf);
/**
* @brief ckeck user's contant to OTP efuse
* @param buf: Specified the data to be programmed.
* @param len: Specifies the data length of programmed data.
* @retval 0: Success
* @retval -1: Failure
*/
int efuse_otp_chk(u8 len, u8 *buf);
/**
* @brief Disable jtag
* @retval 0: Success
*/
int efuse_disable_jtag(void);
///@}
#if defined(CONFIG_PLATFORM_8195A) && (CONFIG_PLATFORM_8195A == 1)
///@name Ameba1 Only
///@{
/**
* @brief Write key1 to efuse
* @param address: Specifies the offset of the programmed efuse.
* @param len: Specifies the data length of programmed data.
* @param buf: Specified the data to be programmed.
* @retval 0: Success
* @retval -1: Failure
*/
int efuse_key1_write(u8 address, u8 len, u8 *buf);
/**
* @brief Write key2 to efuse
* @param address: Specifies the offset of the programmed efuse.
* @param len: Specifies the data length of programmed data.
* @param buf: Specified the data to be programmed.
* @retval 0: Success
* @retval -1: Failure
*/
int efuse_key2_write(u8 address, u8 len, u8 *buf);
///@}
#endif //CONFIG_PLATFORM_8195A
#if defined(CONFIG_PLATFORM_8711B) && (CONFIG_PLATFORM_8711B == 1)
///@name AmebaZ Only
///@{
/**
* @brief Set RDP Enable.
* @param none
* @note can not change or read back after write.
*/
void efuse_rdp_enable(void);
/**
* @brief Set 16B RDP key into EFUSE.
* @param rdp_key: 16B EFUSE KEY
* @note can not change or read back after write.
*/
void efuse_rdp_keyset(u8 *rdp_key);
/**
* @brief Set 16B OTF key into EFUSE.
* @param OtfKey: 16B EFUSE KEY
* @note can not change or read back after write.
*/
void efuse_otf_keyset(u8 *otf_key);
///@}
#endif //CONFIG_PLATFORM_8711B
#if defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1)
///@name AmebaPro Only
///@{
/**
* @brief Disable LP jtag
* @retval 0: Success
*/
int efuse_disable_lp_jtag(void);
/**
* @brief Disable HS secure jtag
* @retval 0: Success
*/
int efuse_disable_sec_jtag(void);
/**
* @brief Disable HS nonsecure jtag
* @retval 0: Success
*/
int efuse_disable_nonsec_jtag(void);
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BLP)"
#if defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)
///@name AmebaPro Only
///@{
/**
* @brief Write secure key to efuse
* @param buf: Specified the 32-byte security key to be programmed.
* @retval 0: Success
* @retval -1: Failure
*/
int efuse_sec_key_write(u8 *buf);
/**
* @brief Write super secure key to efuse
* @param buf: Specified the 32-byte super security key to be programmed.
* @retval 0: Success
* @retval -1: Failure
*/
int efuse_susec_key_write(u8 *buf);
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP)"
#if (defined(CONFIG_PLATFORM_8710C) && (CONFIG_PLATFORM_8710C == 1))
///@name AmebaZII Only
///@{
/**
* @brief Disable secure jtag
* @retval 0: Success
*/
int efuse_disable_sec_jtag(void);
/**
* @brief Disable nonsecure jtag
* @retval 0: Success
*/
int efuse_disable_nonsec_jtag(void);
/**
* @brief Write secure key to efuse
* @param buf: Specified the 32-byte security key to be programmed.
* @param key_num: select key number.
* @retval 0: Success
* @retval -1: Failure
*/
int efuse_sec_key_write(u8 *buf, u8 key_num);
/**
* @brief Write super secure key to efuse
* @param buf: Specified the 32-byte super security key to be programmed.
* @retval 0: Success
* @retval -1: Failure
*/
int efuse_susec_key_write(u8 *buf);
/**
* @brief Write secure j-tag key to efuse
* @param buf: Specified the 32-byte security key to be programmed.
* @retval 0: Success
* @retval -1: Failure
*/
int efuse_s_jtag_key_write(u8 *buf);
/**
* @brief Write non-secure j-tag key to efuse
* @param buf: Specified the 32-byte security key to be programmed.
* @retval 0: Success
* @retval -1: Failure
*/
int efuse_ns_jtag_key_write(u8 *buf);
/**
* @brief lock super secure key
* @retval 0: Success
* @retval -1: Failure
*/
int efuse_lock_susec_key(void);
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8710C)"
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif // MBED_EXT_EFUSE_API_EXT_H

View file

@ -0,0 +1,159 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************
*/
#ifndef ETHERNET_EX_API_H
#define ETHERNET_EX_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup ethernet_ex ETHERNET_EX
* @ingroup hal
* @brief ethernet extended functions
* @{
*/
#if defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)
///@name AmebaPro Only
///@{
/// the selection of Ethernet pinmux
#define ETH_PIN_SEL (Eth_Pin_Sel0)
/// the selection of the interface between MAC and PHY
#define ETH_IF_SEL (Eth_If_Mii)
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP)"
/// the size (unit: Bytes) of each Tx descriptor
#define ETH_TX_DESC_SIZE 20 // 20 Bytes
/// the size (unit: Bytes) of each Rx descriptor
#define ETH_RX_DESC_SIZE 16 // 16 Bytes
/// the size of the packet buffer
#define ETH_PKT_BUF_SIZE 1600
#if defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)
///@name AmebaPro Only
///@{
/**
\brief Defines Ethernet Pin mux selection.
*/
typedef enum {
Eth_Pin_Sel0 = EthPinSel0,
Eth_Pin_Sel1 = EthPinSel1
} EthPinmuxSel;
/**
\brief Defines the interface between MAC and PHY.
*/
typedef enum {
Eth_If_Mii = EthMiiMode,
Eth_If_Rmii = EthRmiiMode
} EthInterfaceSel;
/**
\brief Defines the link speed.
*/
typedef enum {
Eth_Spd_Auto = -1,
Eth_Spd_10M = 0,
Eth_Spd_100M = 1
} EthSpeedSel;
/**
\brief Defines the duplex mode.
*/
typedef enum {
Eth_Duplex_Auto = -1,
Eth_Duplex_Half = 0,
Eth_Duplex_Full = 1
} EthDuplexMode;
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP)"
/**
\brief The function type of the Ethernet MAC controller interrupt callback function.
*/
typedef void (*ethernet_callback)(uint32_t event, uint32_t data);
#if defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)
///@name AmebaPro Only
///@{
/**
\brief The function type of the OS task yield callback function.
*/
typedef void (*ethernet_task_yield)(void);
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP)"
/**
* @brief To hook a callback function for Ethernet MAC controller interrupt.
*
* @param[in] callback The callback function.
*
* @returns void
*/
void ethernet_irq_hook(ethernet_callback callback);
#if defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)
///@name AmebaPro Only
///@{
/**
* @brief To hook a callback function to make OS do a context-switch while waiting.
*
* @param[in] task_yield The callback function.
*
* @returns void.
*/
void ethernet_task_yield_hook (ethernet_task_yield task_yield);
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP)"
/**
* @brief To set the Tx/Rx descriptor number.
*
* @param[in] txdescCnt The specified Tx descriptor number.
* @param[in] rxdescCnt The specified Rx descriptor number.
*
* @returns void.
*/
void ethernet_set_descnum(uint8_t txdescCnt, uint8_t rxdescCnt);
/**
* @brief To set the start address of Tx/Rx descriptor ring and Tx/Rx packet buffer.
*
* @param[in] TxDescAddr The start address of Tx descriptor ring.
* @param[in] RxDescAddr The start address of Rx descriptor ring.
* @param[in] pTxPktBuf The start address of Tx packet buffer.
* @param[in] pRxPktBuf The start address of Rx packet buffer.
*
* @returns void.
*/
void ethernet_trx_pre_setting(uint8_t *TxDescAddr, uint8_t *RxDescAddr, uint8_t *pTxPktBuf, uint8_t *pRxPktBuf);
#if defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)
///@name AmebaPro Only
///@{
/**
* @brief To set the ethernet MAC address.
*
* @param[in] mac The specified MAC address.
*
* @returns void.
*/
void ethernet_set_address(char *mac);
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP)"
#ifdef __cplusplus
}
#endif
#endif // #ifndef ETHERNET_EX_API_H

View file

@ -0,0 +1,46 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************
*/
#ifndef EX_API_H
#define EX_API_H
#include "device.h"
#include "serial_api.h"
#include "spi_api.h"
#include "dma_api.h"
#include "flash_api.h"
#include "gpio_ex_api.h"
#include "gpio_irq_ex_api.h"
#include "i2c_ex_api.h"
#include "i2s_api.h"
#include "serial_ex_api.h"
#include "sleep_ex_api.h"
#include "spi_ex_api.h"
#include "sys_api.h"
#include "wdt_api.h"
#if defined(CONFIG_PLATFORM_8195A) && (CONFIG_PLATFORM_8195A == 1)
#include "nfc_api.h"
#include "ethernet_ex_api.h"
#endif //CONFIG_PLATFORM_8195A
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,264 @@
/** mbed Microcontroller Library
******************************************************************************
* @file flash_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed FLASH API
******************************************************************************
* @attention
*
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
******************************************************************************
*/
#ifndef MBED_EXT_FLASH_API_EXT_H
#define MBED_EXT_FLASH_API_EXT_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup flash FLASH
* @ingroup hal
* @brief flash functions
* @{
*/
///@name Ameba Common
///@{
typedef struct flash_s flash_t;
/**
* @brief Erase flash sector
* @param obj: Flash object define in application software.
* @param address: Specifies the starting address to be erased.
* @retval none
*/
void flash_erase_sector(flash_t *obj, uint32_t address);
/**
* @brief Erase flash block(64KB)
* @param obj: Flash object define in application software.
* @param address: Specifies the starting address to be erased.LSB 16bits will be masked.
* @retval none
*/
void flash_erase_block(flash_t * obj, uint32_t address);
/**
* @brief Read a word from specified address
* @param obj: Flash object define in application software.
* @param address: Specifies the address to read from.
* @param data: Specified the address to save the readback data.
* @retval 1: Success
* @note auto mode read is ok, because we have flash cache
*/
int flash_read_word(flash_t *obj, uint32_t address, uint32_t * data);
/**
* @brief Write a word to specified address
* @param obj: Flash object define in application software.
* @param address: Specifies the address to be programmed to.
* @param data: Specified the data to be programmed.
* @retval 1: Success
* @note user mode write used
*/
int flash_write_word(flash_t *obj, uint32_t address, uint32_t data);
/**
* @brief Read a stream of data from specified address
* @param obj: Flash object define in application software.
* @param address: Specifies the starting address to read from.
* @param len: Specifies the length of the data to read.
* @param data: Specified the address to save the readback data.
* @retval 1: Success
* @note auto mode is ok, because we have flash cache
*/
int flash_stream_read(flash_t *obj, uint32_t address, uint32_t len, uint8_t * data);
/**
* @brief Write a stream of data to specified address
* @param obj: Flash object define in application software.
* @param address: Specifies the starting address to write to.
* @param len: Specifies the length of the data to write.
* @param data: Pointer to a byte array that is to be written.
* @retval 1: Success
*/
int flash_stream_write(flash_t *obj, uint32_t address, uint32_t len, uint8_t * data);
/**
* @brief Control the flash chip write protect enable/disable.
* @param obj: Flash object define in application software.
* @param protect: This parameter can be 1 or 0.
* @arg 1: Protect the whole chip from being programmed/erased.
* @arg 0: Unprotect the whole chip from being programmed/erased.
* @retval none
*/
void flash_write_protect(flash_t *obj, uint32_t protect);
/**
* @brief Get the value of status register1
* @param obj: Flash object define in application software.
* @retval : The value of status register1.
*/
int flash_get_status(flash_t * obj);
/**
* @brief Read Status register 2 to check flash status
* @param obj: Specifies the parameter of flash object.
* @retval status: the value of status register.
*/
int flash_get_status2(flash_t *obj);
/**
* @brief Set Status register to enable desired operation
* @param obj: Specifies the parameter of flash object.
* @param data: Specifies which bit users like to set.
* ex: if users want to set the third bit, data = 0x8.
* @retval 1: Success
* @note Please refer to the datatsheet of flash for more details of the content of status register.
* The block protected area and the corresponding control bits are provided in the flash datasheet.
*/
int flash_set_status(flash_t * obj, uint32_t data);
/**
* @brief This function aims to reset the status register, please make sure the operation is appropriate.
* @param obj: Specifies the parameter of flash object.
* @retval none
*/
void flash_reset_status(flash_t * obj);
/**
* @brief It is the same with flash_stream_write function which is used to write a stream of data to specified address.
* @param obj: Flash object define in application software.
* @param address: Specifies the starting address to write to.
* @param len: Specifies the length of the data to write.
* @param data: Pointer to a byte array that is to be written.
* @retval 1: Success
*/
int flash_burst_write(flash_t * obj, uint32_t address, uint32_t Length, uint8_t * data);
/**
* @brief It is the same with flash_stream_read function which is used to read a stream of data from specified address
* @param obj: Flash object define in application software.
* @param address: Specifies the starting address to read from.
* @param len: Specifies the length of the data to read.
* @param data: Specified the address to save the readback data.
* @retval 1: Success
*/
int flash_burst_read(flash_t * obj, uint32_t address, uint32_t Length, uint8_t * data);
/**
* @brief This function is only for Micron 128MB flash to access beyond 16MB by switching between eight 16MB-area(segment).
* Please refer to flash datasheet for more information about memory mapping.
* @param obj: Flash object define in application software.
* @param data: Specified which segment to choose.
* @retval 1: Success
*/
int flash_set_extend_addr(flash_t * obj, uint32_t data);
/**
* @brief This function is only for Micron 128MB flash to read from Extended Address Register, which shows the current segment.
* Please refer to flash datasheet for more information about memory mapping.
* @param obj: Flash object define in application software.
* @retval : The value of current Extended Address Register.
*/
int flash_get_extend_addr(flash_t * obj);
/**
* @brief Get flash ID (command: 0x9F).
* @param obj: Flash object define in application software.
* @param buf: Pointer to a byte array to save the readback ID.
* @param len: Specifies the length of the buf. It should be 3.
* @retval -1: Fail.
*/
int flash_read_id(flash_t *obj, uint8_t *buf, uint8_t len);
/**
* @brief This function is only for Winbond flash to get unique ID (command: 0x4B).
* @param obj: Flash object define in application software.
* @param buf: Pointer to a byte array to save the readback unique ID.
* @param len: Specifies the length of the buf. It should be 8.
* @retval -1: Fail.
*/
int flash_read_unique_id(flash_t *obj, uint8_t *buf, uint8_t len);
/**
* @brief This function is only for Winbond flash to set lock mode.
* @param mode: This parameter can be 1 or 0.
* @arg 1: Enable individual sector / block protect feature.
* @arg 0: Set status register 1 to enble write protect feature.
* @retval none
* @note But not all Winbond flash supports the function, plase refer to data sheets of the target flashes.
*/
void flash_set_lock_mode(uint32_t mode);
/**
* @brief This function is only for Winbond flash to lock whole flash chip.
* @param none
* @retval none
* @note But not all Winbond flash supports the function, plase refer to data sheets of the target flashes.
*/
void flash_global_lock(void);
/**
* @brief This function is only for Winbond flash to unlock whole flash chip.
* @param none
* @retval none
* @note But not all Winbond flash supports the function, plase refer to data sheets of the target flashes.
*/
void flash_global_unlock(void);
/**
* @brief This function is only for Winbond flash to lock individual sector or block region, should refer to the datasheet for more details.
* @param address
* @retval none
* @note But not all Winbond flash supports the function, plase refer to data sheets of the target flashes.
*/
void flash_individual_lock(uint32_t address);
/**
* @brief This function is only for Winbond flash to unlock individual sector or block region, should refer to the datasheet for more details.
* @param address
* @retval none
* @note But not all Winbond flash supports the function, plase refer to data sheets of the target flashes.
*/
void flash_individual_unlock(uint32_t address);
/**
* @brief This function is only for Winbond flash to get the individual lock state on certain address.
* @param address
* @retval 1: the target sector/block is locked.
* 0: the target sector/block is not locked.
* @note But not all Winbond flash supports the function, plase refer to data sheets of the target flashes.
*/
int flash_read_individual_lock_state(uint32_t address);
///@}
#if (defined(CONFIG_PLATFORM_8711B) && (CONFIG_PLATFORM_8711B)) \
|| (defined(CONFIG_PLATFORM_8710C) && (CONFIG_PLATFORM_8710C))
///@name AmebaZ/AmebaZ2
///@{
/**
* @brief Erase the whole flash chip
* @param obj: Flash object define in application software.
* @retval none
*/
void flash_erase_chip(flash_t *obj);
///@}
#endif //CONFIG_PLATFORM_8711B
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,88 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************
*/
#ifndef MBED_GPIO_API_H
#define MBED_GPIO_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup gpio_ex GPIO_EX
* @ingroup hal
* @brief gpio extended functions
* @{
*/
/**
* @brief Sets value to the selected output port pin.
* @param obj: gpio object define in application software.
* @param value: specifies the value to be written to the selected pin
* This parameter can be one of the following values:
* @arg 0: Pin state set to low
* @arg 1: Pin state set to high
* @retval none
*/
void gpio_direct_write(gpio_t *obj, BOOL value) ;
/**
* @brief Sets pull type to the selected pin.
* @param obj: gpio object define in application software.
* @param pull_type: this parameter can be one of the following values:
* @arg PullNone: HighZ, user can input high or low use this pin
* @arg OpenDrain(is OpenDrain output): no pull + OUT + GPIO[gpio_bit] = 0
* @arg PullDown: pull down
* @arg PullUp: pull up
* @retval none
*/
void gpio_pull_ctrl(gpio_t *obj, PinMode pull_type);
/**
* @brief Deinitializes the GPIO device, include mode/direction/pull control registers.
* @param obj: gpio object define in application software.
* @retval none
*/
void gpio_deinit(gpio_t *obj);
/**
* @brief Set GPIO direction.
* @param obj: gpio object define in application software.
* @param direction: this parameter can be one of the following values:
* @arg PIN_INPUT: this pin is input
* @arg PIN_OUTPUT: this pin is output
* @retval none
*/
void gpio_change_dir(gpio_t *obj, PinDirection direction);
#if (defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)) || (defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1))
///@name AmebaPro Only
///@{
/**
* @brief Sets schmitt trigger on/off control on the given GPIO pin .
* @param pin: PinName according to pinmux spec.
* @param ctrl The on/off control:
* - 0: disable the schmitt trigger.
* - 1: enable the schmitt trigger.
* @param v_h3l1 The GPIO Group Voltage Select:
* - 0: 1.8V.
* - 1: 3V.
* @retval none
*/
void gpio_schmitt_ctrl(PinName pin, BOOLEAN ctrl, uint8_t v_h3l1);
///@}
#endif //CONFIG_PLATFORM_8195BHP || CONFIG_PLATFORM_8195BLP
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,113 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************
*/
#ifndef MBED_GPIO_IRQ_EX_API_H
#define MBED_GPIO_IRQ_EX_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup gpio_irq_ex_api GPIO_IRQ_EX
* @ingroup hal
* @brief gpio IRQ extented functions
* @{
*/
///@name Ameba Common
///@{
typedef enum {
IRQ_LOW = 3,
IRQ_HIGH = 4,
IRQ_FALL_RISE = 5 // dual edge trigger, available for 8195B and 8710C
} gpio_irq_event_ex;
/**
* @brief Deinitializes the GPIO device interrupt mode, include mode/trigger/polarity registers.
* @param obj: gpio irq object define in application software.
* @retval none
*/
void gpio_irq_deinit(gpio_irq_t *obj);
/**
* @brief Sets pull type to the selected interrupt pin.
* @param obj: gpio irq object define in application software.
* @param pull_type: this parameter can be one of the following values:
* @arg PullNone: HighZ, user can input high or low use this pin
* @arg OpenDrain(is OpenDrain output): no pull + OUT + GPIO[gpio_bit] = 0
* @arg PullDown: pull down
* @arg PullUp: pull up
* @retval none
*/
void gpio_irq_pull_ctrl(gpio_irq_t *obj, PinMode pull_type);
///@}
#if (defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)) || (defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1))
///@name AmebaPro Only
///@{
/**
* @brief To enables or disable the debounce function of the given GPIO IRQ pin.
* The debounce resource(circuit) is limited, not all GPIO pin
* can has debounce function.
*
* @param[in] pgpio_irq_adapter The GPIO IRQ pin adapter.
* @param[in] debounce_us The time filter for the debounce, in micro-second.
* But the time resolution is 31.25us (1/32K) and the
* maximum time is 512 ms.
* @param[in] enable: this parameter can be one of the following values:
* @arg 0 disable gpio debounce interrupt
* @arg 1 enable gpio debounce interrupt
* @return 0: Setting Succeed.
* @return -1: Setting Fail.
*/
int gpio_irq_debounce_set (gpio_irq_t *obj, uint32_t debounce_us, u8 enable);
///@}
#endif //CONFIG_PLATFORM_8195BHP || CONFIG_PLATFORM_8195BLP
#if defined(CONFIG_PLATFORM_8710C)
///@name AmebaZ2 Only
///@{
/**
* @brief To enables or disable the debounce function of the given GPIO IRQ pin.
* The debounce resource(circuit) is limited, not all GPIO pin
* can has debounce function.
*
* @param[in] pgpio_irq_adapter The GPIO IRQ pin adapter.
* @param[in] debounce_us The time filter for the debounce, in micro-second.
* But the time resolution is 31.25us (1/32K) and the
* maximum time is 512 ms.
* @param[in] enable: this parameter can be one of the following values:
* @arg 0 disable gpio debounce interrupt
* @arg 1 enable gpio debounce interrupt
* @return 0: Setting Succeed.
* @return -1: Setting Fail.
*/
int gpio_irq_debounce_set (gpio_irq_t *obj, uint32_t debounce_us, u8 enable);
/**
* @brief Reads the specified gpio irq port pin.
* @param obj: gpio irq object define in application software.
* @retval 1: pin state is high
* @retval 0: pin state is low
*/
int gpio_irq_read (gpio_irq_t *obj);
///@}
#endif //CONFIG_PLATFORM_8710C
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif // end of #ifndef MBED_GPIO_IRQ_EX_API_H

View file

@ -0,0 +1,78 @@
/** mbed Microcontroller Library
******************************************************************************
* @file i2c_ex_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed API for I2C.
******************************************************************************
* @attention
*
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
******************************************************************************
*/
#ifndef I2C_EX_API_H
#define I2C_EX_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup i2c_ex I2C_EX
* @ingroup hal
* @brief i2c extended functions
* @{
*/
///@name Ameba Common
///@{
typedef enum {
I2C_TX_COMPLETE = 0,
I2C_RX_COMPLETE = 1,
I2C_RD_REQ_COMMAND = 2,
I2C_ERR_OCCURRED = 3,
}I2CCallback;
/**
* @brief Enable/Disable i2c Device
* @param obj: i2c object define in application software.
* @param enable: this parameter can be one of the following values:
* @arg 0 disable
* @arg 1 enable
* @retval : result
*/
int i2c_enable_control(i2c_t *obj, int enable);
/**
* @brief Enable i2c master RESTART function
* @param obj: i2c object define in application software.
* @retval none
*/
void i2c_restart_enable(i2c_t *obj);
/**
* @brief Disable i2c Master RESTART function
* @param obj: i2c object define in application software.
* @retval none
*/
void i2c_restart_disable(i2c_t *obj);
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,417 @@
/** mbed Microcontroller Library
******************************************************************************
* @file i2s_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed I2S API
******************************************************************************
* @attention
*
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
******************************************************************************
*/
#ifndef MBED_EXT_I2S_API_EXT_H
#define MBED_EXT_I2S_API_EXT_H
#include "device.h"
#if !(defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)) && !(defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1))
///@name Only Ameba1
#include "ameba_soc.h"
#endif // end of "#if !defined(CONFIG_PLATFORM_8195BHP) && !defined(CONFIG_PLATFORM_8195BLP)"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup i2s I2S
* @ingroup hal
* @brief i2s functions
* @{
*/
#if (defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)) || (defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1)) || (defined(CONFIG_PLATFORM_8721D) && (CONFIG_PLATFORM_8721D == 1))
///@name AmebaPro and AmebaD
///@{
enum {
SR_8KHZ = I2S_SR_8KHZ,
SR_12KHZ = I2S_SR_12KHZ,
SR_16KHZ = I2S_SR_16KHZ,
SR_24KHZ = I2S_SR_24KHZ,
SR_32KHZ = I2S_SR_32KHZ,
SR_48KHZ = I2S_SR_48KHZ,
SR_64KHZ = I2S_SR_64KHZ,
SR_96KHZ = I2S_SR_96KHZ,
SR_192KHZ = I2S_SR_192KHZ,
SR_384KHZ = I2S_SR_384KHZ,
SR_7p35KHZ = I2S_SR_7p35KHZ,
SR_11p025KHZ = I2S_SR_11p025KHZ,
SR_14p7KHZ = I2S_SR_14p7KHZ,
SR_22p05KHZ = I2S_SR_22p05KHZ,
SR_29p4KHZ = I2S_SR_29p4KHZ,
SR_44p1KHZ = I2S_SR_44p1KHZ,
SR_58p8KHZ = I2S_SR_58p8KHZ,
SR_88p2KHZ = I2S_SR_88p2KHZ,
SR_176p4KHZ = I2S_SR_176p4KHZ
};
enum {
CH_STEREO = I2S_CH_STEREO,
CH_5p1 = I2S_CH_5p1,
CH_MONO = I2S_CH_MONO
};
enum {
WL_16b = I2S_WL_16,
WL_24b = I2S_WL_24,
WL_32b = I2S_WL_32
};
#else
///@name Ameba Common
///@{
enum {
SR_8KHZ = I2S_SR_8KHZ,
SR_16KHZ = I2S_SR_16KHZ,
SR_24KHZ = I2S_SR_24KHZ,
SR_32KHZ = I2S_SR_32KHZ,
SR_48KHZ = I2S_SR_48KHZ,
SR_96KHZ = I2S_SR_96KHZ,
SR_7p35KHZ = I2S_SR_7p35KHZ,
SR_14p7KHZ = I2S_SR_14p7KHZ,
SR_22p05KHZ = I2S_SR_22p05KHZ,
SR_29p4KHZ = I2S_SR_29p4KHZ,
SR_44p1KHZ = I2S_SR_44p1KHZ,
SR_88p2KHZ = I2S_SR_88p2KHZ
};
enum {
CH_STEREO = I2S_CH_STEREO,
CH_MONO = I2S_CH_MONO
};
enum {
WL_16b = I2S_WL_16,
WL_24b = I2S_WL_24
};
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP) || defined(CONFIG_PLATFORM_8195BLP)"
enum {
I2S_DIR_RX = I2S_ONLY_RX, // Rx Only
I2S_DIR_TX = I2S_ONLY_TX, // Tx Only
I2S_DIR_TXRX = I2S_TXRX // Tx & Rx (BiDirection)
};
typedef void (*i2s_irq_handler)(uint32_t id, char *pbuf);
typedef struct i2s_s i2s_t;
/**
* @brief Deinitializes the I2S device, include function/interrupt/I2S registers.
* @param obj: i2s object define in application software.
* @retval none
*/
void i2s_deinit(i2s_t *obj);
/**
* @brief Sets page number, page size, page address.
* @param obj: i2s object define in application software.
* @param tx_buf: pointer to the start address of Tx page.
* @param rx_buf: pointer to the start address of Rx page.
* @param page_num: page number. This parameter must be set to a value in the 2~4 range
* @param page_size: page size. This parameter must be set to a value in the 4~16384 bytes range
* @retval none
*/
void i2s_set_dma_buffer(i2s_t *obj, char *tx_buf, char *rx_buf, uint32_t page_num, uint32_t page_size);
/**
* @brief Sets TX interrupt handler.
* @param obj: i2s object define in application software.
* @param handler: TX interrupt callback function.
* @param id: TX interrupt callback function parameter.
* @retval none
*/
void i2s_tx_irq_handler(i2s_t *obj, i2s_irq_handler handler, uint32_t id);
/**
* @brief Sets RX interrupt handler.
* @param obj: i2s object define in application software.
* @param handler: RX interrupt callback function.
* @param id: RX interrupt callback function parameter.
* @retval none
*/
void i2s_rx_irq_handler(i2s_t *obj, i2s_irq_handler handler, uint32_t id);
/**
* @brief Sets i2s data transfer direction.
* @param obj: i2s object define in application software.
* @param trx_type: transfer direction.
* This parameter can be one of the following values:
* @arg I2S_DIR_RX: Rx receive direction
* @arg I2S_DIR_TX: Tx transmission direction
* @arg I2S_DIR_TXRX: Tx & Rx bi-direction
* @retval none
*/
void i2s_set_direction(i2s_t *obj, int trx_type);
/**
* @brief Sets i2s channel number, sample rate, word length.
* @param obj: i2s object define in application software.
* @param channel_num: this parameter can be one of the following values:
* @arg CH_STEREO: stereo channel
* @arg CH_MONO: mono channel
* @param rate: this parameter can be one of the following values:
* @arg SR_8KHZ: sample rate is 8kHz
* @arg SR_16KHZ: sample rate is 16kHz
* @arg SR_24KHZ: sample rate is 24kHz
* @arg SR_32KHZ: sample rate is 32kHz
* @arg SR_48KHZ: sample rate is 48kHz
* @arg SR_96KHZ: sample rate is 96kHz
* @arg SR_7p35KHZ: sample rate is 7.35kHz
* @arg SR_14p7KHZ: sample rate is 14.7kHz
* @arg SR_22p05KHZ: sample rate is 22.05kHz
* @arg SR_29p4KHZ: sample rate is 29.4kHz
* @arg SR_44p1KHZ: sample rate is 44.1kHz
* @arg SR_88p2KHZ: sample rate is 88.2kHz
* @param word_len: this parameter can be one of the following values:
* @arg WL_16b: sample bit is 16 bit
* @arg WL_24b: sample bit is 24 bit
* @retval none
*/
void i2s_set_param(i2s_t *obj, int channel_num, int rate, int word_len);
/**
* @brief Gets current tx page address.
* @param obj: i2s object define in application software.
* @retval : address of current tx page or NULL
* @note current page own by cpu, return address of current tx page
* @note current page own by i2s, return NULL
*/
int* i2s_get_tx_page(i2s_t *obj);
/**
* @brief Sets current tx page own by i2s.
* @param obj: i2s object define in application software.
* @param pbuf: tx buffer adderss.
* @retval none
*/
void i2s_send_page(i2s_t *obj, uint32_t *pbuf);
/**
* @brief Sets current rx page own by i2s.
* @param obj: i2s object define in application software.
* @retval none
*/
void i2s_recv_page(i2s_t *obj);
/**
* @brief Enable i2s interrupt and function.
* @param obj: i2s object define in application software.
* @retval none
*/
void i2s_enable(i2s_t *obj);
/**
* @brief Disable i2s interrupt and function.
* @param obj: i2s object define in application software.
* @retval none
*/
void i2s_disable(i2s_t *obj);
///@}
#if defined(CONFIG_PLATFORM_8195A) && (CONFIG_PLATFORM_8195A == 1)
///@name Ameba1 Only
///@{
/**
* @brief Initializes the I2S device, include clock/function/interrupt/I2S registers.
* @param obj: i2s object define in application software.
* @param sck: Serial clock PinName according to pinmux spec.
* @param ws: Word select PinName according to pinmux spec.
* @param sd: PinName according to pinmux spec.
* @retval none
*/
void i2s_init(i2s_t *obj, PinName sck, PinName ws, PinName sd);
///@}
#endif //CONFIG_PLATFORM_8195A
#if (defined(CONFIG_PLATFORM_8711B) && (CONFIG_PLATFORM_8711B == 1)) || (defined(CONFIG_PLATFORM_8721D) && (CONFIG_PLATFORM_8721D == 1))
///@name AmebaZ and AmebaD
///@{
/**
* @brief Initializes the I2S device, include clock/function/interrupt/I2S registers.
* @param obj: i2s object define in application software.
* @param sck: Serial clock PinName according to pinmux spec.
* @param ws: Word select PinName according to pinmux spec.
* @param sd_tx: Tx PinName according to pinmux spec.
* @param sd_rx: Rx PinName according to pinmux spec.
* @param mck: Master clock PinName according to pinmux spec.
* @retval none
*/
void i2s_init(i2s_t *obj, PinName sck, PinName ws, PinName sd_tx, PinName sd_rx, PinName mck);
///@}
#endif //CONFIG_PLATFORM_8711B
#if (defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)) || (defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1))
///@name AmebaPro Only
///@{
typedef enum {
FORMAT_I2S = I2S_FORMAT_I2S,
LEFT_JUST = I2S_FORMAT_LEFT_JUST,
FORMAT_RIGHT_JUST = I2S_FORMAT_RIGHT_JUST
} i2s_format;
typedef enum {
I2S_MASTER = I2S_MASTER_MODE,
I2S_SLAVE = I2S_SLAVE_MODE
} i2s_ms_mode;
typedef enum {
PAGE_0NUM = I2S_USELESS_PAGE,
PAGE_2NUM = I2S_2PAGE,
PAGE_3NUM = I2S_3PAGE,
PAGE_4NUM = I2S_4PAGE
} i2s_page_num;
typedef enum {
BURST8 = I2S_BURST8,
BURST12 = I2S_BURST12,
BURST16 = I2S_BURST16
} i2s_burst_size;
typedef enum {
LEFT_PHASE = I2S_LEFT_PHASE,
RIGHT_PHASE = I2S_RIGHT_PHASE
} i2s_ws_swap;
typedef enum {
NEGATIVE_EDGE = I2S_NEGATIVE_EDGE,
POSITIVE_EDGE = I2S_POSITIVE_EDGE
} i2s_edge_sw;
/**
* @brief Initializes the I2S device, include clock/function/interrupt/I2S registers.
* @param obj: i2s object define in application software.
* @param sck: Serial clock PinName according to pinmux spec.
* @param ws: Word select PinName according to pinmux spec.
* @param sd_tx0: Tx PinName according to pinmux spec.
* @param sd_rx: Rx PinName according to pinmux spec. This pin is not configured when set PinName "NC".
* @param mck: Master clock PinName according to pinmux spec. This pin is not configured when set PinName "NC".
* @param sd_tx1: Tx1 PinName according to pinmux spec. This pin is not configured when set PinName "NC".
* @param sd_tx2: Tx2 PinName according to pinmux spec. This pin is not configured when set PinName "NC".
* @retval none
*/
void i2s_init(i2s_t *obj, PinName sck, PinName ws, PinName sd_tx0, PinName sd_rx, PinName mck, PinName sd_tx1, PinName sd_tx2);
/**
* @brief Reset the I2S.
* @param obj: i2s object define in application software.
* @retval none
*/
void i2s_sw_reset(i2s_t *obj);
/**
* @brief Set the I2S format.
* @param obj: i2s object define in application software.
* @param format: The I2S formate.
* @FORMAT_I2S : I2S
* @LEFT_JUST : Left Justified
* @FORMAT_RIGHT_JUST : Right Justified
* @retval none
*/
void i2s_set_format(i2s_t *obj, i2s_format format);
/**
* @brief Set the master or slave mode.
* @param obj: i2s object define in application software.
* @param ms_mode: Master or slave mode.
* @I2S_MASTER : Master mode.
* @I2S_SLAVE : Left Justified
* @FORMAT_RIGHT_JUST : Right Justified
* @retval none
*/
void i2s_set_master(i2s_t *obj, i2s_ms_mode ms_mode);
/**
* @brief Set the burst size for DMA.
* @param obj: i2s object define in application software.
* @param burst_size: Set the burst size.
* @BURST8 : The burst size is 8-words.
* @BURST12 : The burst size is 12-words.
* @BURST16 : The burst size is 16-words.
* @retval none
*/
void i2s_set_dma_burst_size(i2s_t *obj, i2s_burst_size burst_size);
/**
* @brief Make the data do the byte switch.
* @param obj: i2s object define in application software.
* @param byte_swap_en: To enable or disable.
* @retval none
*/
void i2s_set_byte_swap(i2s_t *obj, BOOL byte_swap_en);
/**
* @brief Make the SCK inverse.
* @param obj: i2s object define in application software.
* @param sck_inv_en: To enable or disable.
* @retval none
*/
void i2s_set_sck_inv(i2s_t *obj, BOOL sck_inv_en);
/**
* @brief Control whether the first data appear in the "right" or "left" phase of WS clock.
* @param obj: i2s object define in application software.
* @param ws_swap: Select the right or left phase.
* @LEFT_PHASE : Select the left phase.
* @RIGHT_PHASE : Select the right phase.
* @retval none
*/
void i2s_set_ws_swap(i2s_t *obj, i2s_ws_swap ws_swap);
/**
* @brief Set the I2S loopback mode. Need to set the I2S direction is only TX.
* @param obj: i2s object define in application software.
* @param loopback_en: To enable or disable.
* @retval none
*/
void i2s_set_loopback(i2s_t *obj, BOOL loopback_en);
/**
* @brief Chose to send data at the negative edge or positive edge of SCK.
* @param obj: i2s object define in application software.
* @param edge_sw: Select the sending edge.
* @NEGATIVE_EDGE : Select the negative edge.
* @POSITIVE_EDGE : Select the positive edge.
* @retval none
*/
void i2s_set_data_start_edge(i2s_t *obj, i2s_edge_sw edge_sw);
/**
* @brief Set the I2S mute mode.
* @param obj: i2s object define in application software.
* @param mute_en: To enable or disable.
* @retval none
*/
void i2s_set_mute(i2s_t *obj, BOOL mute_en);
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP) || defined(CONFIG_PLATFORM_8195BLP)"
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,213 @@
/**************************************************************************//**
* @file icc_api.c
* @brief This file defines the data types and macro for ICC API implementation.
*
* @version V1.00
* @date 2017-06-05
*
* @note
*
******************************************************************************
*
* Copyright(c) 2007 - 2016 Realtek Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*
******************************************************************************/
#ifndef MBED_ICC_API_H
#define MBED_ICC_API_H
#if (defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)) || (defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1))
///@name AmebaPro Only
///@{
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup icc ICC
* @ingroup hal
* @brief ICC(Inter CPU Communication) HAL APIs
* @{
*/
/**
\brief ICC message queue ID.
*/
typedef enum icc_api_msg_qid_e {
ICC_MsgHQ = 0, ///< higher priority message queue, data is this queue will be processed first
ICC_MsgLQ = 1 ///< lower priority message queue
} icc_msg_qid_t, *picc_msg_qid_t;
/**
\brief Default type for ICC user application command word.
*/
typedef struct icc_user_cmd_s {
union {
uint32_t cmd_w;
struct {
uint32_t para0:24; ///< command parameter 0. User application can re-define this field
uint32_t cmd:8; ///< command type, bit[31:24] is dedicated for the command type.
} cmd_b;
};
} icc_user_cmd_t, *picc_user_cmd_t;
#if 0
/**
\brief Default type for ICC user application message word.
*/
typedef struct icc_user_msg_s{
union {
uint32_t msg_w;
struct {
icc_msg_qid_t msg_q:8; ///< message queue selection, bit[7:0] is dedicated for the message queue ID.
uint32_t msg_op:8; ///< message operland. User application can re-define this field.
uint32_t msg_type:8; ///< message type, bit[23:13] is dedicated for the message type.
uint32_t cmd:8; ///< command type, bit[31:24] is reserved for the command type. User application should not use this field.
} msg_b;
};
} icc_user_msg_t, *picc_user_msg_t;
#endif
/**
\brief The function type of the ICC command callback function.
*/
typedef void (*icc_user_cmd_callback_t)(uint32_t icc_cmd, uint32_t icc_cmd_op, uint32_t cb_arg);
/**
\brief The function type of the ICC message callback function.
*/
typedef void (*icc_user_msg_callback_t)(uint8_t *pmsg_buf, uint32_t msg_size, uint32_t cb_arg);
/**
\brief The function type of the message data transfer complete callback function.
*/
typedef void (*icc_msg_tx_callback_t)(uint32_t cb_arg);
/**
* @brief Initials the ICC (Inter CPU Communication) object.
* The secure region ICC object should be initialed first.
*
* @returns void.
*/
void icc_init (void);
/**
* @brief Disables the ICC interface.
*
* @returns void.
*/
void icc_deinit (void);
/**
* @brief Submits a message RX request with RX data buffer to the ICC HAL. The RX requests
* are used to receive messages from HS platform.
* @param[in] rx_req The message RX request will to be added to the message RX request pending queue.
* @param[in] pbuf The data buffer for ICC message data receiving.
* @param[in] size The size, in byte, of the data buffer.
*
* @return void.
*/
void icc_msg_rx_req_submit (icc_msg_rx_req_t *rx_req, uint8_t *pbuf, uint32_t size);
/**
* @brief Registers(add) an ICC command to the user application ICC command table.
*
* @param[in] cmd The user application ICC command type to be registered.
* @param[in] callback The handler function of this user application ICC command type.
* @param[in] cb_arg The application data will be passed back to the application with the callback function.
*
* @return void.
*/
void icc_cmd_register(uint8_t cmd, icc_user_cmd_callback_t callback, uint32_t cb_arg);
/**
* @brief Unregisters(remove) an ICC command from the user application ICC command table.
*
* @param[in] cmd The ICC command type to be removed from the user application ICC command table.
*
* @returns void.
*/
void icc_cmd_unregister(uint8_t cmd);
/**
* @brief Sends an ICC command to the LS platform.
*
* @param[in] cmd The ICC command word 0, it contains the command type and the data word0.
* @param[in] cmd_para1 The ICC command parameter(data word1).
* @param[in] timeout_us The period, in micro-second, to wait the completion of
* command sending.
* -Value 0: no wait.
* -Value 0xFFFFFFFF: wait forever.
* @param[in] task_yield The OS task yield function. The ICC HAL will call this function
* while wait for the command sending is finished.
*
* @return void.
*/
void icc_cmd_send (uint32_t cmd_w, uint32_t cmd_para1, uint32_t timeout_us, void *task_yield);
/**
* @brief Registers(adds) an ICC user application message to the
* ICC user application message table.
*
* @param[in] msg_type The ICC message type to be registered.
* @param[in] frame The frame type(category) of this ICC message.
* @param[in] callback The ICC message handler function of this new added message type.
* @param[in] cb_arg The application data will be passed back to the application
* with the callback function.
*
* @return void.
*/
void icc_msg_register (uint8_t msg_type, uint8_t frame,
icc_user_msg_callback_t callback, uint32_t cb_arg);
/**
* @brief Un-register(remove) an user application ICC message from the
* user application ICC message table.
*
* @param[in] msg The user application ICC message type to be removed
* from the user application ICC message table.
* @param[in] frame The frame type(category) of this ICC message.
*
* @returns void.
*/
void icc_msg_unregister (uint8_t msg, uint8_t frame);
/**
* @brief Sends a ICC message (with message data) to peer.
* @param[in] msg_type The message type of the ICC message to be send.
* @param[in] frame_type The frame type(category) of the message type.
* @param[in] q_id The message queue ID. It assign the message queue to send this message(with its data).
* @param[in] msg_data The buffer of the message data to be send.
* @param[in] msg_len The length(in byte) of data in the buffer msg_data to be send.
* @param[in] callback The call-back function for the message data transfer is done.
* @param[in] callback_arg The argument of the call-back function.
*
* @return 0: Message send OK. (the TX request adds to the TX pending queue OK).
* @return < 0: Gor error on Message sending.
*/
int32_t icc_msg_tx_submit (uint8_t msg_type, uint8_t frame_type, uint8_t *msg_data, uint16_t msg_len,
icc_msg_tx_callback_t callback, uint32_t callback_arg);
/** @} */ /* End of group icc */
#ifdef __cplusplus
}
#endif
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP) || defined(CONFIG_PLATFORM_8195BLP)"
#endif // end of "#ifndef MBED_ICC_API_H"

View file

@ -0,0 +1,159 @@
/** mbed Microcontroller Library
******************************************************************************
* @file keyscan_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed KEYSCAN API
******************************************************************************
* @attention
*
* 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_KEYSCAN_API_H
#define MBED_KEYSCAN_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup keyscan KEYSCAN
* @ingroup hal
* @brief KEYSCAN functions
* @{
*/
#if ((defined (CONFIG_PLATFORM_8721D) && (CONFIG_PLATFORM_8721D == 1)))
///@name AmebaD Only
///@{
typedef struct keyscan_s keyscan_t;
/**
* @brief initialization of pinmux settings and pad settings.
* @param col: selected column num depending on KeyColumn(eg: col 0 & col 2, col is 5) .
* @param row: selected column num depending on KeyRow .
* @return void
*/
void keyscan_array_pinmux(u32 col, u32 row);
/**
* @brief Get data number of keyscan FIFO.
* @param obj: keyscan object defined in application software.
* @retval data number of keyscan FIFO
*/
u8 keyscan_getdatanum(keyscan_t *obj);
/**
* @brief Read data from keyscan FIFO.
* @param obj: keyscan object defined in application software.
* @param pBuf: buffer to save data read from KeyScan FIFO.
* @param num: number of data to be read.
* @retval None
*/
void keyscan_read(keyscan_t *obj, u32* pbuf, u8 num);
/**
* @brief Initializes the KeyScan device.
* @param obj: keyscan object defined in application software.
* @retval None
*/
void keyscan_init(keyscan_t *obj);
/**
* @brief Enables or disables the specified KeyScan interrupts mask.
* @param obj: keyscan object defined in application software.
* @param keyscan_IT: specifies the KeyScan interrupt sources to be enabled or masked.
* This parameter can be one or combinations of the following values:
* @arg BIT_KS_SCAN_EVENT_INT_MSK: Mask Scan event interrupt status
* @arg BIT_KS_FIFO_LIMIT_INT_MSK: Mask FIFO limit interrupt status
* @arg BIT_KS_FIFO_OVERFLOW_INT_MSK: Mask FIFO overflow interrupt
* @arg BIT_KS_FIFO_FULL_INT_MSK: Mask FIFO full interrupt
* @arg BIT_KS_SCAN_FINISH_INT_MSK: Mask scan finish interrupt
* @arg BIT_KS_FIFO_NOTEMPTY_INT_MSK: Mask FIFO nonempty interrupt
* @arg BIT_KS_ALL_RELEASE_INT_MSK: Mask All Release interrupt
* @param newstate: new state of the specified KeyScan interrupts mask.
* This parameter can be: ENABLE or DISABLE.
* @retval None
*/
void keyscan_set_irq(keyscan_t * obj, u32 keyscan_IT, u32 newstate);
/**
* @brief Clear the specified KeyScan interrupt pending bit.
* @param obj: keyscan object defined in application software.
* @param keyscan_IT: specifies the KeyScan interrupt to be cleared.
* This parameter can be one or combinations of the following values:
* @arg BIT_KS_FIFO_LIMIT_INT_STATUS: FIFO limit interrupt status
* @arg BIT_KS_FIFO_OVERFLOW_INT_STATUS: FIFO overflow interrupt status
* @arg BIT_KS_SCAN_FINISH_INT_STATUS: Scan finish interrupt status
* @arg BIT_KS_ALL_RELEASE_INT_STATUS: All Release interrupt status
* @note BIT_KS_SCAN_EVENT_INT_STATUS is automatically cleared by hardware when the data is read.
* BIT_KS_FIFO_FULL_INT_STATUS is automatically cleared by hardware when the buffer level
* goes below the BIT_KS_FIFO_THREHOLD_LEVEL threshold.
* BIT_KS_FIFO_NOTEMPTY_INT_STATUS is automatically cleared by hardware when the FIFO is empty.
* @retval None
*/
void keyscan_clear_irq(keyscan_t * obj, u32 keyscan_IT);
/**
* @brief Get KeyScan interrupt status.
* @param obj: keyscan object defined in application software.
* @retval interrupt status
*/
u32 keyscan_get_irq_status(keyscan_t * obj);
/**
* @brief Set keyscan interrupt handler.
* @param obj: keyscan object define in application software.
* @param func: the interrupt handler function.
* @retval None
*/
void keyscan_set_irq_handler(keyscan_t * obj, void * func);
/**
* @brief Enable the specified KeyScan peripheral.
* @param obj: keyscan object defined in application software.
* @retval None
*/
void keyscan_enable(keyscan_t *obj);
/**
* @brief disable the specified KeyScan peripheral.
* @param obj: keyscan object defined in application software.
* @retval None
*/
void keyscan_disale(keyscan_t *obj);
/**
* @brief Clears the FIFO data.
* @param obj: keyscan object defined in application software.
* @retval None
*/
void keyscan_clearfifodata(keyscan_t *obj);
///@}
/*\@}*/
///@}
#endif //CONFIG_PLATFORM_8721D
#ifdef __cplusplus
}
#endif
#endif/* MBED_KEYSCAN_API_H */

View file

@ -0,0 +1,188 @@
/** mbed Microcontroller Library
******************************************************************************
* @file lcdc_api.c
* @author
* @version V1.0.0
* @date 2019-04-19
* @brief This file provides mbed API for LCDC.
******************************************************************************
* @attention
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*
* Copyright(c) 2019, Realtek Semiconductor Corporation. All rights reserved.
******************************************************************************
*/
#ifndef MBED_LCDC_API_H
#define MBED_LCDC_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup lcdc LCDC
* @ingroup hal
* @brief lcdc functions
* @{
*/
#if ((defined (CONFIG_PLATFORM_8721D) && (CONFIG_PLATFORM_8721D == 1)))
///@name AmebaD Only
///@{
typedef struct lcdc_s lcdc_t;
/**
* @brief Initializes the LCDC peripheral.
* @param obj: lcdc object define in application software.
* @retval None
*/
void lcdc_init(lcdc_t * obj);
/**
* @brief Trigger the hardware to transfer one frame from DMA buffer based
* on sync signal.
* @param obj: lcdc object define in application software.
* @retval None
*/
void lcdc_mcu_dma_trigger(lcdc_t * obj);
/**
* @brief write data to MCU I/F bus.
* @param obj: lcdc object define in application software.
* @param Data: the data to transmit.
* @retval None
*/
void lcdc_mcu_write_data(lcdc_t * obj, u16 data);
/**
* @brief read data from MCU I/F bus.
* @param obj: lcdc object define in application software.
* @retval the read value
*/
u16 lcdc_mcu_read_data(lcdc_t * obj);
/**
* @brief write command to MCU I/F bus.
* @param obj: lcdc object define in application software.
* @param Cmd: the command to transmit.
* @retval None
*/
void lcdc_mcu_write_cmd(lcdc_t * obj, u16 cmd);
/**
* @brief Configure LCDC DMA burst size .
* @param obj: lcdc object define in application software.
* @param BurstSize: DMA burst size; Unit 64 Bytes.
* @note If BurstSize=1, the actual burstsize = 1x64 Bytes; if the BurstSize=2,
* the actual burstsize = 2x64 = 128 Bytes.... The parameter "BurstSize" is not more
* than 8.
* @retval None
*/
void lcdc_dma_burstsize_config(lcdc_t * obj, u32 BurstSize);
/**
* @brief Configure LCDC DMA under flow mode and under flow error data .
* @param obj: lcdc object define in application software.
* @param DmaUnFlwMode: DMA under flow mode, this parameter
* can be one of the following values:
* @arg LCDC_DMAUNFW_OUTPUT_LASTDATA: output last data
* @arg LCDC_DMAUNFW_OUTPUT_ERRORDATA: output error data
* @param ErrorData: the output data when DMA FIFO underflow occurred. When under flow mode is configured as
* LCDC_DMAUNFW_OUTPUT_ERRORDATA, this parameter is needed, and otherwise it can be ignored.
* @retval None
*/
void lcdc_dma_underflow_config(lcdc_t * obj, u32 DmaUnFlwMode, u32 ErrorData);
/**
* @brief Configure image base address.
* @param obj: lcdc object define in application software.
* @param ImgBaseAddr: the image base address.
* @retval None
*/
void lcdc_dma_addr_config(lcdc_t * obj, u32 ImgBaseAddr);
/**
* @brief Set lcdc interrupt handler.
* @param obj: lcdc object define in application software.
* @param func: the interrupt handler function.
* @retval None
*/
void lcdc_set_irq_handler(lcdc_t * obj, void * func);
/**
* @brief Enables or disables the specified LCDC interrupts.
* @param obj: lcdc object define in application software.
* @param LCDC_IT: specifies the LCDC interrupts sources to be enabled or disabled.
* This parameter can be any combination of the following values:
* @arg LCDC_IT_DMAUNDFW: DMA FIFO underflow interrupt
* @arg LCDC_IT_FRDN: LCD refresh done interrupt
* @arg LCDC_IT_LINE: line interrupt
* @arg LCDC_IT_IO_TIMEOUT: IO write/read timeout interrupt
* @arg LCDC_IT_FRM_START: Frame Start interrupt
* @param NewState: new state of the specified LCDC interrupts.
* This parameter can be: ENABLE or DISABLE.
* @retval None
*/
void lcdc_set_irq(lcdc_t * obj, u32 LCDC_IT, u32 NewState);
/**
* @brief Clears the LCDC's interrupt pending bits.
* @param obj: lcdc object define in application software.
* @param LCDC_IT: specifies the interrupt to be cleared.
* This parameter can be any combination of the following values:
* @arg LCDC_IT_LINE:line interrupt
* @arg LCDC_IT_FRDN: refresh frame done interrupt
* @arg LCDC_IT_DMAUNDFW: DMA FIFO under flow interrupt
* @arg LCDC_IT_IO_TIMEOUT: IO write/read timeout interrupt
* @arg LCDC_IT_FRM_START: Frame Start interrupt
* @retval None
*/
void lcdc_clear_irq(lcdc_t * obj, u32 LCDC_IT);
/**
* @brief Get lcdc interrupt status.
* @param obj: lcdc object define in application software.
* @retval interrupt status
*/
u32 lcdc_get_irq_status(lcdc_t * obj);
/**
* @brief Enables the LCDC.
* @param obj: lcdc object define in application software.
* @retval None
*/
void lcdc_enable(lcdc_t * obj);
/**
* @brief Disables the LCDC.
* @param obj: lcdc object define in application software.
* @retval None
*/
void lcdc_disable(lcdc_t * obj);
/**
* @brief Deinitializes the LCDC.
* @param obj: lcdc object define in application software.
* @note Disable LCDC instantly, clear and disable all interrupts.
* @retval None
*/
void lcdc_deinit(lcdc_t * obj);
///@}
/*\@}*/
///@}
#endif//CONFIG_PLATFORM_8721D
#ifdef __cplusplus
}
#endif
#endif/* MBED_LCDC_API_H */

View file

@ -0,0 +1,333 @@
//----------------------------------------------------------------------------//
/**
******************************************************************************
* @file log_uart_api.h
* @author
* @version
* @brief This file provides user interface for log uart
* base on the functionalities provided by Realtek periphera.
******************************************************************************
* @attention
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*
* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
******************************************************************************
*/
#ifndef LOG_UART_API_H
#define LOG_UART_API_H
#if defined(CONFIG_PLATFORM_8195A) && (CONFIG_PLATFORM_8195A == 1)
#include "device.h"
#include "serial_api.h"
#include "hal_log_uart.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup log_uart LOG_UART
* @ingroup hal
* @brief log_uart functions
* @{
*/
///@name Ameba1 Only
///@{
/******************************************************
* Type Definitions
******************************************************/
/** Log uart irq handler function pointer type
*
* @param id : The argument for log uart interrupt handler
* @param event : The log uart interrupt indication ID. More details is shown in hal_log_uart.h
*/
typedef void (*loguart_irq_handler)(uint32_t id, LOG_UART_INT_ID event);
typedef struct log_uart_s log_uart_t;
/******************************************************
* Function Declarations
******************************************************/
/**
* @brief Initialize Realtek log uart.
* Initialize the required parts of the log uart.
* i.e. baudrate, data bits, parity, etc.
* @param[in] obj: The address of log uart object.
* @param[in] baudrate: Baud rate of the log uart object.
* @param[in] data_bits: Data bits of the log uart object.
* @param[in] parity: Parity type of the log uart object
- ParityNone, - Do not use parity
- ParityOdd, - Use odd parity
- ParityEven, - Use even parity
- ParityForced1, - Use even parity, the same as ParityEven
- ParityForced0 - Use odd parity, the same as ParityOdd
* @param[in] stop_bits: The number of stop bits for the log uart object.
* @return 0 if initialization is successful, -1 otherwise
*/
int32_t log_uart_init(log_uart_t *obj, int baudrate, int data_bits, SerialParity parity, int stop_bits);
/**
* @brief Release the resources related to Realtek log uart.
* @param[in] obj: The address of log uart object.
* @return None
*/
void log_uart_free(log_uart_t *obj);
/**
* @brief Set the baud rate of log uart.
* @param[in] obj: The address of log uart object.
* @param[in] baudrate: Baud rate of the log uart object.
* @return None
*/
void log_uart_baud(log_uart_t *obj, int baudrate);
/**
* @brief Set parameters for log uart.
* including data bits, parity type and stop bits
* @param[in] obj: The address of log uart object.
* @param[in] data_bits: Data bits of log uart object.
* @param[in] parity: Parity type of the log uart object
- ParityNone, - Do not use parity
- ParityOdd, - Use odd parity
- ParityEven, - Use even parity
- ParityForced1, - Use even parity, the same as ParityEven
- ParityForced0 - Use odd parity, the same as ParityOdd
* @param[in] stop_bits: The number of stop bits for the log uart object.
* @return None
*/
void log_uart_format(log_uart_t *obj, int data_bits, SerialParity parity, int stop_bits);
/**
* @brief Set irq handler for log uart.
* @param[in] obj: The address of log uart object.
* @param[in] handler: The interrupt handler for log uart.
* @param[in] id: The argument for log uart interrupt handler.
* @return None
*/
void log_uart_irq_handler(log_uart_t *obj, loguart_irq_handler handler, uint32_t id);
/**
* @brief Enable/disable the specific irq indication ID.
* @param[in] obj: The address of log uart object.
* @param[in] irq: The log uart interrupt indication ID which will be enabled/disabled.
* @param[in] enable: 1 enable, 0 disable
* @return None
*/
void log_uart_irq_set(log_uart_t *obj, LOG_UART_INT_ID irq, uint32_t enable);
/**
* @brief Read one character from log uart.
This function will block untill the log uart gets something to read
* @param[in] obj: The address of log uart object.
* @return the character read from log uart
*/
char log_uart_getc(log_uart_t *obj);
/**
* @brief Write one character to log uart.
This function will block untill the data is successfully written to log uart
* @param[in] obj: The address of log uart object.
* @param[in] c: The one byte data to be written to log uart.
* @return None
*/
void log_uart_putc(log_uart_t *obj, char c);
/**
* @brief Check whether log uart is ready to read data
* @param[in] obj: The address of log uart object.
* @return 1 if there is data at log uart to be read, 0 otherwise
*/
int log_uart_readable(log_uart_t *obj);
/**
* @brief Check whether log uart is ready to write data
* @param[in] obj: The address of log uart object.
* @return 1 if log uart is ready for writing, 0 otherwise
*/
int log_uart_writable(log_uart_t *obj);
/**
* @brief Clear both data at log uart
This function will clear data in both TX FIFO and RX FIFO of log uart
* @param[in] obj: The address of log uart object.
* @return None
*/
void log_uart_clear(log_uart_t *obj);
/**
* @brief Clear TX FIFO of log uart
* @param[in] obj: The address of log uart object.
* @return None
*/
void log_uart_clear_tx(log_uart_t *obj);
/**
* @brief Clear RX FIFO of log uart
* @param[in] obj: The address of log uart object.
* @return None
*/
void log_uart_clear_rx(log_uart_t *obj);
/**
* @brief Set break control for log uart
* @param[in] obj: The address of log uart object.
* @return None
*/
void log_uart_break_set(log_uart_t *obj);
/**
* @brief Clear break control for log uart
* @param[in] obj: The address of log uart object.
* @return None
*/
void log_uart_break_clear(log_uart_t *obj);
/**
* @brief Set the handler for complete TX
* @param[in] obj: The address of log uart object.
* @param[in] handler: The function which is called when log uart has finished transmitting data.
* @param[in] id: The parameter for handler.
* @return None
*/
void log_uart_tx_comp_handler(log_uart_t *obj, void *handler, uint32_t id);
/**
* @brief Set the handler for complete RX
* @param[in] obj: The address of log uart object.
* @param[in] handler: The function which is called when log uart has finished receving data
* @param[in] id: The parameter for handler.
* @return None
*/
void log_uart_rx_comp_handler(log_uart_t *obj, void *handler, uint32_t id);
/**
* @brief Set the handler for line status
* @param[in] obj: The address of log uart object.
* @param[in] handler: The function which is called when log uart gets an line status indication ID.
* @param[in] id: The parameter for handler.
* @return None
*/
void log_uart_line_status_handler(log_uart_t *obj, void *handler, uint32_t id);
/**
* @brief Read data from log uart in blocking mode.
* @param[in] obj: The address of log uart object.
* @param[out] prxbuf: The buffer to store received data.
* @param[in] len: The maximum length of data to be read
* @param[in] timeout_ms: Blocking time in ms.
* @return the length of received data in bytes
*/
int32_t log_uart_recv(log_uart_t *obj, char *prxbuf, uint32_t len, uint32_t timeout_ms);
/**
* @brief Send data to log uart in blocking mode
* @param[in] obj: The address of log uart object.
* @param[in] ptxbuf: Data buffer to be sent to log uart
* @param[in] len: Length of data to be sent to log uart
* @param[in] timeout_ms: Blocking time in ms.
* @return the length of sent data in bytes
*/
int32_t log_uart_send(log_uart_t *obj, char *ptxbuf, uint32_t len, uint32_t timeout_ms);
/**
* @brief Read data from log uart in interrupt mode(Non-blocking)
* @param[in] obj: The address of log uart object.
* @param[out] prxbuf: The buffer to store received data.
* @param[in] len: The maximum length of data to be read
* @return 0 if success
*/
int32_t log_uart_recv_stream(log_uart_t *obj, char *prxbuf, uint32_t len);
/**
* @brief Send data to log uart in interrupt mode(Non-blocking)
* @param[in] obj: The address of log uart object.
* @param[in] ptxbuf: Data buffer to be sent to log uart
* @param[in] len: Length of data to be sent to log uart
* @return 0 if success
*/
int32_t log_uart_send_stream(log_uart_t *obj, char *ptxbuf, uint32_t len);
/**
* @brief Read data from log uart with a given timeout in interrupt mode(Non-blocking)
* @param[in] obj: The address of log uart object.
* @param[out] prxbuf: The buffer to store received data.
* @param[in] len: The maximum length of data to be read
* @param[in] timeout_ms: The timeout for reading data in ms
* @param[in] force_cs: User callback function
* @return the length in Byte of received data before timeout, or error (< 0)
*/
int32_t log_uart_recv_stream_timeout(log_uart_t *obj, char *prxbuf, uint32_t len,
uint32_t timeout_ms, void *force_cs);
/**
* @brief Abort interrupt mode of sending data
* @param[in] obj: The address of log uart object.
* @return the length of data sent to log uart.
*/
int32_t log_uart_send_stream_abort(log_uart_t *obj);
/**
* @brief Abort interrupt mode of receiving data
* @param[in] obj: The address of log uart object.
* @return the length of data received from log uart.
*/
int32_t log_uart_recv_stream_abort(log_uart_t *obj);
/**
* @brief Disable log uart
* @param[in] obj: The address of log uart object.
* @return None.
*/
void log_uart_disable(log_uart_t *obj);
/**
* @brief Enable log uart
* @param[in] obj: The address of log uart object.
* @return None.
*/
void log_uart_enable(log_uart_t *obj);
/**
* @brief Read Line-Status register
* @return value:
* - Bit 0: RX Data Ready
* - Bit 1: Overrun Error
* - Bit 2: Parity Error
* - Bit 3: Framing Error
* - Bit 4: Break Interrupt (received data input is held in 0 state for a longer than a full word tx time)
* - Bit 5: TX FIFO empty (THR empty)
* - Bit 6: TX FIFO empty (THR & TSR both empty)
* - Bit 7: Receiver FIFO Error (parity error, framing error or break indication)
*/
uint8_t log_uart_raed_lsr(log_uart_t *obj);
/**
* @brief Read Modem-Status register
* @return value:
* - Bit 0: DCTS, The CTS line has changed its state
* - Bit 1: DDSR, The DSR line has changed its state
* - Bit 2: TERI, RI line has changed its state from low to high state
* - Bit 3: DDCD, DCD line has changed its state
* - Bit 4: Complement of the CTS input
* - Bit 5: Complement of the DSR input
* - Bit 6: Complement of the RI input
* - Bit 7: Complement of the DCD input
*/
uint8_t log_uart_raed_msr(log_uart_t *obj);
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif //CONFIG_PLATFORM_8195A
#endif // end of "#ifndef LOG_UART_API_H"

View file

@ -0,0 +1,65 @@
/* mbed Microcontroller Library
*******************************************************************************
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************
*/
#ifndef MBED_NFC_API_H
#define MBED_NFC_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
#define NFCTAGLENGTH 36 // maximum 36*4=144 bytes
#define NFC_MAX_CACHE_PAGE_NUM 36 // maximum 36*4=144 bytes
typedef enum _NFC_STATUS_ {
NFC_OK = 0,
NFC_ERROR = -1
}NFC_STATUS, *PNFC_STATUS;
typedef enum _NFC_PWR_STATUS_ {
NFC_PWR_DISABLE = 0,
NFC_PWR_RUNNING = 1,
NFC_PWR_SLEEP0 = 2,
NFC_PWR_SLEEP1 = 3,
NFC_PWR_DOWN = 4,
NFC_PWR_ERROR = -1
}NFC_PWR_STATUS, *PNFC_PWR_STATUS;
typedef enum _NFC_EVENT_ {
NFC_EV_READER_PRESENT = (1<<0),
NFC_EV_READ = (1<<1),
NFC_EV_WRITE = (1<<2),
NFC_EV_ERR = (1<<3),
NFC_EV_CACHE_READ = (1<<4)
}NFC_EVENT, *PNFC_EVENT;
typedef struct nfctag_s nfctag_t;
typedef void (*nfc_read_cb)(void *arg, void *buf, unsigned int page);
typedef void(*nfc_write_cb)(void *arg, unsigned int page, uint32_t pgdat);
typedef void(*nfc_event_cb)(void *arg, unsigned int event);
typedef void(*nfc_cache_read_cb)(void *arg, void *buf, unsigned int page);
int nfc_init(nfctag_t *obj, uint32_t *pg_init_val);
void nfc_read(nfctag_t *obj, nfc_read_cb handler, void *arg);
void nfc_write(nfctag_t *obj, nfc_write_cb handler, void *arg);
void nfc_event(nfctag_t *obj, nfc_event_cb handler, void *arg, unsigned int event_mask);
int nfc_power(nfctag_t *obj, int pwr_mode, int wake_event);
int nfc_cache_write(nfctag_t *obj, uint32_t *tbuf, unsigned int spage, unsigned int pg_num);
int nfc_cache_raed(nfctag_t *obj, nfc_cache_read_cb handler, void *arg, unsigned int start_pg);
int nfc_status(nfctag_t *obj);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,458 @@
/** mbed Microcontroller Library
******************************************************************************
* @file pcm_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed I2S API
******************************************************************************
* @attention
*
* 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_EXT_PCM_API_EXT_H
#define MBED_EXT_PCM_API_EXT_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup pcm PCM
* @ingroup hal
* @brief pcm functions
* @{
*/
typedef enum {
U_LAW = PCM_U_LAW,
A_LAW = PCM_A_LAW
} pcm_ua_law;
typedef enum {
CH0 = PCM_CH0,
CH1 = PCM_CH1,
CH2 = PCM_CH2,
CH3 = PCM_CH3,
CH4 = PCM_CH4,
CH5 = PCM_CH5,
CH6 = PCM_CH6,
CH7 = PCM_CH7,
CH8 = PCM_CH8,
CH9 = PCM_CH9,
CH10 = PCM_CH10,
CH11 = PCM_CH11,
CH12 = PCM_CH12,
CH13 = PCM_CH13,
CH14 = PCM_CH14,
CH15 = PCM_CH15
} pcm_ch;
typedef enum {
SLOT0 = PCM_SLOT0,
SLOT1 = PCM_SLOT1,
SLOT2 = PCM_SLOT2,
SLOT3 = PCM_SLOT3,
SLOT4 = PCM_SLOT4,
SLOT5 = PCM_SLOT5,
SLOT6 = PCM_SLOT6,
SLOT7 = PCM_SLOT7,
SLOT8 = PCM_SLOT8,
SLOT9 = PCM_SLOT9,
SLOT10 = PCM_SLOT10,
SLOT11 = PCM_SLOT11,
SLOT12 = PCM_SLOT12,
SLOT13 = PCM_SLOT13,
SLOT14 = PCM_SLOT14,
SLOT15 = PCM_SLOT15,
SLOT16 = PCM_SLOT16,
SLOT17 = PCM_SLOT17,
SLOT18 = PCM_SLOT18,
SLOT19 = PCM_SLOT19,
SLOT20 = PCM_SLOT20,
SLOT21 = PCM_SLOT21,
SLOT22 = PCM_SLOT22,
SLOT23 = PCM_SLOT23,
SLOT24 = PCM_SLOT24,
SLOT25 = PCM_SLOT25,
SLOT26 = PCM_SLOT26,
SLOT27 = PCM_SLOT27,
SLOT28 = PCM_SLOT28,
SLOT29 = PCM_SLOT29,
SLOT30 = PCM_SLOT30,
SLOT31 = PCM_SLOT31
} pcm_slot;
typedef enum {
PCM_MASTER = PCM_MASTER_MODE,
PCM_SLAVE = PCM_SLAVE_MODE
} pcm_ms_mode;
typedef enum {
FRAME_HIGH_ACTIVE = PCM_FRAME_HIGH_ACTIVE,
FRAME_LOW_ACTIVE = PCM_FRAME_LOW_ACTIVE
} pcm_frame_active;
typedef enum {
COMPENDER_MODE = PCM_COMPENDER_MODE,
LINEAR_MODE = PCM_LINEAR_MODE
} pcm_mode;
typedef enum {
PCM_LOOPBACK_DIS = PCM_LOOPBACK_DISABLE,
PCM_LOOPBACK_EN = PCM_LOOPBACK_ENABLE
} pcm_loopback_mode;
typedef enum {
ENDIANSWAP_DISABLE = PCM_ENDIANSWAP_DISABLE,
ENDIANSWAP_ENABLE = PCM_ENDIANSWAP_ENABLE
} pcm_endian_swap;
typedef enum {
PCM_PAGE0 = 0,
PCM_PAGE1 = 1
} pcm_page;
typedef void (*pcm_irq_handler)(void *data, u16 *pbuf);
typedef struct pcm_s pcm_t;
/**
* @brief Initializes the PCM device, include clock/function/interrupt/PCM registers.
* @param obj: PCM object define in application software.
* @param sync: Fram sync PinName according to pinmux spec.
* @param clk: Clock PinName according to pinmux spec.
* @param out: Tx PinName according to pinmux spec.
* @param in: Rx PinName according to pinmux spec.
* @retval none
*/
void pcm_init(pcm_t *obj, PinName sync, PinName clk, PinName out, PinName in);
/**
* @brief Set tx interrupt handler according to channel
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @param handler: User defined IRQ callback function.
* @retval none
*/
void pcm_tx_irq_handler(pcm_t *obj, pcm_ch chan, pcm_irq_handler handler);
/**
* @brief Set rx interrupt handler according to channel
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @param handler: User defined IRQ callback function.
* @retval none
*/
void pcm_rx_irq_handler(pcm_t *obj, pcm_ch chan, pcm_irq_handler handler);
/**
* @brief Set the PCM format and parameters.
* @param obj: PCM object define in application software.
* @param ms_mode: Set master or slave mode
* @param linear_mode: Set linear or compender mode. when choose the compender mode, need to set A-law or U-law.
* @param loop_back: Use lookback mode.
* @param endian_swap: Use endian swap.
* @param fs_inv: Set frame sync is the high or low active.
* @retval none
*/
void pcm_set_format(pcm_t *obj, pcm_ms_mode ms_mode, pcm_mode linear_mode, pcm_loopback_mode loop_back, pcm_endian_swap endian_swap, pcm_frame_active fs_inv);
/**
* @brief Set the buffer address
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @param tx_buf: Set the address of tx buffer. Need 4-byte aligned.
* @param rx_buf: Set the address of rx buffer. Need 4-byte aligned.
* @retval none
*/
void pcm_set_dma_buffer(pcm_t *obj, pcm_ch chan, u16 *tx_buf, u16 *rx_buf);
/**
* @brief Control the tx and rx enable by the channel.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @param tx_en: To enable or disable.
* @param rx_en: To enable or disable.
* @retval none
*/
void pcm_chan_trx_ctrl(pcm_t *obj, pcm_ch chan, BOOL tx_en, BOOL rx_en);
/**
* @brief Set the page size of the channel.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @param page_size: Need the even number 2~512, page units: 2 bytes
* @retval none
*/
void pcm_chan_page_size(pcm_t *obj, pcm_ch chan, u32 page_size);
/**
* @brief Set the time slot of the channel. If configured as 16 bit linear mode, only even number time slot is allowed.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @param slot: Set the time slot, 0~31.
* @retval none
*/
void pcm_chan_time_slot(pcm_t *obj, pcm_ch chan, pcm_slot slot);
/**
* @brief Set the time slot for the wideband. If configured as 16 bit linear mode, only even number time slot is allowed.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel. The channel is only valid for CH0~CH7.
* @param wband_en: To enable or disable.
* @param wtsa: Set the time slot, SLOT0~SLOT31.
* @retval none
*/
void pcm_chan_wideband(pcm_t *obj, pcm_ch chan, BOOL wband_en, pcm_slot wtsa);
/**
* @brief Set U-law or A-law in the compender mode.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @param ua_law: Set U-law or A-law.
* @arg U_LAW: U-law.
* @arg A_LAW: A-law.
* @retval none
*/
void pcm_chan_compender_law(pcm_t *obj, pcm_ch chan, pcm_ua_law ua_law);
/**
* @brief Reset all channel setting and state machine.
* @param obj: PCM object define in application software.
* @retval none
*/
void pcm_reset(pcm_t *obj);
/**
* @brief Clear interrupt status for all channels.
* @param obj: PCM object define in application software.
* @retval none
*/
void pcm_clear_all_Intr(pcm_t *obj);
/**
* @brief Disable interrupt for all channels.
* @param obj: PCM object define in application software.
* @retval none
*/
void pcm_disable_all_Intr(pcm_t *obj);
/**
* @brief Reset all logic and registers to initial state. Gate PCM Clock.
* @param obj: PCM object define in application software.
* @retval none
*/
void pcm_disable(pcm_t *obj);
/**
* @brief Enable PCM and Clock
* @param obj: PCM object define in application software.
* @retval none
*/
void pcm_enable(pcm_t *obj);
/**
* @brief Deinitializes the PCM device, include function/interrupt/PCM registers.
* @param obj: PCM object define in application software.
* @retval none
*/
void pcm_deinit(pcm_t *obj);
/**
* @brief Start the transmission for all enabled channels.
* @param obj: PCM object define in application software.
* @retval none
*/
void pcm_start_trx(pcm_t *obj);
/**
* @brief Start this tx channel. This channel needs to enable first by pcm_chan_trx_ctrl.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @retval none
*/
void pcm_start_tx_chan(pcm_t *obj, pcm_ch chan);
/**
* @brief Start this rx channel. This channel needs to enable first by pcm_chan_trx_ctrl.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @retval none
*/
void pcm_start_rx_chan(pcm_t *obj, pcm_ch chan);
/**
* @brief Stop the transmission for all channels.
* @param obj: PCM object define in application software.
* @retval none
*/
void pcm_stop_trx_all_chan(pcm_t *obj);
/**
* @brief Stop the tx transmission for all channels.
* @param obj: PCM object define in application software.
* @retval none
*/
void pcm_stop_tx_all_chan(pcm_t *obj);
/**
* @brief Stop the rx transmission for all channels.
* @param obj: PCM object define in application software.
* @retval none
*/
void pcm_stop_rx_all_chan(pcm_t *obj);
/**
* @brief Stop the tx transmission for this channel.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @retval none
*/
void pcm_stop_tx_chan(pcm_t *obj, pcm_ch chan);
/**
* @brief Stop the rx transmission for this channel.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @retval none
*/
void pcm_stop_rx_chan(pcm_t *obj, pcm_ch chan);
/**
* @brief Get the next address to be processed.
* This function needs in the interrupt handler.
* @param obj: PCM object define in application software.
* @retval none
*/
u8 *pcm_irq_get_tx_next_page_adr(pcm_t *obj);
/**
* @brief Inform PCM the tx page data is ready.
* This function needs in the interrupt handler.
* @param obj: PCM object define in application software.
* @retval none
*/
void pcm_irq_set_txpage(pcm_t *obj);
/**
* @brief Inform PCM that finish receiving the rx page data.
* This function needs in the interrupt handler.
* @param obj: PCM object define in application software.
* @retval none
*/
void pcm_irq_set_rxpage(pcm_t *obj);
/**
* @brief Get the processing channel number in the interrupt handler.
* This function needs in the interrupt handler.
* @param obj: PCM object define in application software.
* @retval none
*/
u8 pcm_irq_get_channel(pcm_t *obj);
/**
* @brief Get the buffer size of the processing channel in the interrupt handler.
* This function needs in the interrupt handler.
* @param obj: PCM object define in application software.
* @retval none
*/
u32 pcm_irq_get_buffer_size(pcm_t *obj);
/**
* @brief Get the the page number of the processing channel in the interrupt handler.
* This function needs in the interrupt handler.
* @param obj: PCM object define in application software.
* @retval none
*/
u8 pcm_irq_get_page_0_or_1(pcm_t *obj);
/**
* @brief Get the next address of the channel to be processed.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @retval none
*/
u8 *pcm_get_tx_next_page_adr(pcm_t *obj, pcm_ch chan);
/**
* @brief Inform PCM the tx page data of the channel is ready.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @retval none
*/
void pcm_set_txpage(pcm_t *obj, pcm_ch chan);
/**
* @brief Inform PCM that finish receiving the rx page data of the channel.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @retval none
*/
void pcm_set_rxpage(pcm_t *obj, pcm_ch chan);
/**
* @brief Get the buffer size of the channel.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @retval none
*/
u32 pcm_get_buffer_size(pcm_t *obj, pcm_ch chan);
/**
* @brief Get the address of the tx page0 data.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @retval none
*/
u32 pcm_get_tx_page0_adr(pcm_t *obj, pcm_ch chan);
/**
* @brief Get the address of the tx page1 data.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @retval none
*/
u32 pcm_get_tx_page1_adr(pcm_t *obj, pcm_ch chan);
/**
* @brief Get the address of the rx page0 data.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @retval none
*/
u32 pcm_get_rx_page0_adr(pcm_t *obj, pcm_ch chan);
/**
* @brief Get the address of the rx page1 data.
* @param obj: PCM object define in application software.
* @param chan: Set the PCM channel, CH0 ~ CH15.
* @retval none
*/
u32 pcm_get_rx_page1_adr(pcm_t *obj, pcm_ch chan);
///@}
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,253 @@
/*******************************************************************************
* Copyright (c) 2014, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
*******************************************************************************/
#ifndef MBED_EXT_POWER_MODE_API_EXT_H
#define MBED_EXT_POWER_MODE_API_EXT_H
#if (defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)) || (defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1)) || (defined(CONFIG_PLATFORM_8710C) && (CONFIG_PLATFORM_8710C == 1))
///@name AmebaPro Only
///@{
#include "device.h"
#if defined (CONFIG_PLATFORM_8195B)
/** @addtogroup power mode POWER MODE
* @ingroup hal
* @brief power mode functions
* @{
*/
#if defined (CONFIG_PLATFORM_8195BLP)
//SLP
#define SLP_STIMER BIT0
#define SLP_GTIMER BIT1
#define SLP_GPIO BIT2
#define SLP_PWM BIT3
#define SLP_UART BIT4
#define SLP_HSTIMER BIT5
#define SLP_WLAN BIT6
#define SLP_I2C BIT7
#define SLP_ADC BIT8
#define SLP_COMP BIT9
#define SLP_SGPIO BIT10
//DSTBY
#define DSTBY_STIMER BIT0
#define DSTBY_GTIMER BIT1
#define DSTBY_GPIO BIT2
#define DSTBY_PWM BIT3
#define DSTBY_UART BIT4
#define DSTBY_HSTIMER BIT5
#define DSTBY_WLAN BIT6
#define DSTBY_I2C BIT7
#define DSTBY_ADC BIT8
#define DSTBY_COMP BIT9
#define DSTBY_SGPIO BIT10
//DS wake event
#define DS_STIMER BIT0
#define DS_GPIO BIT1
#define DS_ADP BIT2
#define DS_RTC BIT3
#elif defined (CONFIG_PLATFORM_8195BHP)
//SLP
#define SLP_GTIMER BIT1
#define SLP_GPIO BIT2
#define SLP_PWM BIT3
#define SLP_UART BIT4
#define SLP_MII BIT5
#define SLP_WLAN BIT6
#define SLP_I2C BIT7
#define SLP_ADC BIT8
#define SLP_USB BIT9
#define SLP_SGPIO BIT10
#define SLP_SDIO BIT11
//DSTBY
#define DSTBY_GTIMER BIT1
#define DSTBY_GPIO BIT2
#endif
///@name Ameba Common
///@{
enum {
AON_128K = CLK_128K, // AON CLK 128kHz
AON_100K = CLK_100K, // AON CLK 100kHz
};
/**
* @brief The function for ls sleep mode.
*
* @param[in] Option, To slect AON Timer,GPIO...etc
* - bit[4]: the UART Wake up event.
* - bit[3]: the PWM Wake up event.
* - bit[2]: the GPIO A13 as a Wake up event.
* - bit[1]: the GTimer Wake up event. Only active at 128kHz
* - bit[0]: the AON Timer Wake up event.
* @param[in] SDuration, wake up after SDuration value. Uint: us
* @param[in] Clock, 1: 100kHz, 0: 128kHz.
* @param[in] GpioOption, GPIOA0~A13 as a wake up trigger.
*
* @returns void
*/
void SleepCG (u16 Option, u32 SDuration, u8 Clock, u8 GpioOption);
#if defined (CONFIG_PLATFORM_8195BHP)
/**
* @brief The function for hs power gated.
*
* @param[in] Option, To slect HS Timer and GPIO
* - bit[2]: the GPIO Wake up event.
* - bit[1]: the GTimer Wake up event.
* @param[in] SDuration, wake up after SDuration value. Uint: us
* @param[in] Memsel, 1: Enable memory, 0: Disable memory.
* @param[in] GpioOption, Select GPIO pin as a wake up trigger.
*
* @returns void
*/
void SleepPG (u16 Option, u32 SDuration, u8 Memsel, u8 GpioOption);
#endif
#if defined (CONFIG_PLATFORM_8195BLP)
/**
* @brief The function for ls standby mode.
*
* @param[in] Option, To slect AON Timer,GPIO...etc
* - bit[4]: the UART Wake up event.
* - bit[3]: the PWM Wake up event.
* - bit[2]: the GPIO Wake up event.
* - bit[1]: the GTimer Wake up event. Not ready
* - bit[0]: the AON Timer Wake up event.
* @param[in] SDuration, wake up after SDuration value(Max:8300 sec). Uint: us
* @param[in] Memsel, 1: Enable memory, 0: Disable memory.
* @param[in] GpioOption, GPIOA0~A13 as a wake up trigger.
*
* @returns void
*/
void Standby (u16 Option, u64 SDuration, u8 Memsel, u8 GpioOption);
/**
* @brief The stubs functions table to exports POWER MODE HAL functions in ROM.
*/
//extern const hal_power_mode_func_stubs_t hal_power_mode_stubs;
/**
* @brief The function for ls deep sleep mode.
*
* @param[in] Option, To slect AON Timer,GPIO,ADP and RTC.
* - bit[3]: the ADP Wake up event.
* - bit[2]: the GPIO A13 Rising Wake up event.
* - bit[1]: the GPIO A13 Falling Wake up event.
* - bit[0]: the AON Timer Wake up event.
* @param[in] SDuration, wake up after SDuration value(Max:8300 sec). Uint: us
* @param[in] Memsel, 1: Enable memory, 0: Disable memory.
* @param[in] Clock, 1: 100kHz, 0: 128kHz.
*
* @returns void
*/
void DeepSleep (u8 Option, u64 SDuration, u8 Memsel, u8 Clock);
/**
* @brief The function for ls deep sleep mode.
*
* @param[in] Option The RTC wake up event.
* - bit[3]: Wake up per day.
* - bit[2]: Wake up per hour.
* - bit[1]: Wake up per minute.
* - bit[0]: Wake up per second.
* @param[in] Memsel, 1: Enable memory, 0: Disable memory.
*
* @returns void
*/
void DeepSleep_RTC (u8 Option, u8 Memsel);
///@}
/*\@}*/
#endif
#endif
///@}
#if defined(CONFIG_PLATFORM_8710C)
//DS wake event
#define DS_STIMER BIT0
#define DS_GPIO BIT1
//SLP
#define SLP_STIMER BIT0
#define SLP_GTIMER BIT1
#define SLP_GPIO BIT2
#define SLP_PWM BIT3
#define SLP_UART BIT4
#define SLP_WLAN BIT6
#define SLP_SDIO BIT11
//DSTBY
#define DSTBY_STIMER BIT0
#define DSTBY_GTIMER BIT1
#define DSTBY_GPIO BIT2
enum {
AON_250K = 0, // AON CLK 250kHz
AON_4M = 1, // AON CLK 4MHz
};
/**
* @brief The function for ls deep sleep mode.
*
* @param[in] Option, To slect AON Timer and GPIO.
* - bit[1]: the GPIO as a Wake up event.
* - bit[0]: the LP Timer Wake up event.
* @param[in] SDuration, wake up after SDuration value. Uint: us
* @param[in] Clock, 1: 4MHz, 0: 250kHz.
*
* @returns void
*/
void DeepSleep (u8 Option, u32 SDuration, u8 Clock);
/**
* @brief The function for sleep mode.
*
* @param[in] Option, To slect GTimer, GPIO and PWM...etc
* - bit[4]: the UART Wake up event.
* - bit[3]: the PWM Wake up event.
* - bit[2]: the GPIO Wake up event.
* - bit[1]: the GTimer Wake up event.
* - bit[0]: the LP Timer Wake up event.
* @param[in] SDuration, wake up after SDuration value. Uint: us
* @param[in] Clock, 1: 4MHz, 0: 250kHz.
* @param[in] GpioOption, Select GPIO pin as a wake up trigger.
*
* @returns void
*/
void SleepCG (u16 Option, u32 SDuration, u8 Clock, u8 GpioOption);
/**
* @brief The function for Standby mode.
*
* @param[in] Option, To slect GTimer, GPIO and PWM...etc
* - bit[4]: the UART Wake up event.
* - bit[3]: the PWM Wake up event.
* - bit[2]: the GPIO Wake up event.
* - bit[1]: the GTimer Wake up event.
* - bit[0]: the LP Timer Wake up event.
* @param[in] SDuration, wake up after SDuration value. Uint: us
* @param[in] Clock, 1: 4MHz, 0: 250kHz.
* @param[in] GpioOption, Select GPIO pin as a wake up trigger.
*
* @returns void
*/
void Standby (u16 Option, u32 SDuration, u8 Clock, u8 GpioOption);
#endif
#endif // end of "#if (defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)) || (defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1)) || (defined(CONFIG_PLATFORM_8710C) && (CONFIG_PLATFORM_8710C == 1))"
#endif

View file

@ -0,0 +1,156 @@
/** mbed Microcontroller Library
******************************************************************************
* @file pwmout_ex_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed pwm API
******************************************************************************
* @attention
*
* 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_EX_API_H
#define MBED_PWMOUT_EX_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup pwm PWM
* @ingroup hal
* @brief pwm functions
* @{
*/
///@name Ameba Common
///@{
#if !defined(CONFIG_PLATFORM_8710C)
typedef void (*pwm_lim_callback_t) (void *, u8 dir);
typedef void (*pwm_period_callback_t) (void *);
#endif
/**
* @brief Set the start timing offset of the specified channel in seconds.
* @param obj: PWM object define in application software.
* @param seconds: The period value to be set in seconds.
* @retval none
*/
void pwmout_startoffset(pwmout_t *obj, float seconds);
/**
* @brief Set the start timing offset of the specified channel in millseconds.
* @param obj: PWM object define in application software.
* @param ms: The period value to be set in millseconds.
* @retval none
*/
void pwmout_startoffset_ms(pwmout_t *obj, int ms);
/**
* @brief Set the start timing offset of the specified channel in microseconds.
* @param obj: PWM object define in application software.
* @param us: The period value to be set in microseconds.
* @retval none
*/
void pwmout_startoffset_us(pwmout_t *obj, int us);
//typedef struct pwmout_s pwmout_t;
/**
* @brief To enable the PWM period end interrupt.
*
* @param obj: PWM object define in application software.
* @param callback The callback function. It will be called when the interrupt is accurred.
* @param arg The argument of the callback function.
* @param enable To enable(1) or disable(0) the interrupt. For interrupt disable, the arguments
* 'callback' & 'arg' are ignored.
* @returns void
*/
void pwmout_period_int(pwmout_t *obj, pwm_period_callback_t callback, u8 enable);
/**
* @brief To setup the PWM duty auto adjustment interrupt.
*
* @param obj: PWM object define in application software.
* @param callback The callback function. It will be called when the interrupt is accurred.
* @param direction The bit map to enable/disable the interrupt. Bit 1 control the interrupt of duty duration
* reachs the up limit. Bit 0 control the interrupt of duty duration reachs the down limit.
* @param enable To enable(1) or disable(0) the interrupt. For interrupt disable, the arguments
* 'callback' & 'arg' are ignored.
*
* @returns void
*/
void pwmout_autoadj_int (pwmout_t *obj, pwm_lim_callback_t callback, u8 direction, u8 enable);
/**
* @brief To start the PWM duty auto-adjustment for duty duration increasing.
*
* @param obj: PWM object define in application software.
* @param max_duty_us The up limit of the duty duration, in us.
* @param step_sz_us The step size of each duty duration increasing, in us.
* @param step_period_cnt The stay time of each duty duration increasing step, uint is PWM period.
*
* @returns The result.
*/
void pwmout_autoadj_inc(pwmout_t *obj, u32 max_duty_us, u32 step_sz_us, u32 step_period_cnt);
/**
* @brief To start the PWM duty auto-adjustment for duty duration decreasing.
*
* @param obj: PWM object define in application software.
* @param min_duty_us The up limit of the duty duration, in us.
* @param step_sz_us The step size of each duty duration increasing, in us.
* @param step_period_cnt The stay time of each duty duration increasing step, uint is PWM period.
*
* @returns The result.
*/
void pwmout_autoadj_dec(pwmout_t *obj, u32 min_duty_us, u32 step_sz_us, u32 step_period_cnt);
/**
* @brief To Eable the PWM function.
* @param obj: PWM object define in application software.
*
* @returns void
*/
void pwmout_start(pwmout_t *obj);
/**
* @brief To Disable the PWM function.
* @param obj: PWM object define in application software.
*
* @returns void
*/
void pwmout_stop(pwmout_t *obj);
/**
* @brief Eable the Multible PWM function/registers of the specified pin with default parameters in same time.
* @param pin_ctrl: the pinname of specified channel to be set. Bit 0 control the PWM0. Bit 1 control the PWM1.
* Bit 2 control the PWM2...etc
*
* @returns void
*/
void pwmout_multi_start(u8 pin_ctrl);
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,406 @@
/** mbed Microcontroller Library
******************************************************************************
* @file qdec_api.h
* @author
* @version V1.0.0
* @brief
******************************************************************************
* @attention
*
* 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_EXT_QDEC_API_EXT_H
#define MBED_EXT_QDEC_API_EXT_H
#if defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)
///@name AmebaPro Only
///@{
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup qdec QDEC
* @ingroup hal
* @brief qdec functions
* @{
*/
typedef enum {
QDEC_SClk_2M = QdecSClk_2M,
QDEC_SClk_32K = QdecSClk_32K,
QDEC_SClk_MAXID = QdecSClk_MAXID
} qdec_clk_source;
typedef enum {
ONE_PHASE_COUNT = One_Phase,
TWO_PHASE_COUNT = Two_Phase
} qdec_resolution;
typedef enum {
REF_INDEX = Index_Event,
PC_OVER_UNDER_FLOW = PC_Over_Or_Under_Flow
} qdec_rotation_source;
typedef enum {
INPUT_INIT_LOW = Input_Low,
INPUT_INIT_HIGH = Input_High
} qdec_index_level;
typedef enum {
INDEX_NO_RST = Disable_Rst,
INDEX_RST_1ST = Reset_1st_Index,
INDEX_RST_ALWAYS = Reset_Every_Index
} qdec_index_rst;
typedef enum {
PC_CHANGE_1_CNT = Pos_Chg1,
PC_CHANGE_2_CNT = Pos_Chg2,
PC_CHANGE_4_CNT = Pos_Chg4
} qdec_cnt_chg;
typedef enum {
CAL_PC_ABSOLUTE_CNT = Absolute_Count,
CAL_PC_NOT_ABSOLUTE_CNT = Not_Absolute_Count
} qdec_vmuc_mode;
typedef struct qdec_def_setting_s {
u8 smp_div; /*!< Sampling Clock = source clock/(smp_div+1). Value: 0 ~ 31. */
qdec_resolution resolution; /*!< The position accumulation counter. 0: 1 phase, 1: 2 phases. Only phase A edges are counted. */
u16 pc_maximum; /*!< The maximum value of the position counter. Value: 0 ~ 65535. */
qdec_rotation_source rotation_mode; /*!< 0: accumulate the rotation number when the index event occurres with direction(+/-), 1: accumulate the rotation number when the position counter occurres overflow(+)/underflow(-). */
BOOL filter_enable; /*!< 0: disable de-bounce. 1: enable de-bounce. */
u16 filter_time; /*!< De-bounce timer configuration, Value: 0 ~ 2047, unit is sclk: 0.5us or 31.25us. The time needs a little bigger than the maximum period of noise. */
BOOL index_enable; /*!< 0: The index pulse signal detection is disabled. 1: enable. */
qdec_index_level index_level; /*!< 0: The index input is low. 1: The index input is lhigh. */
qdec_index_rst index_rst; /*!< The index input can reset the position counter. 0: disable, 1: only reset 1st, 2: reset every index. */
} qdec_def_setting_t, *pqdec_def_setting_t;
typedef void (*qdec_irq_handler)(void *);
typedef struct qdec_s qdec_t;
/**
* @brief Initializes the QDEC device, include clock/function/interrupt/QDEC registers.
* @param obj: QDEC object define in application software.
* @param pha: PHA PinName according to pinmux spec.
* @param phb: PHB PinName according to pinmux spec.
* @param idx: IDX PinName according to pinmux spec. This pin is not configured when set PinName "NC".
* @param source_clk: The clock source of the quadrature decoder.
* @arg 0 : 2MHz
* @arg 1 : 32KHz
* @retval none
*/
void qdec_init (qdec_t *obj, PinName pha, PinName phb, PinName idx, qdec_clk_source source_clk);
/**
* @brief Deinitializes the QDEC device, include function/interrupt/QDEC registers.
* @param obj: QDEC object define in application software.
* @retval none
*/
void qdec_deinit (qdec_t *obj);
/**
* @brief Set the clock source, and the clock divider
* @param obj: QDEC object define in application software.
* @param smp_div: Sampling Clock = source clock/(smp_div+1). Value: 0 ~ 31.
* @retval none
*/
void qdec_set_sampling_div (qdec_t *obj, u8 smp_div);
/**
* @brief Set the position accumulation counter.
* @param obj: QDEC object define in application software.
* @param resolution: The resolution of the quadrature decoder.
* @arg 0 : 1 phase
* @arg 1 : 2 phases. Only phase A edges are counted.
* @retval none
*/
void qdec_set_resolution (qdec_t *obj, qdec_resolution resolution);
/**
* @brief Set the position accumulation counter.
* @param obj: QDEC object define in application software.
* @param pc_maximum: The maximum value of the position counter is according to the quadrature encoder. Value: 0 ~ 65535.
* @retval none
*/
void qdec_set_pc_maximum (qdec_t *obj, u16 pc_maximum);
/**
* @brief Set the method for calculating the rotation.
* @param obj: QDEC object define in application software.
* @param rotation_mode: The rotation mode.
* @arg 0 : Accumulate the rotation number when the index event occurres with direction(+/-).
* @arg 1 : Accumulate the rotation number when the position counter occurres overflow(+)/underflow(-).
* @retval none
*/
void qdec_set_rotation_mode (qdec_t *obj, qdec_rotation_source rotation_mode);
/**
* @brief Set the glitch filter.
* @param obj: QDEC object define in application software.
* @param filter_enable: To enable or disable.
* @param filter_time: Set de-bounce time = filter_time x clock source unit, clock source unit is 0.5us or 31.25us.
* @retval none
*/
void qdec_set_filter_init (qdec_t *obj, BOOL filter_enable, u16 filter_time);
/**
* @brief Configure the function of the index pin.
* @param obj: QDEC object define in application software.
* @param index_enable: To enable or disable.
* @param index_level: Set the used level according to the quadrature encoder.
* @param index_rst: The index input can reset the position counter.
* @arg 0 : disable.
* @arg 1 : only reset 1st.
* @arg 2 : always reset.
* @retval none
*/
void qdec_set_index_init (qdec_t *obj, BOOL index_enable, qdec_index_level index_level, qdec_index_rst index_rst);
/**
* @brief Control quadrature decoder.
* @param obj: QDEC object define in application software.
* @param qdec_en_ctrl: To enable or disable.
* @retval none
*/
void qdec_set_en (qdec_t *obj, BOOL qdec_en_ctrl);
/**
* @brief Control the interrupt event when change the direction.
* @param obj: QDEC object define in application software.
* @param en: To enable or disable.
* @param qdec_cb: User defined IRQ callback function.
* @param pqdec_arg: User defined IRQ callback parameter.
* @retval none
*/
void qdec_set_position_direction_change_init (qdec_t *obj, BOOL en, qdec_irq_handler qdec_cb, void *pqdec_arg);
/**
* @brief Set a value changed on the position counter which will trigger the position changed interrupt.
* @param obj: QDEC object define in application software.
* @param en: To enable or disable.
* @param count_change_value: This field set a value changed on the position counter which will trigger the position changed interrupt.
* @arg 00: +/- 1.
* @arg 01: +/- 2.
* @arg 10: +/- 4.
* @arg 11: reserved.
* @param qdec_cb: User defined IRQ callback function.
* @param pqdec_arg: User defined IRQ callback parameter.
* @retval none
*/
void qdec_set_position_count_change_init (qdec_t *obj, BOOL en, qdec_cnt_chg count_change_value, qdec_irq_handler qdec_cb, void *pqdec_arg);
/**
* @brief Control the interrupt event when the position counter is equal to the compare value.
* @param obj: QDEC object define in application software.
* @param en: To enable or disable.
* @param compare_value: If the position counter is equal to this value, the corresponding interrupt will be asserted. The value is 0x00~0xFFFF.
* @param qdec_cb: User defined IRQ callback function.
* @param pqdec_arg: User defined IRQ callback parameter.
* @retval none
*/
void qdec_set_position_compare_init (qdec_t *obj, BOOL en, u16 compare_value, qdec_irq_handler qdec_cb, void *pqdec_arg);
/**
* @brief Control the interrupt event when the position counter value is overflow (Max position counter -> 0x0000).
* @param obj: QDEC object define in application software.
* @param en: To enable or disable.
* @param qdec_cb: User defined IRQ callback function.
* @param pqdec_arg: User defined IRQ callback parameter.
* @retval none
*/
void qdec_set_position_overflow_init (qdec_t *obj, BOOL en, qdec_irq_handler qdec_cb, void *pqdec_arg);
/**
* @brief Control the interrupt event when the position counter value is underflow (0x0000 -> Max position counter).
* @param obj: QDEC object define in application software.
* @param en: To enable or disable.
* @param qdec_cb: User defined IRQ callback function.
* @param pqdec_arg: User defined IRQ callback parameter.
* @retval none
*/
void qdec_set_position_underflow_init (qdec_t *obj, BOOL en, qdec_irq_handler qdec_cb, void *pqdec_arg);
/**
* @brief Control the interrupt event when the rotation counter is equal to the rotation value.
* @param obj: QDEC object define in application software.
* @param en: To enable or disable.
* @param compare_value: If the rotation counter is equal to this value, the corresponding interrupt will be asserted. The value is 0x00~0xFFF.
* @param qdec_cb: User defined IRQ callback function.
* @param pqdec_arg: User defined IRQ callback parameter.
* @retval none
*/
void qdec_set_rotation_compare_init (qdec_t *obj, BOOL en, u16 compare_value, qdec_irq_handler qdec_cb, void *pqdec_arg);
/**
* @brief Control the interrupt event when the rotation counter value is overflow (Max rotation counter -> 0x0000).
* @param obj: QDEC object define in application software.
* @param en: To enable or disable.
* @param qdec_cb: User defined IRQ callback function.
* @param pqdec_arg: User defined IRQ callback parameter.
* @retval none
*/
void qdec_set_rotation_overflow_init (qdec_t *obj, BOOL en, qdec_irq_handler qdec_cb, void *pqdec_arg);
/**
* @brief Control the interrupt event when the rotation counter value is underflow (0x0000 -> Max position counter).
* @param obj: QDEC object define in application software.
* @param en: To enable or disable.
* @param qdec_cb: User defined IRQ callback function.
* @param pqdec_arg: User defined IRQ callback parameter.
* @retval none
*/
void qdec_set_rotation_underflow_init (qdec_t *obj, BOOL en, qdec_irq_handler qdec_cb, void *pqdec_arg);
/**
* @brief Control the interrupt event when get the velocity by measuring the counts in a period of time.
* @param obj: QDEC object define in application software.
* @param en: To enable or disable.
* @param vmuc_mode: Control the measurement value.
* @arg 0 : the counter value uses the absolute value.
* @arg 1 : the counter value does not use the absolute value.
* @param time_us: Measure time. This unit is us.
* @param qdec_cb: User defined IRQ callback function.
* @param pqdec_arg: User defined IRQ callback parameter.
* @retval none
*/
void qdec_set_velocity_measure_cnt_init (qdec_t *obj, BOOL en, qdec_vmuc_mode vmuc_mode, u32 time_us, qdec_irq_handler qdec_cb, void *pqdec_arg);
/**
* @brief Control the interrupt event. The measuring counts is less than the low limit when execute the velocity function.
* @param obj: QDEC object define in application software.
* @param en: To enable or disable.
* @param low_limit_cnt: The low limit value is 0x00~0xFFFF.
* @param qdec_cb: User defined IRQ callback function.
* @param pqdec_arg: User defined IRQ callback parameter.
* @retval none
*/
void qdec_set_velocity_measure_cnt_lowlmt_init (qdec_t *obj, BOOL en, u16 low_limit_cnt, qdec_irq_handler qdec_cb, void *pqdec_arg);
/**
* @brief Control the interrupt event. The measuring counts is bigger than the up limit when execute the velocity function.
* @param obj: QDEC object define in application software.
* @param en: To enable or disable.
* @param up_limit_cnt: The up limit value is 0x00~0xFFFF.
* @param qdec_cb: User defined IRQ callback function.
* @param pqdec_arg: User defined IRQ callback parameter.
* @retval none
*/
void qdec_set_velocity_measure_cnt_uplmt_init (qdec_t *obj, BOOL en, u16 up_limit_cnt, qdec_irq_handler qdec_cb, void *pqdec_arg);
/**
* @brief Control the interrupt event for detecting the index.
* @param obj: QDEC object define in application software.
* @param en: To enable or disable.
* @param qdec_cb: User defined IRQ callback function.
* @param pqdec_arg: User defined IRQ callback parameter.
* @retval none
*/
void qdec_set_index_present_init (qdec_t *obj, BOOL en, qdec_irq_handler qdec_cb, void *pqdec_arg);
/**
* @brief Control the interrupt event for checking that the position counter is zero at the present of index.
* @param obj: QDEC object define in application software.
* @param en: To enable or disable.
* @param qdec_cb: User defined IRQ callback function.
* @param pqdec_arg: User defined IRQ callback parameter.
* @retval none
*/
void qdec_set_index_check_position_init (qdec_t *obj, BOOL en, qdec_irq_handler qdec_cb, void *pqdec_arg);
/**
* @brief Reset the position counter and machine.
* @param obj: QDEC object define in application software.
* @retval none
*/
void qdec_position_reset (qdec_t *obj);
/**
* @brief Reset the rotation counter and machine.
* @param obj: QDEC object define in application software.
* @retval none
*/
void qdec_rotation_reset (qdec_t *obj);
/**
* @brief Reset the velocity counter and machine.
* @param obj: QDEC object define in application software.
* @retval none
*/
void qdec_velocity_cnt_reset (qdec_t *obj);
/**
* @brief Start the timer to measure the velocity.
* @param obj: QDEC object define in application software.
* @param en: To enable or disable.
* @retval none
*/
void qdec_start_velocity_measure_cnt (qdec_t *obj, BOOL en);
/**
* @brief Get the velocity counts.
* @param obj: QDEC object define in application software.
* @retval The capture value of the velocity counter.
*/
u16 qdec_get_velocity_measure_cnt (qdec_t *obj);
/**
* @brief Calculate RPM (Revolution Per Minute) according to the velocity counts.
* @param obj: QDEC object define in application software.
* @param velocity_cnt: The velocity counts.
* @retval RPM
*/
float qdec_get_velocity_measure_cnt_rpm (qdec_t *obj, u16 velocity_cnt);
/**
* @brief Get the position counter of QDEC.
* @param obj: QDEC object define in application software.
* @retval Position counter 16bits.
*/
u16 qdec_get_position (qdec_t *obj);
/**
* @brief Get the rotation counter of QDEC.
* @param obj: QDEC object define in application software.
* @retval Rotation counter 12bits.
*/
u16 qdec_get_rotation (qdec_t *obj);
/**
* @brief Get the movement direction of QDEC.
* @param obj: QDEC object define in application software.
* @retval 0: decrease, 1: increase
*/
u8 qdec_get_direction (qdec_t *obj);
/**
* @brief Get the phase state of QDEC.
* @param obj: QDEC object define in application software.
* @retval Current state of (A, B) phase
*/
u8 qdec_get_phase_state (qdec_t *obj);
/*\@}*/
#ifdef __cplusplus
}
#endif
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP)"
#endif

View file

@ -0,0 +1,107 @@
/** mbed Microcontroller Library
******************************************************************************
* @file reset_reason_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed Reset Reason API
******************************************************************************
* @attention
*
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
******************************************************************************
*/
#ifndef MBED_RESET_REASON_API_H
#define MBED_RESET_REASON_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
#if defined(CONFIG_PLATFORM_8710C)
/**
* \defgroup hal_reset_reason Reset Reason HAL API
* @{
*/
/** Definitions of different reset reasons
*/
typedef enum {
RESET_REASON_POWER_ON, /**< Set when power is initially applied to the board. The power-on-reset circuit causes a POWER_ON reset when this occurs */
RESET_REASON_PIN_RESET, /**< Set when a reset is triggered by the hardware pin on the board */
RESET_REASON_BROWN_OUT, /**< Triggered when the voltage drops below the low voltage detect (LVD) threshold the system will be held in a reset until the voltage rises above the threshold */
RESET_REASON_SOFTWARE, /**< Set during software reset, typically triggered by writing the SYSRESETREQ bit in the Application Interrupt and Reset Control register */
RESET_REASON_WATCHDOG, /**< Set when a running watchdog timer fails to be refreshed */
RESET_REASON_WAKE_LOW_POWER, /**< Set when waking from deep sleep mode */
RESET_REASON_MULTIPLE, /**< Set if multiple reset reasons are set within the board. Occurs when the reset reason registers aren't cleared between resets */
RESET_REASON_UNKNOWN /**< Unknown or unreadable reset reason **/
} reset_reason_t;
/** Fetch the reset reason for the last system reset
*
* This function must return the contents of the system reset reason registers
* cast to an appropriate platform independent reset reason. If multiple reset
* reasons are set this function should return RESET_REASON_MULTIPLE. If the
* reset reason does not match any existing platform independent value this
* function should return RESET_REASON_PLATFORM. If no reset reason can be
* determined this function should return RESET_REASON_UNKNOWN.
*
* This function is not idempotent, there is no guarantee that the system
* reset reason will not be cleared between calls to this function altering the
* return value between calls.
*
* Note: Some platforms contain reset reason registers that persist through
* system resets. If the registers haven't been cleared before calling this
* function multiple reasons may be set within the registers. If multiple reset
* reasons are detected this function will return RESET_REASON_MULTIPLE.
*
* @return enum containing the last reset reason for the board.
*/
reset_reason_t hal_reset_reason_get(void);
/** Fetch the raw platform specific reset reason register value
*
* This function must return the raw contents of the system reset reason
* registers cast to a uint32_t value. If the platform contains reset reasons
* that span multiple registers/addresses the value should be concatenated into
* the return type.
*
* This function is not idempotent, there is no guarantee that the system
* reset reason will not be cleared between calls to this function altering the
* return value between calls.
*
* @return value containing the reset reason register for the given platform.
* If the platform contains reset reasons across multiple registers they
* will be concatenated here.
*/
uint32_t hal_reset_reason_get_raw(void);
/** Clear the reset reason from registers
*
* Reset the value of the reset status registers, the reset reason will persist
* between system resets on certain platforms so the registers should be cleared
* before the system resets. Failing to do so may make it difficult to determine
* the cause of any subsequent system resets.
*/
void hal_reset_reason_clear(void);
/** Set the reset reason to registers
*
* Set the value of the reset status registers, to let user applicatoin store
* the reason before doing reset.
*/
void hal_reset_reason_set(reset_reason_t reason);
#endif //CONFIG_PLATFORM_8710C
/**@}*/
#ifdef __cplusplus
}
#endif
#endif //MBED_RESET_REASON_API_H

View file

@ -0,0 +1,220 @@
/** mbed Microcontroller Library
******************************************************************************
* @file serial_ex_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed API for UART.
******************************************************************************
* @attention
*
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
******************************************************************************
*/
#ifndef MBED_SERIAL_EX_API_H
#define MBED_SERIAL_EX_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup uart_ex UART_EX
* @ingroup hal
* @brief uart extended functions
* @{
*/
///@name Ameba Common
///@{
/**
* @brief Define RX FIFO Level: RX interrupt trigger, RTS de-assert trigger
*/
typedef enum {
FifoLv1Byte=0, /*!< 1-byte */
FifoLvQuarter=1, /*!< 4-byte/8-byte(for 8195B/8710C) */
FifoLvHalf=2, /*!< 8-byte/16-byte(for 8195B/8710C) */
FifoLvFull=3 /*!< 14-byte/30-bytes(for 8195B/8710C) */
} SerialFifoLevel;
/**
* @brief Clear TX fifo.
* @param obj: uart object define in application software.
* @retval none
*/
void serial_clear_tx(serial_t *obj);
/**
* @brief Clear RX fifo.
* @param obj: uart object define in application software.
* @retval none
*/
void serial_clear_rx(serial_t *obj);
/**
* @brief set TX complete handler.
* @param obj: uart object define in application software.
* @param handler: TX complete callback function.
* @param id: TX complete callback function parameter.
* @retval none
* @note this function is used when asynchronous API is used.
*/
void serial_send_comp_handler(serial_t *obj, void *handler, uint32_t id);
/**
* @brief set RX complete handler.
* @param obj: uart object define in application software.
* @param handler: RX complete callback function.
* @param id: RX complete callback function parameter.
* @retval none
* @note this function is used when asynchronous API is used.
*/
void serial_recv_comp_handler(serial_t *obj, void *handler, uint32_t id);
/**
* @brief recv target length data use poll mode, with time out.
* @param obj: uart object define in application software.
* @param ptxbuf: buffer to be written to Tx FIFO.
* @param len: number of data to be recv.
* @param timeout_ms: polling time before timeout.
* @retval : return received bytes count
* @note this function is synchronous API.
*/
int32_t serial_recv_blocked(serial_t *obj, char *prxbuf, uint32_t len, uint32_t timeout_ms);
/**
* @brief send target length data use poll mode, with time out.
* @param obj: uart object define in application software.
* @param ptxbuf: buffer to be written to Tx FIFO.
* @param len: number of data to be send.
* @param timeout_ms: polling time before timeout.
* @retval : transmitted bytes count
* @note this function is synchronous API.
*/
int32_t serial_send_blocked(serial_t *obj, char *ptxbuf, uint32_t len, uint32_t timeout_ms);
/**
* @brief recv target length data use interrupt mode.
* @param obj: uart object define in application software.
* @param prxbuf: buffer to save data read from UART FIFO.
* @param len: number of data to be read.
* @retval : HAL_Status
* @note this function is asynchronous API.
*/
int32_t serial_recv_stream(serial_t *obj, char *prxbuf, uint32_t len);
/**
* @brief send target length data use interrupt mode.
* @param obj: uart object define in application software.
* @param ptxbuf: buffer to be written to Tx FIFO.
* @param len: number of data to be send.
* @retval : HAL_Status
* @note this function is asynchronous API.
*/
int32_t serial_send_stream(serial_t *obj, char *ptxbuf, uint32_t len);
/**
* @brief recv target length data use DMA mode.
* @param obj: uart object define in application software.
* @param prxbuf: buffer to save data read from UART FIFO.
* @param len: number of data to be read.
* @retval : HAL_Status
* @note this function is asynchronous API.
*/
int32_t serial_recv_stream_dma(serial_t *obj, char *prxbuf, uint32_t len);
/**
* @brief send target length data use DMA mode.
* @param obj: uart object define in application software.
* @param ptxbuf: buffer to be written to Tx FIFO.
* @param len: number of data to be send.
* @retval : HAL_Status
* @note this function is asynchronous API.
*/
int32_t serial_send_stream_dma(serial_t *obj, char *ptxbuf, uint32_t len);
/**
* @brief stop the stream or stream_dma TX.
* @param obj: uart object define in application software.
* @retval : number of bytes sent before stop
*/
int32_t serial_send_stream_abort(serial_t *obj);
/**
* @brief stop the stream or stream_dma RX.
* @param obj: uart object define in application software.
* @retval : number of bytes received before stop
*/
int32_t serial_recv_stream_abort(serial_t *obj);
/**
* @brief disable uart clock and function.
* @param obj: uart object define in application software.
* @retval none
*/
void serial_disable(serial_t *obj);
/**
* @brief enable uart clock and function.
* @param obj: uart object define in application software.
* @retval none
*/
void serial_enable(serial_t *obj);
/**
* @brief recv target length data use interrupt mode.
* @param obj: uart object define in application software.
* @param prxbuf: buffer to save data read from UART FIFO.
* @param len: number of data to be recv.
* @param timeout_ms: polling time before timeout.
* @param force_cs: forcing context switch function.
* @retval : the byte count received before timeout, or error(<0)
* @note this function is asynchronous API.
*/
int32_t serial_recv_stream_timeout(serial_t *obj, char *prxbuf, uint32_t len, uint32_t timeout_ms, void *force_cs);
/**
* @brief recv target length data use DMA mode.
* @param obj: uart object define in application software.
* @param prxbuf: buffer to save data read from UART FIFO.
* @param len: number of data to be recv.
* @param timeout_ms: polling time before timeout.
* @param force_cs: forcing context switch function.
* @retval : the byte count received before timeout, or error(<0)
* @note this function is asynchronous API. Some parameters have changed for AmebaD.
*/
int32_t serial_recv_stream_dma_timeout(serial_t *obj, char *prxbuf, uint32_t len, uint32_t timeout_ms, void *force_cs);
/**
* @brief uart rx fifo level setting.
* @param obj: uart object define in application software.
* @param FifoLv: @see SerialFifoLevel
* @retval none
*/
void serial_rx_fifo_level(serial_t *obj, SerialFifoLevel FifoLv);
#if (defined(CONFIG_PLATFORM_8710C) && (CONFIG_PLATFORM_8710C == 1))
/**
* @brief controls the RTS signal.
* @param obj: uart object define in application software.
* @param rts_state: RTS signal control value.
* @retval none
*/
void serial_rts_control(serial_t *obj, BOOLEAN rts_state);
#endif
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif // #ifndef MBED_SERIAL_EX_API_H

View file

@ -0,0 +1,607 @@
/** mbed Microcontroller Library
******************************************************************************
* @file sgpio_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed I2S API
******************************************************************************
* @attention
*
* 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_EXT_SGPIO_API_EXT_H
#define MBED_EXT_SGPIO_API_EXT_H
#if (defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1)) || (defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1))
///@name AmebaPro Only
///@{
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup sgpio SGPIO
* @ingroup hal
* @brief sgpio functions
* @{
*/
typedef enum {
RXTC_NO_TRIGGER = Rxtc_None,
RXTC_RISE_EDGE = Rxtc_InputRiseEg,
RXTC_FALL_EDGE = Rxtc_InputFallEg,
RXTC_BOTH_EDGE = Rxtc_InputBothEg,
RXTC_ACTIVE = 4
} sgpio_rxtc_input_start;
typedef enum {
RXTC_MATCH_EVENT0 = Rxtc_MatchEvent0,
RXTC_MATCH_EVENT1 = Rxtc_MatchEvent1,
RXTC_MATCH_EVENT2 = Rxtc_MatchEvent2
} sgpio_rxtc_match_event;
typedef enum {
CAP_NO_TRIGGER = Cap_None,
CAP_RISE_EDGE = Cap_InputRiseEg,
CAP_FALL_EDGE = Cap_InputFallEg,
CAP_BOTH_EDGE = Cap_InputBothEg,
CAP_MULTC_MATCH_EVENT0 = Cap_MultcMatchEvent0
} sgpio_capture_type;
typedef enum {
MULTC_TIMER = Multc_Timer_Mode,
MULTC_COUNTER_RISE_EDGE = Multc_Counter_InputRiseEg,
MULTC_COUNTER_FALL_EDGE = Multc_Counter_InputFallEg,
MULTC_COUNTER_BOTH_EDGE = Multc_Counter_InputBothEg
} sgpio_multc_mode;
typedef enum {
INPUT_NO_TRIGGER = Input_None,
INPUT_RISE_EDGE = Input_RiseEdge,
INPUT_FALL_EDGE = Input_FallEdge,
INPUT_BOTH_EDGE = Input_BothEdge
} sgpio_counter_edge;
typedef enum {
MULTC_MATCH_EVENT0 = Multc_MatchEvent0,
MULTC_MATCH_EVENT1 = Multc_MatchEvent1,
MULTC_MATCH_EVENT2 = Multc_MatchEvent2,
MULTC_MATCH_EVENT3 = Multc_MatchEvent3
} sgpio_multc_match_event;
typedef enum {
MULTC_MATCH_GROUP0 = Multc_MatchGroup0,
MULTC_MATCH_GROUP1 = Multc_MatchGroup1
} sgpio_multc_match_group;
typedef enum {
MATCH_OUTPUT_NONE = External_None,
MATCH_OUTPUT_LOW = External_Low,
MATCH_OUTPUT_HIGH = External_High,
MATCH_OUTPUT_TOGGLE = External_Toggle
} sgpio_external_output;
typedef enum {
INPUT_ONLY = Rx_Input_Only,
BIDIRECTION = Rx_In_And_Output
} sgpio_rx_inoutput;
typedef enum {
OUTPUT_LOW = Output_Is_Low,
OUTPUT_HIGH = Output_Is_High
} sgpio_output_value;
typedef enum {
FIRST_LSB = First_Data_LSB,
FIRST_MSB = First_Data_MSB
} sgpio_first_msb_or_lsb;
typedef enum {
GET_BIT0 = Compare_Result_Bit0,
GET_BIT1 = Compare_Result_Bit1
} sgpio_cmp_result_bit;
typedef enum {
UNIT_US = Time_unit_us,
UNIT_NS = Time_unit_ns
} sgpio_time_unit;
typedef enum {
TIMER_US = Timer_mode_unit_us,
TIMER_NS = Timer_mode_unit_ns,
COUNTER_CNT = Countr_mode_unit_cnt
} sgpio_source_unit;
typedef enum {
RXTC_INACTIVE = 0x00,
RXTC_RESET = 0x01,
RXTC_STOP = 0x02,
RXTC_RESET_STOP = 0x03
} sgpio_rxtc_ctrl;
typedef enum {
MULTC_INACTIVE = 0x00,
MULTC_RESET = 0x01,
MULTC_STOP = 0x02,
MULTC_RESET_STOP = 0x03
} sgpio_multc_ctrl;
typedef void (*sgpio_irq_handler)(void *);
typedef struct sgpio_s sgpio_t;
/**
* @brief Initializes the SGPIO device, include clock/function/interrupt/SGPIO registers.
* @param obj: SGPIO object define in application software.
* @param tx: Tx PinName according to pinmux spec.
* @param bi_dir_rx: Bidirectional Rx PinName according to pinmux spec.
* @retval none
*/
void sgpio_init (sgpio_t *obj, PinName tx, PinName bi_dir_rx);
/**
* @brief Deinitializes the SGPIO device, include function/interrupt/SGPIO registers.
* @param obj: SGPIO object define in application software.
* @retval none
*/
void sgpio_deinit (sgpio_t *obj);
/**
* @brief Be able to release the SGPIO pins from the pin mux after initializes the SGPIO device.
* @param obj: SGPIO object define in application software.
* @retval none
*/
void sgpio_pin_free (sgpio_t *obj);
/**
* @brief Reset SGPIO and registers.
* @param obj: SGPIO object define in application software.
* @retval none
*/
void sgpio_reset (sgpio_t *obj);
/**
* @brief Configure SGPIO to become the rxtc timer. Use RXTC.
* @param obj: SGPIO object define in application software.
* @param timer_once_en: Enable that matching event is executed once.
* @arg 0 : Repeat. When the rxtc timer matches match_reset_value_time, only reset the timer.
* @arg 1 : Once. When the rxtc timer matches match_reset_value_time, reset and stop the timer.
* @param time_unit: Select the time unit.
* @arg 0 : The unit is us.
* @arg 1 : The unit is ns.
* @param match_time1: Matching this time 1 generates the interrupt.
* @param match_time1_cb: User defined IRQ callback function. Using "NULL" will not generate this interrupt.
* @param pmatch_time1_arg: User defined IRQ callback parameter.
*
* @param match_time2: Matching this time 2 generates the interrupt.
* @param match_time2_cb: User defined IRQ callback function. Using "NULL" will not generate this interrupt.
* @param pmatch_time2_arg: User defined IRQ callback parameter.
*
* @param match_time_reset: This match time is able to make the timer reset and stop.
* @param time_reset_cb: User defined IRQ callback function. Using "NULL" will not generate this interrupt.
* @param ptime_reset_arg: User defined IRQ callback parameter.
* @retval none
*/
void sgpio_rxtc_timer_mode (sgpio_t *obj, BOOL timer_once_en, sgpio_time_unit time_unit,
u32 match_time1, sgpio_irq_handler match_time1_cb, void *pmatch_time1_arg,
u32 match_time2, sgpio_irq_handler match_time2_cb, void *pmatch_time2_arg,
u32 match_time_reset, sgpio_irq_handler time_reset_cb, void *ptime_reset_arg);
/**
* @brief Generate the external output when happen the match events of the rxtc timer.
* @param obj: SGPIO object define in application software.
* @param match_time1_output: Set the output value when match the time 1.
* @arg 0 : Inactive.
* @arg 1 : The output is low.
* @arg 2 : The output is high.
* @arg 3 : Toggle.
* @param match_time2_output: Set the output value when match the time 2.
* @param match_reset_time_output: Set the output value when match the reset time.
* @retval none
*/
void sgpio_rxtc_timer_match_output (sgpio_t *obj, sgpio_external_output match_time1_output, sgpio_external_output match_time2_output,
sgpio_external_output match_reset_time_output);
/**
* @brief Control to start the rxtc timer. Use RXTC.
* @param obj: SGPIO object define in application software.
* @param start_en: To enable or disable.
* @retval none
*/
void sgpio_rxtc_start_en (sgpio_t *obj, BOOL start_en);
/**
* @brief Configure SGPIO to become the multc timer. Use MULTC.
* @param obj: SGPIO object define in application software.
* @param timer_once_en: Enable that matching event is executed once.
* @arg 0 : Repeat. When the multc timer matches match_reset_value_time, only reset the timer.
* @arg 1 : Once. When the multc timer matches match_reset_value_time, reset and stop the timer.
* @param time_unit: Select the time unit.
* @arg 0 : The unit is us.
* @arg 1 : The unit is ns.
* @param match_time_reset: This match time is able to make the timer reset and stop.
* @param time_reset_cb: User defined IRQ callback function. Using "NULL" will not generate this interrupt.
* @param ptime_reset_arg: User defined IRQ callback parameter.
* @retval none
*/
void sgpio_multc_timer_mode (sgpio_t *obj, BOOL timer_once_en, sgpio_time_unit time_unit,
u32 match_time_reset, sgpio_irq_handler time_reset_cb, void *ptime_reset_arg);
/**
* @brief Configure SGPIO to count input triggers. Use MULTC. When use the timeout function, use RXTC.
* Setting the monitor time can monitor the number of triggers in a period.
* Reset the counter when the monitor time is timeout.
* @param obj: SGPIO object define in application software.
* @param counter_en: To enable or disable.
* @param input_edge: Select the edge of the trigger event.
* @arg 0 : Inactive.
* @arg 1 : Count on the rising edge.
* @arg 2 : Count on the falling edge.
* @arg 3 : Count on the both edge.
* @param match_value: When the counter value is equal to match_value, generate an interrupt.
* @param match_cb: User defined IRQ callback function. Using "NULL" will not generate this interrupt.
* @param pmatch_arg: User defined IRQ callback parameter.
* @param multc_ctrl: When the counter value is equal to match_value, control multc reset and stop.
* @arg 0 : Inactive
* @arg 1 : Reset MULTC.
* @arg 2 : Stop MULTC.
* @arg 3 : Reset and stop MULTC.
* @param timeout_unit: Select the timeout unit.
* @arg 0 : The unit is us.
* @arg 1 : The unit is ns.
* @param counter_timeout: If this value is not 0, make RXTC count time. When RXTC matches the timeout value, make MULTC reset and stop.
* @param timeout_cb: User defined IRQ callback function. Using "NULL" will not generate this interrupt.
* @param ptimeout_arg: User defined IRQ callback parameter.
* @retval none
*/
void sgpio_multc_counter_mode (sgpio_t *obj, BOOL counter_en, sgpio_counter_edge input_edge, u16 match_value,
sgpio_irq_handler match_cb, void *pmatch_arg, sgpio_multc_ctrl multc_ctrl,
sgpio_time_unit timeout_unit, u32 counter_timeout, sgpio_irq_handler timeout_cb, void *ptimeout_arg);
/**
* @brief Generate the external output when happen the match events of the multc timer counter.
* @param obj: SGPIO object define in application software.
* @param source_unit: Select the time unit.
* @arg 0 : The unit is us in the timer mode.
* @arg 1 : The unit is ns in the timer mode.
* @arg 2 : The unit is count in the counter mode.
* @param match_value1_output: Set the output value when happen the multc match event 1.
* @arg 0 : Inactive.
* @arg 1 : The output is low.
* @arg 2 : The output is high.
* @arg 3 : Toggle.
* @param match_value1: The match value 1 of the multc timer counter .
* @param match_value2_output: Set the output value when happen the multc match event 2.
* @param match_value2: The match value 2 of the multc timer counter .
* @param match_value3_output: Set the output value when happen the multc match event 3.
* @param match_value3: The match value 3 of the multc timer counter .
* @retval none
*/
void sgpio_multc_timer_counter_match_output (sgpio_t *obj, sgpio_source_unit source_unit,
sgpio_external_output match_value1_output, u32 match_value1,
sgpio_external_output match_value2_output, u32 match_value2,
sgpio_external_output match_value3_output, u32 match_value3);
/**
* @brief Control to start the multc timer. Use MULTC.
* @param obj: SGPIO object define in application software.
* @param start_en: To enable or disable.
* @retval none
*/
void sgpio_multc_start_en (sgpio_t *obj, BOOL start_en);
/**
* @brief Configure SGPIO to become the capture mode for measuring the pulse width. Use RXTC.
* @param obj: SGPIO object define in application software.
* @param capture_en: To enable or disable.
* @param start_timer_edge: Select the trigger edge for starting the rxtc timer.
* @param input_capture_edge: Select the capture edge for capturing the time.
* @arg 0 : Inactive.
* @arg 1 : Capture on the rising edge.
* @arg 2 : Capture on the falling edge.
* @arg 3 : Capture on the both edge.
* @param rxtc_ctrl: When happen the capture event, control rxtc reset and stop.
* @arg 0 : Inactive
* @arg 1 : Reset RXTC.
* @arg 2 : Stop RXTC.
* @arg 3 : Reset and stop RXTC.
* @param max_capture_range_us: Set the maximum possible measurement value for making the prescale of the timer automatically.
* This setting will affect the accuracy.
* @param capture_cb: User defined IRQ callback function. Using "NULL" will not generate this interrupt.
* @param pcapture_arg: User defined IRQ callback parameter.
* @retval none
*/
void sgpio_rxtc_capture_mode (sgpio_t *obj, BOOL capture_en, sgpio_rxtc_input_start start_timer_edge, sgpio_capture_type input_capture_edge,
sgpio_rxtc_ctrl rxtc_ctrl, u32 max_capture_range_us, sgpio_irq_handler capture_cb, void *pcapture_arg);
/**
* @brief Make the capture timer reset and stop in the capture mode when the timer value is equal to timeout_value. Use RXTC.
* @param obj: SGPIO object define in application software.
* @param capture_timeout_en: To enable or disable.
* @param rxtc_ctrl: When happen the capture timeout, control rxtc reset and stop.
* @arg 0 : Inactive
* @arg 1 : Reset RXTC.
* @arg 2 : Stop RXTC.
* @arg 3 : Reset and stop RXTC.
* @param time_unit: Select the time unit.
* @arg 0 : The unit is us.
* @arg 1 : The unit is ns.
* @param timeout_value: Matching this timeout value generates the interrupt.
* @param capture_timeout_cb: User defined IRQ callback function. Using "NULL" will not generate this interrupt.
* @param pcapture_timeout_arg: User defined IRQ callback parameter.
* @retval none
*/
void sgpio_rxtc_capture_timeout(sgpio_t *obj, BOOL capture_timeout_en, sgpio_rxtc_ctrl rxtc_ctrl,
sgpio_time_unit time_unit, u32 timeout_value, sgpio_irq_handler capture_timeout_cb, void *pcapture_timeout_arg);
/**
* @brief Monitor the capture value. When the capture value is bigger than monitor time, generate the interrupt. Use RXTC.
* @param obj: SGPIO object define in application software.
* @param capture_monitor_en: To enable or disable.
* @param time_unit: Select the time unit.
* @arg 0 : The unit is us.
* @arg 1 : The unit is ns.
* @param monitor_time: The monitor value.
* @param monitor_count: Set the continuous numbers of the successful condition. Value: 1 ~ 32, 0: Inactive.
* @param capture_monitor_cb: User defined IRQ callback function. Using "NULL" will not generate this interrupt.
* @param pcapture_monitor_arg: User defined IRQ callback parameter.
* @retval none
*/
void sgpio_rxtc_capture_monitor(sgpio_t *obj, BOOL capture_monitor_en, sgpio_time_unit time_unit, u32 monitor_time, u8 monitor_count,
sgpio_irq_handler capture_monitor_cb, void *pcapture_monitor_arg);
/**
* @brief Get the capture value. Use RXTC.
* @param obj: SGPIO object define in application software.
* @param time_unit: Select the time unit.
* @arg 0 : The unit is us.
* @arg 1 : The unit is ns.
* @retval The capture value.
*/
u32 sgpio_get_rxtc_capture_time (sgpio_t *obj, sgpio_time_unit time_unit);
/**
* @brief Set the trigger edge to start the timer, and sample the input value according to the sampling time.
* The sampling data is put in the 32-bit register. Use RXTC.
* @param obj: SGPIO object define in application software.
* @param sampling_en: To enable or disable.
* @param start_timer_edge: Select the trigger edge for starting the rxtc timer.
* @param time_unit: Select the time unit.
* @arg 0 : The unit is us.
* @arg 1 : The unit is ns.
* @param sampling_time1: The sampling time 1 needs less than the sampling end time. Set to 0 when not in use.
* @param sampling_time2: The sampling time 2 needs less than the sampling end time. Set to 0 when not in use.
* @param sampling_end_time: The sampling end time. Matching this time is to make the timer reset and stop.
* @param sampling_bit_length: Set the bit length generated the interrupt. Value: 1 ~ 32, 0: Inactive.
* @param first_msb_or_lsb: Putting in the register is LSB or MSB.
* @param sampling_finish_cb: User defined IRQ callback function. Using "NULL" will not generate this interrupt.
* @param psampling_finish_arg: User defined IRQ callback parameter.
* @retval none
*/
void sgpio_sampling_rxdata (sgpio_t *obj, BOOL sampling_en, sgpio_rxtc_input_start start_timer_edge, sgpio_time_unit time_unit,
u32 sampling_time1, u32 sampling_time2, u32 sampling_end_time, u8 sampling_bit_length,
sgpio_first_msb_or_lsb first_msb_or_lsb, sgpio_irq_handler sampling_finish_cb, void *psampling_finish_arg);
/**
* @brief Set the trigger edge to start the timer, and translate the capture time into "0" or "1" according to the result of the comparison.
* When the capture time is bigger than the compare time, the bit result is put in the 32-bit register.
* The bit resut is "0" or "1" is controlled by compare_result_bit. Use RXTC.
* @param obj: SGPIO object define in application software.
* @param sampling_en: To enable or disable.
* @param capture_en: Select the trigger edge for starting the rxtc timer.
* @param input_capture_edge: Select the capture edge for capturing the time.
* @arg 0 : Inactive.
* @arg 1 : Capture on the rising edge.
* @arg 2 : Capture on the falling edge.
* @arg 3 : Capture on the both edge.
* @param max_capture_range_us: Set the maximum possible measurement value for making the prescale of the timer automatically.
* This setting will affect the accuracy.
* @param time_unit: Select the time unit.
* @arg 0 : The unit is us.
* @arg 1 : The unit is ns.
* @param capture_compare_value_time: Set the compare time.
* @param compare_result_bit: Deciding the value of the result bit is "0" or "1" when the capture time is bigger than the compare time.
* @param compare_bit_length: Set the bit length generated the interrupt. Value: 1 ~ 32, 0: Inactive.
* @param first_msb_or_lsb: Putting in the register is LSB or MSB.
* @param sampling_finish_cb: User defined IRQ callback function. Using "NULL" will not generate this interrupt.
* @param psampling_finish_arg: User defined IRQ callback parameter.
* @retval none
*/
void sgpio_capture_compare_rxdata (sgpio_t *obj, BOOL capture_en, sgpio_rxtc_input_start start_timer_edge, sgpio_capture_type input_capture_edge,
u32 max_capture_range_us, sgpio_time_unit time_unit, u32 capture_compare_value_time, sgpio_cmp_result_bit compare_result_bit,
u8 compare_bit_length, sgpio_first_msb_or_lsb first_msb_or_lsb, sgpio_irq_handler compare_finish_cb, void *pcompare_finish_arg);
/**
* @brief Get the register of the RX data by sample or capture.
* @param obj: SGPIO object define in application software.
* @retval The result register.
*/
u32 sgpio_get_input_rxdata (sgpio_t *obj);
/**
* @brief Configure the waveforms of the bit 0 and bit 1 for the output.
* @param obj: SGPIO object define in application software.
* @param initial_output_value: Set the initial output value.
* @param time_unit: Select the time unit.
* @arg 0 : The unit is us.
* @arg 1 : The unit is ns.
* @param bit0_middle_change_time: The time is to change the output value for the bit 0.
* @param bit0_duration_time: The duration of the bit 0.
* @param bit1_middle_change_time: The time is to change the output value for the bit 1.
* @param bit1_duration_time: The duration of the bit 1.
* @retval none
*/
void sgpio_set_bit_symbol_of_txdata (sgpio_t *obj, sgpio_output_value_t initial_output_value, sgpio_time_unit time_unit,
u32 bit0_middle_change_time, u32 bit0_duration_time,
u32 bit1_middle_change_time, u32 bit1_duration_time);
/**
* @brief Set the output data according to the waveforms of the bit 0 and bit 1. Use MULTC.
* @param obj: SGPIO object define in application software.
* @param txdata_en: To enable or disable.
* @param rx_output_en: Control the output behavior of the bidirectional Rx.
* @param output_bit_counts: Set the output bit number.
* @param ptxdata_pointer: Set the output data pointer.
* @param txdata_finish_cb: When finish the TX output, generate the interrupt.
* User defined IRQ callback function. Using "NULL" will not generate this interrupt.
* @param ptxdata_finish_arg: User defined IRQ callback parameter.
* @retval none
*/
void sgpio_set_txdata (sgpio_t *obj, BOOL txdata_en, BOOL rx_output_en, u16 output_bit_counts, u32 *ptxdata_pointer,
sgpio_irq_handler txdata_finish_cb, void *ptxdata_finish_arg);
/**
* @brief Start to output the TX data. Use MULTC.
* @param obj: SGPIO object define in application software.
* @retval none
*/
void sgpio_start_send_txdata (sgpio_t *obj);
/**
* @brief Monitor the register of the sample or capture data. When the register value is equal to the monitor data, generate the interrupt.
* @param obj: SGPIO object define in application software.
* @param monitor_en: To enable or disable.
* @param monitor_data: Set the monitor data.
* @param monitor_input_data_mask: Set the bit mask of the monitor data.
* @param monitor_rxdata_cb: User defined IRQ callback function. Using "NULL" will not generate this interrupt.
* @param pmonitor_rxdata_arg: User defined IRQ callback parameter.
* @retval none
*/
void sgpio_set_rxdata_monitor (sgpio_t *obj, BOOL monitor_en, u32 monitor_data, u32 monitor_input_data_mask,
sgpio_irq_handler monitor_rxdata_cb, void *pmonitor_rxdata_arg);
/**
* @brief Disable the monitor mode.
* @param obj: SGPIO object define in application software.
* @retval none
*/
void sgpio_disable_rxdata_monitor (sgpio_t *obj);
/**
* @brief Reset the register of the RX data.
* @param obj: SGPIO object define in application software.
* @retval none
*/
void sgpio_reset_receive_rxdata(sgpio_t *obj);
/**
* @brief Initializes the GDMA of SGPIO. Schedule the output to make the waveform by GDMA. Use MULTC.
* @param obj: SGPIO object define in application software.
* @param pmatch_value_ptr: The pointer is the memory address of setting the match time.
* Memory allocation: reset time(a), match time1(a), match time2(a), match time3(a)
* reset time(b), match time1(b), match time2(b), match time3(b)
* reset time(c), ...
* @param reset_time_num: Set the number of reset times. An interrupt will be generated when the number of times is reached.
* @param time_unit: Select the time unit.
* @arg 0 : The unit is us.
* @arg 1 : The unit is ns.
* @param match_time1_output: Set the output value when match the time 1.
* @arg 0 : Inactive.
* @arg 1 : The output is low.
* @arg 2 : The output is high.
* @arg 3 : Toggle.
* @param match_time2_output: Set the output value when match the time 2.
* @param match_time3_output: Set the output value when match the time 3.
* @param counter_finish_cb: User defined IRQ callback function. Using "NULL" will not generate this interrupt.
* @param pcounter_finish_arg: User defined IRQ callback parameter.
* @retval none
*/
void sgpio_init_dma_match_output (sgpio_t *obj, u16 *pmatch_value_ptr, u8 reset_time_num, sgpio_time_unit time_unit,
sgpio_external_output match_time1_output, sgpio_external_output match_time2_output, sgpio_external_output match_time3_output,
sgpio_irq_handler counter_finish_cb, void *pcounter_finish_arg);
/**
* @brief Deinitializes the GDMA of SGPIO.
* @param obj: SGPIO object define in application software.
* @retval none
*/
void sgpio_deinit_dma_match_output (sgpio_t *obj);
/**
* @brief Start the GDMA to send the TX waveform.
* @param obj: SGPIO object define in application software.
* @retval none
*/
void sgpio_start_dma (sgpio_t *obj);
/**
* @brief Set the TX output value.
* @param obj: SGPIO object define in application software.
* @param value: Set the output value.
* @arg 1 : The output is low.
* @arg 2 : The output is high.
* @retval none
*/
void sgpio_set_output_value (sgpio_t *obj, sgpio_output_value value);
/**
* @brief Make the inverse output
* @param obj: SGPIO object define in application software.
* @retval none
*/
void sgpio_set_inverse_output (sgpio_t *obj);
/**
* @brief Get the register value of the rxtc timer.
* @param obj: SGPIO object define in application software.
* @retval The register value of the rxtc timer.
*/
u16 sgpio_get_rxtc_value (sgpio_t *obj);
/**
* @brief Reset the rxtc timer.
* @param obj: SGPIO object define in application software.
* @retval none
*/
void sgpio_reset_rxtc (sgpio_t *obj);
/**
* @brief Get the register value of the multc timer.
* @param obj: SGPIO object define in application software.
* @retval The register value of the multc timer.
*/
u16 sgpio_get_multc_value (sgpio_t *obj);
/**
* @brief Reset the multc timer.
* @param obj: SGPIO object define in application software.
* @retval none
*/
void sgpio_reset_multc (sgpio_t *obj);
/**
* @brief Control the rx to become the bi-direction.
* @param obj: SGPIO object define in application software.
* @param rx_in_out: Select the input or bi-direction.
* @arg 0 : Only input.
* @arg 1 : Bi-direction.
* @retval none
*/
void sgpio_set_rx_in_out_ctrl (sgpio_t *obj, sgpio_rx_inoutput rx_in_out);
/*\@}*/
#ifdef __cplusplus
}
#endif
///@}
#endif // end of "#if defined(CONFIG_PLATFORM_8195BHP) || defined(CONFIG_PLATFORM_8195BLP)"
#endif

View file

@ -0,0 +1,283 @@
/** mbed Microcontroller Library
******************************************************************************
* @file sleep_ex_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed API for SLEEP.
******************************************************************************
* @attention
*
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
******************************************************************************
*/
#ifndef MBED_SLEEP_EX_API_H
#define MBED_SLEEP_EX_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup sleep_ex SLEEP_EX
* @ingroup hal
* @brief sleep extended functions
* @{
*/
#if defined(CONFIG_PLATFORM_8195A) && (CONFIG_PLATFORM_8195A == 1)
///@name Ameba1 Only
///@{
/* Sleep Eake Up event, the User application also
need to config the peripheral to trigger wake up event */
#define SLEEP_WAKEUP_BY_STIMER (SLP_STIMER) // wake up by system timer
#define SLEEP_WAKEUP_BY_GTIMER (SLP_GTIMER) // wake up by General purpose timer timeout
#define SLEEP_WAKEUP_BY_GPIO_INT (SLP_GPIO) // wake up by GPIO Port A[7:0] Interrupt
#define SLEEP_WAKEUP_BY_WLAN (SLP_WL) // wake up by WLan event
#define SLEEP_WAKEUP_BY_NFC (SLP_NFC) // wake up by NFC event
#define SLEEP_WAKEUP_BY_SDIO (SLP_SDIO) // wake up by SDIO event
#define SLEEP_WAKEUP_BY_USB (SLP_USB) // wake up by USB event
// Deep Standby Wakeup event
#define STANDBY_WAKEUP_BY_STIMER (BIT0) // wake up by system timer
#define STANDBY_WAKEUP_BY_NFC (BIT1) // wake up by NFC event
//#define SLEEP_WAKEUP_BY_DS_TIMER (BIT2) // The timer to wakeup from Deep Sleep timer
// Do not modify these definition, or need to modify the code also.
#define STANDBY_WAKEUP_BY_PA5 (BIT4) // GPIO Port A[5]
#define STANDBY_WAKEUP_BY_PC7 (BIT5) // GPIO Port C[7]
#define STANDBY_WAKEUP_BY_PD5 (BIT6) // GPIO Port D[5]
#define STANDBY_WAKEUP_BY_PE3 (BIT7) // GPIO Port E[3]
// Deep Sleep Wakeup event
#define DSLEEP_WAKEUP_BY_TIMER (DS_TIMER33)
#define DSLEEP_WAKEUP_BY_GPIO (DS_GPIO) // GPIO Port B[1]
typedef struct _SLEEP_WKUP_EVENT_ {
u8 wakeup_event; // Wake up event: Timer, NFC, GPIO
u8 gpio_option; // GPIO Wakeup setting: [3:0]: Pin 3~0 enable, [7:4]: pin3~0 active high/low
u32 timer_duration; // the sleep duration and then wakeup
} SLEEP_WAKEUP_EVENT, *PSLEEP_WAKEUP_EVENT;
///@}
#endif //CONFIG_PLATFORM_8195A
#if defined(CONFIG_PLATFORM_8711B) && (CONFIG_PLATFORM_8711B == 1)
///@name AmebaZ Only
///@{
/* Sleep Eake Up event, the User application also
need to config the peripheral to trigger wake up event */
#define SLEEP_WAKEUP_BY_STIMER (BIT_SYSON_WEVT_SYSTIM_MSK) // wake up by system timer
#define SLEEP_WAKEUP_BY_GPIO_INT (BIT_SYSON_WEVT_GPIO_MSK) // wake up by GPIO Port A[31:0] Interrupt
#define SLEEP_WAKEUP_BY_WLAN (BIT_SYSON_WEVT_WLAN_MSK) // wake up by WLan event
#define SLEEP_WAKEUP_BY_SDIO (BIT_SYSON_WEVT_SDIO_MSK) // wake up by SDIO event
#define SLEEP_WAKEUP_BY_USB (BIT_SYSON_WEVT_USB_MSK) // wake up by USB event
#define SLEEP_WAKEUP_BY_GPIO (BIT_SYSON_WEVT_GPIO_DSTBY_MSK) // GPIO Port(PA_18, PA_5, PA_22, PA_23)
#define SLEEP_WAKEUP_BY_UART (BIT_SYSON_WEVT_UART0_MSK | BIT_SYSON_WEVT_UART1_MSK) // wake up by UART event
#define SLEEP_WAKEUP_BY_I2C (BIT_SYSON_WEVT_I2C0_MSK | BIT_SYSON_WEVT_I2C1_MSK) // wake up by I2C event
#define SLEEP_WAKEUP_BY_RTC (BIT_SYSON_WEVT_RTC_MSK) // wake up by RTC event
// Deep Standby Wakeup event
#define STANDBY_WAKEUP_BY_STIMER (BIT_SYSON_WEVT_A33_AND_A33GPIO_MSK) // wake up by 1K timer
#define STANDBY_WAKEUP_BY_GPIO (BIT_SYSON_WEVT_GPIO_DSTBY_MSK) // GPIO Port(PA_18, PA_5, PA_22, PA_23)
#define STANDBY_WAKEUP_BY_RTC (BIT_SYSON_WEVT_RTC_MSK) // wake up by RTC event
// Deep Sleep Wakeup event
#define DSLEEP_WAKEUP_BY_TIMER BIT(0)
#define DSLEEP_WAKEUP_BY_GPIO BIT(2) // GPIO Port(PA_18, PA_5, PA_22, PA_23)
typedef struct _SLEEP_WKUP_EVENT_ {
u32 wakeup_event; // Wake up event: Timer, NFC, GPIO
u32 gpio_option; // GPIO Wakeup setting: [3:0]: Pin 3~0 enable, [11:8]: pin3~0 active high/low
u32 timer_duration; // the sleep duration and then wakeup
} SLEEP_WAKEUP_EVENT, *PSLEEP_WAKEUP_EVENT;
///@}
#endif //CONFIG_PLATFORM_8711B
///@name Ameba Common
///@{
/**
* @brief To make the system entering the Clock Gated power saving.
* This function just make the system to enter the clock gated
* power saving mode and pending on wake up event waitting.
* The user application need to configure the peripheral to
* generate system wake up event, like GPIO interrupt,
* G-Timer timeout, etc. befor entering power saving mode.
* @param wakeup_event: A bit map of wake up event.
* This parameter can be any combination of the following values:
* @arg SLEEP_WAKEUP_BY_STIMER
* @arg SLEEP_WAKEUP_BY_GTIMER
* @arg SLEEP_WAKEUP_BY_GPIO_INT
* @arg SLEEP_WAKEUP_BY_WLAN
* @arg SLEEP_WAKEUP_BY_SDIO
* @arg SLEEP_WAKEUP_BY_USB
* @arg SLEEP_WAKEUP_BY_GPIO
* @arg SLEEP_WAKEUP_BY_UART
* @arg SLEEP_WAKEUP_BY_I2C
* @arg SLEEP_WAKEUP_BY_RTC
* @arg SLEEP_WAKEUP_BY_RESETPIN
* @param sleep_duration: the system sleep duration in ms, only valid
* for SLEEP_WAKEUP_BY_STIMER wake up event.
* @retval None
*/
void sleep_ex(uint32_t wakeup_event, uint32_t sleep_duration);
/**
* @brief To make the system entering the Clock Gated power saving.
* This function just make the system to enter the clock gated
* power saving mode and pending on wake up event waitting.
* The user application need to configure the peripheral to
* generate system wake up event, like GPIO interrupt
* , G-Timer timeout, etc. befor entering power saving mode.
* @param wakeup_event: A bit map of wake up event.
* This parameter can be any combination of the following values:
* @arg SLEEP_WAKEUP_BY_STIMER
* @arg SLEEP_WAKEUP_BY_GTIMER
* @arg SLEEP_WAKEUP_BY_GPIO_INT
* @arg SLEEP_WAKEUP_BY_WLAN
* @arg SLEEP_WAKEUP_BY_SDIO
* @arg SLEEP_WAKEUP_BY_USB
* @arg SLEEP_WAKEUP_BY_GPIO
* @arg SLEEP_WAKEUP_BY_UART
* @arg SLEEP_WAKEUP_BY_I2C
* @arg SLEEP_WAKEUP_BY_RTC
* @arg SLEEP_WAKEUP_BY_RESETPIN
* @param sleep_duration: the system sleep duration in ms, only valid
* for SLEEP_WAKEUP_BY_STIMER wake up event.
* @param clk_sourec_enable: the option for SCLK on(1)/off(0)
* @param sdr_enable: the option for turn off the SDR controller (1:off, 0:on)
* @retval None
*/
void sleep_ex_selective(uint32_t wakeup_event, uint32_t sleep_duration, uint32_t clk_sourec_enable, uint32_t sdr_enable);
#if defined(CONFIG_PLATFORM_8195A) && (CONFIG_PLATFORM_8195A == 1)
///@name Ameba1 Only
///@{
/**
* @brief To make the system entering the Deep Standby power saving.
* The CPU, memory and part fo peripheral power is off when
* entering deep standby power saving mode. The program needs
* to be reload from the flash at system resume.
* @retval None
*/
void deepstandby_ex(void);
///@}
#endif //CONFIG_PLATFORM_8195A
#if defined(CONFIG_PLATFORM_8711B) && (CONFIG_PLATFORM_8711B == 1)
///@name AmebaZ Only
///@{
/**
* @brief To make the system entering the Deep Standby power saving.
* The CPU, memory and part fo peripheral power is off when
* entering deep standby power saving mode. The program needs
* to be reload from the flash at system resume.
* @param sleep_duration_ms: the system sleep duration in ms, only valid
* for STANDBY_WAKEUP_BY_STIMER wake up event.
* @retval None
*/
void deepstandby_ex(uint32_t sleep_duration_ms);
///@}
#endif //CONFIG_PLATFORM_8711B
/**
* @brief To make the system entering the Deep Sleep power saving mode.
* The CPU, memory and peripheral power is off when entering
* deep sleep power saving mode. The program needs to be reload
* and all peripheral needs be re-configure when system resume.
* @param wakeup_event: A bit map of wake up event.
* This parameter can be any combination of the following values:
* @arg DSLEEP_WAKEUP_BY_TIMER
* @arg DSLEEP_WAKEUP_BY_GPIO
* @param sleep_duration: the system sleep duration in ms, only valid
* for DSLEEP_WAKEUP_BY_TIMER wake up event.
* @retval None
*/
void deepsleep_ex(uint32_t wakeup_event, uint32_t sleep_duration);
#if defined(CONFIG_PLATFORM_8195A) && (CONFIG_PLATFORM_8195A == 1)
///@name Ameba1 Only
///@{
/**
* @brief To add a wake up event to wake up the system from the
* deep standby power saving mode.
* @param wakeup_event: A bit map of wake up event.
* This parameter can be any combination of the following values:
* @arg STANDBY_WAKEUP_BY_STIMER
* @arg STANDBY_WAKEUP_BY_GPIO
* @arg STANDBY_WAKEUP_BY_RTC
* @arg STANDBY_WAKEUP_BY_RESETPIN
* @param sleep_duration_ms: the system sleep duration in ms, only valid
* for STANDBY_WAKEUP_BY_STIMER wake up event.
* @param gpio_option: for a GPIO pin to wake up the system by goes high or low
* This parameter can be any combination of the following values:
* @arg WAKEUP_BY_GPIO_NONE
* @arg WAKEUP_BY_GPIO_WAKEUP0_LOW
* @arg WAKEUP_BY_GPIO_WAKEUP0_HIG
* @arg WAKEUP_BY_GPIO_WAKEUP1_LOW
* @arg WAKEUP_BY_GPIO_WAKEUP1_HIG
* @arg WAKEUP_BY_GPIO_WAKEUP2_LOW
* @arg WAKEUP_BY_GPIO_WAKEUP2_HIG
* @arg WAKEUP_BY_GPIO_WAKEUP3_LOW
* @arg WAKEUP_BY_GPIO_WAKEUP3_HIG
* @retval None
*/
void standby_wakeup_event_add(uint32_t wakeup_event, uint32_t sleep_duration_ms, uint32_t gpio_active);
///@}
#endif //CONFIG_PLATFORM_8195A
#if defined(CONFIG_PLATFORM_8711B) && (CONFIG_PLATFORM_8711B == 1)
///@name AmebaZ Only
///@{
/**
* @brief To add a wake up event to wake up the system from the
* deep standby power saving mode.
* @param wakeup_event: A bit map of wake up event.
* This parameter can be any combination of the following values:
* @arg STANDBY_WAKEUP_BY_STIMER
* @arg STANDBY_WAKEUP_BY_GPIO
* @arg STANDBY_WAKEUP_BY_RTC
* @arg STANDBY_WAKEUP_BY_RESETPIN
* @param gpio_option: for a GPIO pin to wake up the system by goes high or low
* This parameter can be any combination of the following values:
* @arg WAKEUP_BY_GPIO_NONE
* @arg WAKEUP_BY_GPIO_WAKEUP0_LOW
* @arg WAKEUP_BY_GPIO_WAKEUP0_HIG
* @arg WAKEUP_BY_GPIO_WAKEUP1_LOW
* @arg WAKEUP_BY_GPIO_WAKEUP1_HIG
* @arg WAKEUP_BY_GPIO_WAKEUP2_LOW
* @arg WAKEUP_BY_GPIO_WAKEUP2_HIG
* @arg WAKEUP_BY_GPIO_WAKEUP3_LOW
* @arg WAKEUP_BY_GPIO_WAKEUP3_HIG
* @retval None
*/
void standby_wakeup_event_add(uint32_t wakeup_event, uint32_t gpio_active);
///@}
#endif //CONFIG_PLATFORM_8711B
/**
* @brief To delete a wake up event for wakeing up the system from the
* deep standby power saving mode.
* @param wakeup_event: A bit map of wake up event.
* This parameter can be any combination of the following values:
* @arg STANDBY_WAKEUP_BY_STIMER
* @arg STANDBY_WAKEUP_BY_GPIO
* @arg STANDBY_WAKEUP_BY_RTC
* @arg STANDBY_WAKEUP_BY_RESETPIN
* @retval None
*/
void standby_wakeup_event_del(uint32_t wakeup_event);
///@}
#ifdef __cplusplus
}
#endif
//#endif
/*\@}*/
#endif

View file

@ -0,0 +1,144 @@
/** mbed Microcontroller Library
******************************************************************************
* @file spdio_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed SPDIO API
******************************************************************************
* @attention
*
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
******************************************************************************
*/
#ifndef __SPDIO_API_H__
#define __SPDIO_API_H__
#include <osdep_service.h>
/** @addtogroup spdio_api SPDIO
* @ingroup hal
* @brief spdio functions
* @{
*/
///@name Ameba Common
///@{
#define SPDIO_API_DBG
#ifdef SPDIO_API_DBG
#define SPDIO_API_PRINTK(fmt, args...) printf(fmt"\r\n",## args)
#define _SPDIO_API_PRINTK(fmt, args...) printf(fmt,## args)
#else
#define SPDIO_API_PRINTK(fmt, args...)
#define _SPDIO_API_PRINTK(fmt, args...)
#endif
#define SPDIO_DMA_ALIGN_4 4
#define SPDIO_RX_BUFSZ_ALIGN(x) ((((x-1)>>6)+1)<<6) //alignement to 64
#define SPDIO_RXDESC_SZ 24
/*Don't modify this enum table*/
enum spdio_rx_data_t{
SPDIO_RX_DATA_NULL = 0x00,
SPDIO_RX_DATA_ETH = 0x83, //an ethernet packet received
SPDIO_RX_DATA_ATCMD = 0x11, //an AT command packet received
SPDIO_RX_DATA_USER = 0x41, //defined by user
};
enum spdio_tx_data_t{
SPDIO_TX_DATA_NULL = 0x00,
SPDIO_TX_DATA_ETH = 0x82, //an ethernet packet sent
SPDIO_TX_DATA_ATCMDRSP = 0x10, //an AT command response packet sent
SPDIO_TX_DATA_USER = 0x40, // defined by user
};
struct spdio_buf_t{
void *priv; //priv data from user
u32 buf_allocated; //The spdio buffer allocated address
u16 size_allocated; //The actual allocated size
u32 buf_addr; //The spdio buffer physical address, it must be 4-bytes aligned
u16 buf_size;
u8 type; //The type of the data which this buffer carries, spdio_rx_data_t and spdio_tx_data_t
u8 reserved;
};
struct spdio_t {
void *priv; //not used by user
u32 tx_bd_num; //for spdio send data to host, 2 bd for one packet, so this value must be rounded to 2
u32 rx_bd_num; //for spdio receive data from host
u32 rx_bd_bufsz; //buffer size = desired packet length + 24(spdio header info), must be rounded to 64
struct spdio_buf_t *rx_buf; //buffer array for spdio receive assigned by user, rx_bd_bufsz * rx_bd_num
/**
*@brief pointer to callback function defined by user,
called by spdio when one packet receive done
*@param priv: a pointer to spdio_t structure which is used to initilize spdio interface
*@param pbuf: a pointer to spdio_buf_t structure which is spdio receive buffer
*@param pdata: the actual received packet payload
*@param size: the actual payload length
*@param type: the received packet type, spdio_rx_data_t
*@retval SUCCESS or FAIL
*/
char (*rx_done_cb)(void *priv, void* pbuf, u8 *pdata, u16 size, u8 type);
/**
*@brief pointer to callback function defined by user,
called by spdio when one packet sent done
*@param priv: a pointer to spdio_t structure which is used to initilize spdio interface
*@param pbuf: a pointer to spdio_buf_t structure which carries the transmit packet
*@retval SUCCESS or FAIL
*/
char (*tx_done_cb)(void *priv, void* pbuf);
};
/**
* @brief Gets example setting for spdio obj.
* @param obj: a pointer to an spdio_t structure which will be initialized with an example settings
* @retval None
*/
void spdio_structinit(struct spdio_t *obj);
/**
* @brief Initialize spdio interface.
* @param obj, a pointer to a spdio_t structure which should be initialized by user,
* and which will be used to initialize spdio interface
* obj->tx_bd_num: spdio write bd number, needs 2 bd for one transaction
* obj->rx_bd_num: spdio read bd number
* obj->rx_bd_bufsz: spdio read buffer size
* obj->rx_buf: spdio read buffer array
* @retval None
*/
void spdio_init(struct spdio_t *obj);
/**
* @brief Deinitialize spdio interface.
* @param obj: a pointer to spdio_t structure which is already initialized
* @retval None
*/
void spdio_deinit(struct spdio_t *obj);
/**
* @brief spdio write function.
* @param obj: a pointer to spdio_t structure which is already initialized
* @param pbuf: a pointer to spdio_buf_t structure which carries the payload
* @retval SUCCESS or FAIL
*/
s8 spdio_tx(struct spdio_t *obj, struct spdio_buf_t *pbuf);
/**
* @brief an obj which will be used to initialize sdio interface
* so it must be initialized before calling HalSdioInit();
*/
extern struct spdio_t *g_spdio_priv;
///@}
/*\@}*/
#endif //#ifndef __SPDIO_API_H__

View file

@ -0,0 +1,244 @@
/** mbed Microcontroller Library
******************************************************************************
* @file spi_ex_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed SPI API
******************************************************************************
* @attention
*
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
******************************************************************************
*/
#ifndef MBED_SPI_EXT_API_H
#define MBED_SPI_EXT_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup spi_ex SPI_EX
* @ingroup hal
* @brief spi extended functions
* @{
*/
///@name Ameba Common
///@{
#define SPI_DMA_RX_EN (1<<0)
#define SPI_DMA_TX_EN (1<<1)
enum {
SPI_SCLK_IDLE_LOW=0, // the SCLK is Low when SPI is inactive
SPI_SCLK_IDLE_HIGH=2 // the SCLK is High when SPI is inactive
};
// SPI Master mode: for continuous transfer, how the CS toggle:
enum {
SPI_CS_TOGGLE_EVERY_FRAME=0, // let SCPH=0 then the CS toggle every frame
SPI_CS_TOGGLE_START_STOP=1 // let SCPH=1 the CS toggle at start and stop
};
enum {
SPI_SCLK_TOGGLE_MIDDLE=0, // Serial Clk toggle at middle of 1st data bit and latch data at 1st Clk edge
SPI_SCLK_TOGGLE_START=1 // Serial Clk toggle at start of 1st data bit and latch data at 2nd Clk edge
};
typedef enum {
CS_0 = 0,
CS_1 = 1,
CS_2 = 2,
CS_3 = 3,
CS_4 = 4,
CS_5 = 5,
CS_6 = 6,
CS_7 = 7
}ChipSelect;
#define SPI_STATE_READY 0x00
#define SPI_STATE_RX_BUSY (1<<1)
#define SPI_STATE_TX_BUSY (1<<2)
typedef enum {
SpiRxIrq,
SpiTxIrq
} SpiIrq;
typedef void (*spi_irq_handler)(uint32_t id, SpiIrq event);
/**
* @brief Set SPI interrupt handler if needed.
* @param obj: spi object define in application software.
* @param handler: interrupt callback function
* @param id: interrupt callback parameter
* @retval none
*/
void spi_irq_hook(spi_t *obj, spi_irq_handler handler, uint32_t id);
/**
* @brief Set SPI interrupt bus tx done handler if needed.
* @param obj: spi object define in application software.
* @param handler: interrupt bus tx done callback function
* @param id: interrupt callback parameter
* @retval none
*/
void spi_bus_tx_done_irq_hook(spi_t *obj, spi_irq_handler handler, uint32_t id);
/**
* @brief Slave device to flush tx fifo.
* @param obj: spi slave object define in application software.
* @note : It will discard all data in both tx fifo and rx fifo
*/
void spi_slave_flush_fifo(spi_t * obj);
/**
* @brief slave recv target length data use interrupt mode.
* @param obj: spi slave object define in application software.
* @param rx_buffer: buffer to save data read from SPI FIFO.
* @param length: number of data bytes to be read.
* @retval : stream init status
*/
int32_t spi_slave_read_stream(spi_t *obj, char *rx_buffer, uint32_t length);
/**
* @brief slave send target length data use interrupt mode.
* @param obj: spi slave object define in application software.
* @param tx_buffer: buffer to be written to Tx FIFO.
* @param length: number of data bytes to be send.
* @retval : stream init status
*/
int32_t spi_slave_write_stream(spi_t *obj, char *tx_buffer, uint32_t length);
/**
* @brief master recv target length data use interrupt mode.
* @param obj: spi master object define in application software.
* @param rx_buffer: buffer to save data read from SPI FIFO.
* @param length: number of data bytes to be read.
* @retval : stream init status
*/
int32_t spi_master_read_stream(spi_t *obj, char *rx_buffer, uint32_t length);
/**
* @brief master send target length data use interrupt mode.
* @param obj: spi master object define in application software.
* @param tx_buffer: buffer to be written to Tx FIFO.
* @param length: number of data bytes to be send.
* @retval : stream init status
*/
int32_t spi_master_write_stream(spi_t *obj, char *tx_buffer, uint32_t length);
/**
* @brief master send & recv target length data use interrupt mode.
* @param obj: spi master object define in application software.
* @param tx_buffer: buffer to be written to Tx FIFO.
* @param rx_buffer: buffer to save data read from SPI FIFO.
* @param length: number of data bytes to be send & recv.
* @retval : stream init status
*/
int32_t spi_master_write_read_stream(spi_t *obj, char *tx_buffer, char *rx_buffer, uint32_t length);
/**
* @brief slave recv target length data use interrupt mode and timeout mechanism.
* @param obj: spi slave object define in application software.
* @param rx_buffer: buffer to save data read from SPI FIFO.
* @param length: number of data bytes to be read.
* @param timeout_ms: timeout waiting time.
* @retval : number of bytes read already
*/
int32_t spi_slave_read_stream_timeout(spi_t *obj, char *rx_buffer, uint32_t length, uint32_t timeout_ms);
/**
* @brief slave recv target length data use interrupt mode and stop if the spi bus is idle.
* @param obj: spi slave object define in application software.
* @param rx_buffer: buffer to save data read from SPI FIFO.
* @param length: number of data bytes to be read.
* @retval : number of bytes read already
*/
int32_t spi_slave_read_stream_terminate(spi_t *obj, char *rx_buffer, uint32_t length);
//#ifdef CONFIG_GDMA_EN
/**
* @brief slave recv target length data use DMA mode.
* @param obj: spi slave object define in application software.
* @param rx_buffer: buffer to save data read from SPI FIFO.
* @param length: number of data bytes to be read.
* @retval : stream init status
*/
int32_t spi_slave_read_stream_dma(spi_t *obj, char *rx_buffer, uint32_t length);
/**
* @brief slave send target length data use DMA mode.
* @param obj: spi slave object define in application software.
* @param tx_buffer: buffer to be written to Tx FIFO.
* @param length: number of data bytes to be send.
* @retval : stream init status
*/
int32_t spi_slave_write_stream_dma(spi_t *obj, char *tx_buffer, uint32_t length);
/**
* @brief master send & recv target length data use DMA mode.
* @param obj: spi master object define in application software.
* @param tx_buffer: buffer to be written to Tx FIFO.
* @param rx_buffer: buffer to save data read from SPI FIFO.
* @param length: number of data bytes to be send & recv.
* @retval : stream init status
*/
int32_t spi_master_write_read_stream_dma(spi_t * obj, char * tx_buffer, char * rx_buffer, uint32_t length);
/**
* @brief master recv target length data use DMA mode.
* @param obj: spi master object define in application software.
* @param rx_buffer: buffer to save data read from SPI FIFO.
* @param length: number of data bytes to be read.
* @retval : stream init status
* @note : DMA or Interrupt mode can be used to TX dummy data
*/
int32_t spi_master_read_stream_dma(spi_t *obj, char *rx_buffer, uint32_t length);
/**
* @brief master send target length data use DMA mode.
* @param obj: spi master object define in application software.
* @param tx_buffer: buffer to be written to Tx FIFO.
* @param length: number of data bytes to be send.
* @retval : stream init status
*/
int32_t spi_master_write_stream_dma(spi_t *obj, char *tx_buffer, uint32_t length);
/**
* @brief slave recv target length data use DMA mode and timeout mechanism.
* @param obj: spi slave object define in application software.
* @param rx_buffer: buffer to save data read from SPI FIFO.
* @param length: number of data bytes to be read.
* @param timeout_ms: timeout waiting time.
* @retval : number of bytes read already
*/
int32_t spi_slave_read_stream_dma_timeout(spi_t *obj, char *rx_buffer, uint32_t length, uint32_t timeout_ms);
/**
* @brief slave recv target length data use DMA mode and stop if the spi bus is idle.
* @param obj: spi slave object define in application software.
* @param rx_buffer: buffer to save data read from SPI FIFO.
* @param length: number of data bytes to be read.
* @retval : number of bytes read already
*/
int32_t spi_slave_read_stream_dma_terminate(spi_t * obj, char * rx_buffer, uint32_t length);
//#endif
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,125 @@
/** mbed Microcontroller Library
******************************************************************************
* @file sys_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed system API:
* -JTAG OFF
* -LOGUART ON/OFF
* -OTA image switch
* -System Reset
******************************************************************************
* @attention
*
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
******************************************************************************
*/
#ifndef MBED_SYS_API_H
#define MBED_SYS_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup sys SYSTEM
* @ingroup hal
* @brief system functions
* @{
*/
///@name Ameba Common
///@{
/**
* @brief Turn off the JTAG function
* @retval none
*/
void sys_jtag_off(void);
/**
* @brief switch OTA image if the othe OTA image is valid
* @retval none
* @note for AmebaZ, sys_clear_ota_signature is the same with sys_recover_ota_signature
*/
void sys_clear_ota_signature(void);
/**
* @brief switch OTA image if the othe OTA image is valid
* @retval none
* @note for AmebaZ, sys_clear_ota_signature is the same with sys_recover_ota_signature
*/
void sys_recover_ota_signature(void);
/**
* @brief open log uart
* @retval none
*/
void sys_log_uart_on(void);
/**
* @brief close log uart
* @retval none
*/
void sys_log_uart_off(void);
/**
* @brief store or load adc calibration parameter
* @param write: this parameter can be one of the following values:
* @arg 0: load adc calibration parameter offset & gain from flash system data region
* @arg 1: store adc calibration parameter offset & gain to flash system data region
* @param offset: pointer to adc parameter offset
* @param gain: pointer to adc parameter gain
* @retval none
*/
void sys_adc_calibration(u8 write, u16 *offset, u16 *gain);
/**
* @brief system software reset
* @retval none
*/
void sys_reset(void);
///@}
#if defined(CONFIG_PLATFORM_8195A) && (CONFIG_PLATFORM_8195A == 1)
///@name Ameba1 Only
///@{
/**
* @brief check whether is sdram power on
* @retval 1: power on
* 0: power off
*/
u8 sys_is_sdram_power_on(void);
/**
* @brief sdram power off
* @retval none
*/
void sys_sdram_off(void);
///@}
#endif //CONFIG_PLATFORM_8195A
#if defined(CONFIG_PLATFORM_8711B) && (CONFIG_PLATFORM_8711B == 1)
///@name AmebaZ Only
///@{
/**
* @brief vector reset
* @retval none
*/
void sys_cpu_reset(void);
///@}
#endif //CONFIG_PLATFORM_8711B
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,84 @@
/** mbed Microcontroller Library
******************************************************************************
* @file wdt_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed WDT API
******************************************************************************
* @attention
*
* Copyright (c) 2015, Realtek Semiconductor Corp.
* All rights reserved.
*
* This module is a confidential and proprietary property of RealTek and
* possession or use of this module requires written permission of RealTek.
******************************************************************************
*/
#ifndef MBED_WATCHDOG_API_H
#define MBED_WATCHDOG_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup wdt WDT
* @ingroup hal
* @brief wdt functions
* @{
*/
///@name Ameba Common
///@{
typedef void (*wdt_irq_handler)(uint32_t id);
/**
* @brief Initializes the watch dog, include time setting, mode register
* @param timeout_ms: the watch-dog timer timeout value, in ms.
* default action of timeout is to reset the whole system.
* @retval none
*/
void watchdog_init(uint32_t timeout_ms);
/**
* @brief Start the watchdog counting
* @param None
* @retval none
*/
void watchdog_start(void);
/**
* @brief Stop the watchdog counting
* @param None
* @retval none
*/
void watchdog_stop(void);
/**
* @brief Refresh the watchdog counting to prevent WDT timeout
* @param None
* @retval none
*/
void watchdog_refresh(void);
/**
* @brief Switch the watchdog timer to interrupt mode and
* register a watchdog timer timeout interrupt handler.
* The interrupt handler will be called when the watch-dog
* timer is timeout.
* @param handler: the callback function for WDT timeout interrupt.
* @param id: the parameter for the callback function
* @retval none
*/
void watchdog_irq_init(wdt_irq_handler handler, uint32_t id);
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,61 @@
/* 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_PERIPHERALNAMES_H
#define MBED_PERIPHERALNAMES_H
#include "cmsis.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
UART_0 = (int)UART0_DEV,
UART_1 = (int)UART1_DEV,
UART_2 = (int)UART2_DEV,
UART_3 = (int)UART3_DEV,
} UARTName;
typedef enum {
ADC0_0 = 0,
ADC0_1,
ADC0_2,
ADC0_3
} ADCName;
typedef enum {
SPI_0 = (int)SPI0_DEV,
SPI_1 = (int)SPI1_DEV,
} SPIName;
typedef enum {
I2C_0 = (int)I2C0_DEV,
} I2CName;
typedef enum {
PWM_0 = 1,
PWM_1,
PWM_2,
PWM_3,
PWM_4,
PWM_5
} PWMName;
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,120 @@
#ifndef _PINNAMES_H_
#define _PINNAMES_H_
#include "cmsis.h"
#ifdef __cplusplus
extern "C" {
#endif
#define PIN_DATA(PUPD, FUNC) (((PUPD) << 6) | (FUNC))
#define PIN_PIN_PUPD(X) ((X) & 0x03) /* PullNone/PullUp/PullDown */
#define PIN_FUNC(X) ((X) & 0x0F) /* PINMUX_FUNCTION_XXXX */
typedef enum {
PORT_A = 0,
PORT_B = 1,
} GPIO_PORT;
typedef enum {
PIN_INPUT = 0,
PIN_OUTPUT
} PinDirection;
/* (((port)<<5)|(pin)) */
typedef enum {
PA_0 = (PORT_A<<5|0),
PA_1 = (PORT_A<<5|1),
PA_2 = (PORT_A<<5|2),
PA_3 = (PORT_A<<5|3),
PA_4 = (PORT_A<<5|4),
PA_5 = (PORT_A<<5|5),
PA_6 = (PORT_A<<5|6),
PA_7 = (PORT_A<<5|7),
PA_8 = (PORT_A<<5|8),
PA_9 = (PORT_A<<5|9),
PA_10 = (PORT_A<<5|10),
PA_11 = (PORT_A<<5|11),
PA_12 = (PORT_A<<5|12),
PA_13 = (PORT_A<<5|13),
PA_14 = (PORT_A<<5|14),
PA_15 = (PORT_A<<5|15),
PA_16 = (PORT_A<<5|16),
PA_17 = (PORT_A<<5|17),
PA_18 = (PORT_A<<5|18),
PA_19 = (PORT_A<<5|19),
PA_20 = (PORT_A<<5|20),
PA_21 = (PORT_A<<5|21),
PA_22 = (PORT_A<<5|22),
PA_23 = (PORT_A<<5|23),
PA_24 = (PORT_A<<5|24),
PA_25 = (PORT_A<<5|25),
PA_26 = (PORT_A<<5|26),
PA_27 = (PORT_A<<5|27),
PA_28 = (PORT_A<<5|28),
PA_29 = (PORT_A<<5|29),
PA_30 = (PORT_A<<5|30),
PA_31 = (PORT_A<<5|31),
PB_0 = (PORT_B<<5|0),
PB_1 = (PORT_B<<5|1),
PB_2 = (PORT_B<<5|2),
PB_3 = (PORT_B<<5|3),
PB_4 = (PORT_B<<5|4),
PB_5 = (PORT_B<<5|5),
PB_6 = (PORT_B<<5|6),
PB_7 = (PORT_B<<5|7),
PB_8 = (PORT_B<<5|8),
PB_9 = (PORT_B<<5|9),
PB_10 = (PORT_B<<5|10),
PB_11 = (PORT_B<<5|11),
PB_12 = (PORT_B<<5|12),
PB_13 = (PORT_B<<5|13),
PB_14 = (PORT_B<<5|14),
PB_15 = (PORT_B<<5|15),
PB_16 = (PORT_B<<5|16),
PB_17 = (PORT_B<<5|17),
PB_18 = (PORT_B<<5|18),
PB_19 = (PORT_B<<5|19),
PB_20 = (PORT_B<<5|20),
PB_21 = (PORT_B<<5|21),
PB_22 = (PORT_B<<5|22),
PB_23 = (PORT_B<<5|23),
PB_24 = (PORT_B<<5|24),
PB_25 = (PORT_B<<5|25),
PB_26 = (PORT_B<<5|26),
PB_27 = (PORT_B<<5|27),
PB_28 = (PORT_B<<5|28),
PB_29 = (PORT_B<<5|29),
PB_30 = (PORT_B<<5|30),
PB_31 = (PORT_B<<5|31),
VBAT_MEAS = (0x7<<5|2),
AD_0 = PB_4, //CH0
AD_1 = PB_5, //CH1
AD_2 = PB_6, //CH2
AD_3 = PB_7, //CH3
AD_4 = PB_1, //CH4
AD_5 = PB_2, //CH5
AD_6 = PB_3, //CH6
AD_7 = VBAT_MEAS,//CH7
// Not connected
NC = (uint32_t)0xFFFFFFFF
} PinName;
typedef enum {
PullNone = 0, //IN HIGHZ
PullUp = 1,
PullDown = 2,
PullDefault = PullNone
} PinMode;
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,31 @@
/* 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_PORTNAMES_H
#define MBED_PORTNAMES_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
PortA = 0,
PortB = 1,
} PortName;
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,48 @@
/* 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_DEVICE_H
#define MBED_DEVICE_H
#define DEVICE_PORTIN 1
#define DEVICE_PORTOUT 1
#define DEVICE_PORTINOUT 1
#define DEVICE_INTERRUPTIN 1
#define DEVICE_ANALOGIN 1
#define DEVICE_ANALOGOUT 0
#define DEVICE_SERIAL 1
#define DEVICE_I2C 1
#define DEVICE_I2CSLAVE 1
#define DEVICE_SPI 1
#define DEVICE_SPISLAVE 1
#define DEVICE_CAN 0
#define DEVICE_RTC 1
#define DEVICE_ETHERNET 0
#define DEVICE_PWMOUT 1
#define DEVICE_SLEEP 1
#include "objects.h"
#endif

View file

@ -0,0 +1,32 @@
/* 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_OBJECT_H
#define MBED_GPIO_OBJECT_H
#include "mbed_assert.h"
#include "basic_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,130 @@
/* 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_OBJECTS_H
#define MBED_OBJECTS_H
#include "cmsis.h"
#include "PortNames.h"
#include "PeripheralNames.h"
#include "PinNames.h"
#include "rtl8721d.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct gpio_irq_s {
PinName pin;
} gpio_irq_t;
typedef struct gpio_s {
PinName pin;
} gpio_t;
struct port_s {
PortName port;
uint32_t mask;
};
struct serial_s {
uint8_t uart_idx;
uint32_t tx_len;
uint32_t rx_len;
};
struct spi_s {
/* user variables */
uint32_t spi_idx;
/* internal variables */
uint32_t irq_handler;
uint32_t irq_id;
uint32_t state;
uint8_t sclk;
uint32_t bus_tx_done_handler;
uint32_t bus_tx_done_irq_id;
};
struct pwmout_s {
uint8_t pwm_idx;
uint32_t period;//in us
float pulse;//in us
};
struct i2c_s {
uint32_t i2c_idx;
I2C_TypeDef * I2Cx;
};
struct flash_s {
FLASH_InitTypeDef SpicInitPara;
};
struct analogin_s {
uint8_t adc_idx;
};
struct gtimer_s {
void *handler;
uint32_t hid;
uint8_t timer_id;
uint8_t is_periodcal;
};
struct i2s_s {
uint8_t i2s_idx;
uint8_t sampling_rate;
uint8_t channel_num;
uint8_t word_length;
uint8_t direction;
};
struct gdma_s {
u8 index;
u8 ch_num;
IRQ_FUN user_cb;
u32 user_cb_data;
};
struct captouch_s {
CapTouch_CHInitTypeDef CT_Channel[4];
void* irq_handler_press;
void* irq_handler_release;
};
struct keyscan_s {
u32 row;
u32 col;
u32 clk;
u32 workmode; //0 for regular scan mode, 1 for event trigger mode
u32 keylimit;
u32 overctrl; //0 for discard new, 1 for discard oldest
};
struct lcdc_s{
u32 lcdc_type;
union{
LCDC_MCUInitTypeDef LCDC_MCUInitStruct;
LCDC_RGBInitTypeDef LCDC_RGBInitStruct;
LCDC_LEDInitTypeDef LCDC_LEDInitStruct;
}lcdc_if;
};
#ifdef __cplusplus
}
#endif
#endif