initial commit

This commit is contained in:
Tautvydas Belgeras 2018-06-05 16:16:17 +03:00
commit 60a7afcc83
2528 changed files with 1001987 additions and 0 deletions

View file

@ -0,0 +1,41 @@
/* 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 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,98 @@
/** mbed Microcontroller Library
******************************************************************************
* @file dma_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed GDMA 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_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 CONFIG_PLATFORM_8195A
///@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
/**@}*/
#ifdef __cplusplus
}
#endif
#endif // end of "#define MBED_GDMA_API_H"

View file

@ -0,0 +1,163 @@
/** mbed Microcontroller Library
******************************************************************************
* @file efuse_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed EFUSE 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_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 CONFIG_PLATFORM_8195A
///@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 CONFIG_PLATFORM_8711B
///@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
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif // MBED_EXT_EFUSE_API_EXT_H

View file

@ -0,0 +1,46 @@
/* 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 ETHERNET_EX_API_H
#define ETHERNET_EX_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
#define ETH_TX_DESC_SIZE 20 // 20 Bytes
#define ETH_RX_DESC_SIZE 16 // 16 Bytes
#define ETH_PKT_BUF_SIZE 1600
typedef void (*ethernet_callback)(uint32_t event, uint32_t data);
void ethernet_irq_hook(ethernet_callback callback);
/* Set the numbers of Tx/Rx descriptor */
void ethernet_set_descnum(uint8_t txdescCnt, uint8_t rxdescCnt);
/* Set the start address of Tx/Rx descriptor and packet buffer */
void ethernet_trx_pre_setting(uint8_t *TxDescAddr, uint8_t *RxDescAddr, uint8_t *pTxPktBuf, uint8_t *pRxPktBuf);
#ifdef __cplusplus
}
#endif
#endif // #ifndef ETHERNET_EX_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 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 CONFIG_PLATFORM_8195A
#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,213 @@
/** mbed Microcontroller Library
******************************************************************************
* @file flash_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed FLASH 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_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 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);
///@}
#if CONFIG_PLATFORM_8711B
///@name AmebaZ Only
///@{
/**
* @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,76 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_GPIO_API_H
#define MBED_GPIO_API_H
#include "device.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @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);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,65 @@
/* mbed Microcontroller Library
* Copyright (c) 2006-2013 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_GPIO_IRQ_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
} 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);
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif // end of #ifndef MBED_GPIO_IRQ_EX_API_H

View file

@ -0,0 +1,86 @@
/** mbed Microcontroller Library
******************************************************************************
* @file i2c_ex_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed API for I2C.
******************************************************************************
* @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 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,235 @@
/** mbed Microcontroller Library
******************************************************************************
* @file i2s_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_I2S_API_EXT_H
#define MBED_EXT_I2S_API_EXT_H
#include "device.h"
#include "ameba_soc.h"
#ifdef __cplusplus
extern "C" {
#endif
/** @addtogroup i2s I2S
* @ingroup hal
* @brief i2s functions
* @{
*/
///@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
};
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 CONFIG_PLATFORM_8195A
///@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 CONFIG_PLATFORM_8711B
///@name AmebaZ 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_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
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif

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 CONFIG_PLATFORM_8195A
#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,70 @@
/* 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_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,210 @@
/** mbed Microcontroller Library
******************************************************************************
* @file serial_ex_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_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 */
FifoLvHalf=2, /*!< 8-byte */
FifoLvFull=3 /*!< 14-byte */
} 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 sream or steam_dma RX.
* @param obj: uart object define in application software.
* @retval : HAL_Status
*/
int32_t serial_send_stream_abort(serial_t *obj);
/**
* @brief stop the sream or steam_dma TX.
* @param obj: uart object define in application software.
* @retval : HAL_Status
*/
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.
*/
int32_t serial_recv_stream_dma_timeout(serial_t *obj, char *prxbuf, uint32_t len, uint32_t timeout_ms, void *force_cs);
///@}
/*\@}*/
#ifdef __cplusplus
}
#endif
#endif // #ifndef MBED_SERIAL_EX_API_H

View file

@ -0,0 +1,291 @@
/** mbed Microcontroller Library
******************************************************************************
* @file sleep_ex_api.h
* @author
* @version V1.0.0
* @brief This file provides mbed API for SLEEP.
******************************************************************************
* @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_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 CONFIG_PLATFORM_8195A
///@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 CONFIG_PLATFORM_8711B
///@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 CONFIG_PLATFORM_8195A
///@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 CONFIG_PLATFORM_8711B
///@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 CONFIG_PLATFORM_8195A
///@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 CONFIG_PLATFORM_8711B
///@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,152 @@
/** mbed Microcontroller Library
******************************************************************************
* @file spdio_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed SPDIO 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 __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,252 @@
/** mbed Microcontroller Library
******************************************************************************
* @file spi_ex_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_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,133 @@
/** 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) 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_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 CONFIG_PLATFORM_8195A
///@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 CONFIG_PLATFORM_8711B
///@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,92 @@
/** mbed Microcontroller Library
******************************************************************************
* @file wdt_api.h
* @author
* @version V1.0.0
* @brief This file provides following mbed WDT 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_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