mirror of
https://github.com/rtlduino/RTL8710AF_GCC.git
synced 2026-07-01 00:55:39 +00:00
motify compile link error
motify compile link error
This commit is contained in:
parent
923914edae
commit
03e74a8e50
5418 changed files with 1367914 additions and 206149 deletions
|
|
@ -1,66 +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
|
||||
/* 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
|
||||
|
|
|
|||
|
|
@ -1,50 +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
|
||||
/* 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
|
||||
|
|
|
|||
|
|
@ -1,69 +1,69 @@
|
|||
|
||||
include $(MAKE_INCLUDE_GEN)
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
MODULE_IFLAGS = -I../
|
||||
|
||||
|
||||
ifeq ($(CONFIG_TOOLCHAIN_ARM_GCC), y)
|
||||
GCC_PROJ_BASE = ../../../../../
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/sw/lib/sw_lib/mbed/hal/
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/sw/lib/sw_lib/mbed/api/
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/sw/lib/sw_lib/mbed/common/
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/sw/os
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/sw/os/os_dep/include
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/sw/os/freertos/include
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/sw/os/freertos/portable/GCC/ARM_CM3
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/targets/cmsis/
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/targets/cmsis/TARGET_RTK/TARGET_8195A
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/targets/hal/TARGET_RTK/TARGET_8195A
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/targets/hal/TARGET_RTK/TARGET_8195A/rtl8195a
|
||||
endif
|
||||
|
||||
#*****************************************************************************#
|
||||
# Object FILE LIST #
|
||||
#*****************************************************************************#
|
||||
OBJS =
|
||||
OBJS_ROM =
|
||||
OBJS_RAM =
|
||||
ifeq ($(CONFIG_TIMER_MODULE),y)
|
||||
OBJS += us_ticker_api.o wait_api.o
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LIB_BUILD_RAM),y)
|
||||
OBJS = $(OBJS_RAM)
|
||||
else ifeq ($(CONFIG_RELEASE_BUILD_RAM_ALL),y)
|
||||
OBJS += $(OBJS_RAM)
|
||||
else ifeq ($(CONFIG_RELEASE_BUILD_LIBRARIES),y)
|
||||
OBJS = $(CSRC_ROM)
|
||||
else ifeq ($(CONFIG_NORMAL_BUILD),y)
|
||||
OBJS += $(CSRC_ROM)
|
||||
OBJS += $(CSRC_RAM)
|
||||
endif
|
||||
|
||||
|
||||
#*****************************************************************************#
|
||||
# RULES TO GENERATE TARGETS #
|
||||
#*****************************************************************************#
|
||||
|
||||
# Define the Rules to build the core targets
|
||||
all: CORE_TARGETS COPY_RAM_OBJS
|
||||
|
||||
#*****************************************************************************#
|
||||
# GENERATE OBJECT FILE
|
||||
#*****************************************************************************#
|
||||
CORE_TARGETS: $(OBJS)
|
||||
|
||||
|
||||
#*****************************************************************************#
|
||||
# RULES TO CLEAN TARGETS #
|
||||
#*****************************************************************************#
|
||||
clean:
|
||||
$(REMOVE) *.o
|
||||
$(REMOVE) *.i
|
||||
$(REMOVE) *.s
|
||||
$(REMOVE) *.d
|
||||
|
||||
-include $(DEPS)
|
||||
|
||||
include $(MAKE_INCLUDE_GEN)
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
MODULE_IFLAGS = -I../
|
||||
|
||||
|
||||
ifeq ($(CONFIG_TOOLCHAIN_ARM_GCC), y)
|
||||
GCC_PROJ_BASE = ../../../../../
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/sw/lib/sw_lib/mbed/hal/
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/sw/lib/sw_lib/mbed/api/
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/sw/lib/sw_lib/mbed/common/
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/sw/os
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/sw/os/os_dep/include
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/sw/os/freertos/include
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/sw/os/freertos/portable/GCC/ARM_CM3
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/targets/cmsis/
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/targets/cmsis/TARGET_RTK/TARGET_8195A
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/targets/hal/TARGET_RTK/TARGET_8195A
|
||||
MODULE_IFLAGS += -I$(GCC_PROJ_BASE)/targets/hal/TARGET_RTK/TARGET_8195A/rtl8195a
|
||||
endif
|
||||
|
||||
#*****************************************************************************#
|
||||
# Object FILE LIST #
|
||||
#*****************************************************************************#
|
||||
OBJS =
|
||||
OBJS_ROM =
|
||||
OBJS_RAM =
|
||||
ifeq ($(CONFIG_TIMER_MODULE),y)
|
||||
OBJS += us_ticker_api.o wait_api.o
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_LIB_BUILD_RAM),y)
|
||||
OBJS = $(OBJS_RAM)
|
||||
else ifeq ($(CONFIG_RELEASE_BUILD_RAM_ALL),y)
|
||||
OBJS += $(OBJS_RAM)
|
||||
else ifeq ($(CONFIG_RELEASE_BUILD_LIBRARIES),y)
|
||||
OBJS = $(CSRC_ROM)
|
||||
else ifeq ($(CONFIG_NORMAL_BUILD),y)
|
||||
OBJS += $(CSRC_ROM)
|
||||
OBJS += $(CSRC_RAM)
|
||||
endif
|
||||
|
||||
|
||||
#*****************************************************************************#
|
||||
# RULES TO GENERATE TARGETS #
|
||||
#*****************************************************************************#
|
||||
|
||||
# Define the Rules to build the core targets
|
||||
all: CORE_TARGETS COPY_RAM_OBJS
|
||||
|
||||
#*****************************************************************************#
|
||||
# GENERATE OBJECT FILE
|
||||
#*****************************************************************************#
|
||||
CORE_TARGETS: $(OBJS)
|
||||
|
||||
|
||||
#*****************************************************************************#
|
||||
# RULES TO CLEAN TARGETS #
|
||||
#*****************************************************************************#
|
||||
clean:
|
||||
$(REMOVE) *.o
|
||||
$(REMOVE) *.i
|
||||
$(REMOVE) *.s
|
||||
$(REMOVE) *.d
|
||||
|
||||
-include $(DEPS)
|
||||
|
|
|
|||
|
|
@ -1,39 +1,39 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_ANALOGIN_API_H
|
||||
#define MBED_ANALOGIN_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_ANALOGIN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct analogin_s analogin_t;
|
||||
|
||||
void analogin_init (analogin_t *obj, PinName pin);
|
||||
float analogin_read (analogin_t *obj);
|
||||
uint16_t analogin_read_u16(analogin_t *obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_ANALOGIN_API_H
|
||||
#define MBED_ANALOGIN_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_ANALOGIN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct analogin_s analogin_t;
|
||||
|
||||
void analogin_init (analogin_t *obj, PinName pin);
|
||||
float analogin_read (analogin_t *obj);
|
||||
uint16_t analogin_read_u16(analogin_t *obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,42 +1,42 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_ANALOGOUT_API_H
|
||||
#define MBED_ANALOGOUT_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_ANALOGOUT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct dac_s dac_t;
|
||||
|
||||
void analogout_init (dac_t *obj, PinName pin);
|
||||
void analogout_free (dac_t *obj);
|
||||
void analogout_write (dac_t *obj, float value);
|
||||
void analogout_write_u16(dac_t *obj, uint16_t value);
|
||||
float analogout_read (dac_t *obj);
|
||||
uint16_t analogout_read_u16 (dac_t *obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_ANALOGOUT_API_H
|
||||
#define MBED_ANALOGOUT_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_ANALOGOUT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct dac_s dac_t;
|
||||
|
||||
void analogout_init (dac_t *obj, PinName pin);
|
||||
void analogout_free (dac_t *obj);
|
||||
void analogout_write (dac_t *obj, float value);
|
||||
void analogout_write_u16(dac_t *obj, uint16_t value);
|
||||
float analogout_read (dac_t *obj);
|
||||
uint16_t analogout_read_u16 (dac_t *obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,80 +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
|
||||
/* 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
|
||||
|
|
|
|||
|
|
@ -1,63 +1,63 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_ETHERNET_API_H
|
||||
#define MBED_ETHERNET_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_ETHERNET
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Connection constants
|
||||
|
||||
int ethernet_init(void);
|
||||
void ethernet_free(void);
|
||||
|
||||
// write size bytes from data to ethernet buffer
|
||||
// return num bytes written
|
||||
// or -1 if size is too big
|
||||
int ethernet_write(const char *data, int size);
|
||||
|
||||
// send ethernet write buffer, returning the packet size sent
|
||||
int ethernet_send(void);
|
||||
|
||||
// recieve from ethernet buffer, returning packet size, or 0 if no packet
|
||||
int ethernet_receive(void);
|
||||
|
||||
// read size bytes in to data, return actual num bytes read (0..size)
|
||||
// if data == NULL, throw the bytes away
|
||||
int ethernet_read(char *data, int size);
|
||||
|
||||
// get the ethernet address
|
||||
void ethernet_address(char *mac);
|
||||
|
||||
// see if the link is up
|
||||
int ethernet_link(void);
|
||||
|
||||
// force link settings
|
||||
void ethernet_set_link(int speed, int duplex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_ETHERNET_API_H
|
||||
#define MBED_ETHERNET_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_ETHERNET
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// Connection constants
|
||||
|
||||
int ethernet_init(void);
|
||||
void ethernet_free(void);
|
||||
|
||||
// write size bytes from data to ethernet buffer
|
||||
// return num bytes written
|
||||
// or -1 if size is too big
|
||||
int ethernet_write(const char *data, int size);
|
||||
|
||||
// send ethernet write buffer, returning the packet size sent
|
||||
int ethernet_send(void);
|
||||
|
||||
// recieve from ethernet buffer, returning packet size, or 0 if no packet
|
||||
int ethernet_receive(void);
|
||||
|
||||
// read size bytes in to data, return actual num bytes read (0..size)
|
||||
// if data == NULL, throw the bytes away
|
||||
int ethernet_read(char *data, int size);
|
||||
|
||||
// get the ethernet address
|
||||
void ethernet_address(char *mac);
|
||||
|
||||
// see if the link is up
|
||||
int ethernet_link(void);
|
||||
|
||||
// force link settings
|
||||
void ethernet_set_link(int speed, int duplex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,51 +1,51 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_GPIO_API_H
|
||||
#define MBED_GPIO_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Set the given pin as GPIO
|
||||
* @param pin The pin to be set as GPIO
|
||||
* @return The GPIO port mask for this pin
|
||||
**/
|
||||
uint32_t gpio_set(PinName pin);
|
||||
|
||||
/* GPIO object */
|
||||
void gpio_init(gpio_t *obj, PinName pin);
|
||||
|
||||
void gpio_mode (gpio_t *obj, PinMode mode);
|
||||
void gpio_dir (gpio_t *obj, PinDirection direction);
|
||||
|
||||
void gpio_write(gpio_t *obj, int value);
|
||||
int gpio_read (gpio_t *obj);
|
||||
|
||||
// the following set of functions are generic and are implemented in the common gpio.c file
|
||||
void gpio_init_in(gpio_t* gpio, PinName pin);
|
||||
void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode);
|
||||
void gpio_init_out(gpio_t* gpio, PinName pin);
|
||||
void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value);
|
||||
void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_GPIO_API_H
|
||||
#define MBED_GPIO_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Set the given pin as GPIO
|
||||
* @param pin The pin to be set as GPIO
|
||||
* @return The GPIO port mask for this pin
|
||||
**/
|
||||
uint32_t gpio_set(PinName pin);
|
||||
|
||||
/* GPIO object */
|
||||
void gpio_init(gpio_t *obj, PinName pin);
|
||||
|
||||
void gpio_mode (gpio_t *obj, PinMode mode);
|
||||
void gpio_dir (gpio_t *obj, PinDirection direction);
|
||||
|
||||
void gpio_write(gpio_t *obj, int value);
|
||||
int gpio_read (gpio_t *obj);
|
||||
|
||||
// the following set of functions are generic and are implemented in the common gpio.c file
|
||||
void gpio_init_in(gpio_t* gpio, PinName pin);
|
||||
void gpio_init_in_ex(gpio_t* gpio, PinName pin, PinMode mode);
|
||||
void gpio_init_out(gpio_t* gpio, PinName pin);
|
||||
void gpio_init_out_ex(gpio_t* gpio, PinName pin, int value);
|
||||
void gpio_init_inout(gpio_t* gpio, PinName pin, PinDirection direction, PinMode mode, int value);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,47 +1,47 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_GPIO_IRQ_API_H
|
||||
#define MBED_GPIO_IRQ_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_INTERRUPTIN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
IRQ_NONE,
|
||||
IRQ_RISE,
|
||||
IRQ_FALL
|
||||
} gpio_irq_event;
|
||||
|
||||
typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event);
|
||||
|
||||
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id);
|
||||
void gpio_irq_free(gpio_irq_t *obj);
|
||||
void gpio_irq_set (gpio_irq_t *obj, gpio_irq_event event, uint32_t enable);
|
||||
void gpio_irq_enable(gpio_irq_t *obj);
|
||||
void gpio_irq_disable(gpio_irq_t *obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_GPIO_IRQ_API_H
|
||||
#define MBED_GPIO_IRQ_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_INTERRUPTIN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
IRQ_NONE,
|
||||
IRQ_RISE,
|
||||
IRQ_FALL
|
||||
} gpio_irq_event;
|
||||
|
||||
typedef void (*gpio_irq_handler)(uint32_t id, gpio_irq_event event);
|
||||
|
||||
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id);
|
||||
void gpio_irq_free(gpio_irq_t *obj);
|
||||
void gpio_irq_set (gpio_irq_t *obj, gpio_irq_event event, uint32_t enable);
|
||||
void gpio_irq_enable(gpio_irq_t *obj);
|
||||
void gpio_irq_disable(gpio_irq_t *obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,59 +1,59 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_I2C_API_H
|
||||
#define MBED_I2C_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_I2C
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct i2c_s i2c_t;
|
||||
|
||||
enum {
|
||||
I2C_ERROR_NO_SLAVE = -1,
|
||||
I2C_ERROR_BUS_BUSY = -2
|
||||
};
|
||||
|
||||
void i2c_init (i2c_t *obj, PinName sda, PinName scl);
|
||||
void i2c_frequency (i2c_t *obj, int hz);
|
||||
int i2c_start (i2c_t *obj);
|
||||
int i2c_stop (i2c_t *obj);
|
||||
int i2c_read (i2c_t *obj, int address, char *data, int length, int stop);
|
||||
int i2c_write (i2c_t *obj, int address, const char *data, int length, int stop);
|
||||
void i2c_reset (i2c_t *obj);
|
||||
int i2c_byte_read (i2c_t *obj, int last);
|
||||
int i2c_byte_write (i2c_t *obj, int data);
|
||||
|
||||
|
||||
#if DEVICE_I2CSLAVE
|
||||
void i2c_slave_mode (i2c_t *obj, int enable_slave);
|
||||
int i2c_slave_receive(i2c_t *obj);
|
||||
int i2c_slave_read (i2c_t *obj, char *data, int length);
|
||||
int i2c_slave_write (i2c_t *obj, const char *data, int length);
|
||||
void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_I2C_API_H
|
||||
#define MBED_I2C_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_I2C
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct i2c_s i2c_t;
|
||||
|
||||
enum {
|
||||
I2C_ERROR_NO_SLAVE = -1,
|
||||
I2C_ERROR_BUS_BUSY = -2
|
||||
};
|
||||
|
||||
void i2c_init (i2c_t *obj, PinName sda, PinName scl);
|
||||
void i2c_frequency (i2c_t *obj, int hz);
|
||||
int i2c_start (i2c_t *obj);
|
||||
int i2c_stop (i2c_t *obj);
|
||||
int i2c_read (i2c_t *obj, int address, char *data, int length, int stop);
|
||||
int i2c_write (i2c_t *obj, int address, const char *data, int length, int stop);
|
||||
void i2c_reset (i2c_t *obj);
|
||||
int i2c_byte_read (i2c_t *obj, int last);
|
||||
int i2c_byte_write (i2c_t *obj, int data);
|
||||
|
||||
|
||||
#if DEVICE_I2CSLAVE
|
||||
void i2c_slave_mode (i2c_t *obj, int enable_slave);
|
||||
int i2c_slave_receive(i2c_t *obj);
|
||||
int i2c_slave_read (i2c_t *obj, char *data, int length);
|
||||
int i2c_slave_write (i2c_t *obj, const char *data, int length);
|
||||
void i2c_slave_address(i2c_t *obj, int idx, uint32_t address, uint32_t mask);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,43 +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
|
||||
/* 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
|
||||
|
|
|
|||
|
|
@ -1,42 +1,42 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_PORTMAP_H
|
||||
#define MBED_PORTMAP_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_PORTIN || DEVICE_PORTOUT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct port_s port_t;
|
||||
|
||||
PinName port_pin(PortName port, int pin_n);
|
||||
|
||||
void port_init (port_t *obj, PortName port, int mask, PinDirection dir);
|
||||
void port_mode (port_t *obj, PinMode mode);
|
||||
void port_dir (port_t *obj, PinDirection dir);
|
||||
void port_write(port_t *obj, int value);
|
||||
int port_read (port_t *obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_PORTMAP_H
|
||||
#define MBED_PORTMAP_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_PORTIN || DEVICE_PORTOUT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct port_s port_t;
|
||||
|
||||
PinName port_pin(PortName port, int pin_n);
|
||||
|
||||
void port_init (port_t *obj, PortName port, int mask, PinDirection dir);
|
||||
void port_mode (port_t *obj, PinMode mode);
|
||||
void port_dir (port_t *obj, PinDirection dir);
|
||||
void port_write(port_t *obj, int value);
|
||||
int port_read (port_t *obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,49 +1,49 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_PWMOUT_API_H
|
||||
#define MBED_PWMOUT_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_PWMOUT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct pwmout_s pwmout_t;
|
||||
|
||||
void pwmout_init (pwmout_t* obj, PinName pin);
|
||||
void pwmout_free (pwmout_t* obj);
|
||||
|
||||
void pwmout_write (pwmout_t* obj, float percent);
|
||||
float pwmout_read (pwmout_t* obj);
|
||||
|
||||
void pwmout_period (pwmout_t* obj, float seconds);
|
||||
void pwmout_period_ms (pwmout_t* obj, int ms);
|
||||
void pwmout_period_us (pwmout_t* obj, int us);
|
||||
|
||||
void pwmout_pulsewidth (pwmout_t* obj, float seconds);
|
||||
void pwmout_pulsewidth_ms(pwmout_t* obj, int ms);
|
||||
void pwmout_pulsewidth_us(pwmout_t* obj, int us);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_PWMOUT_API_H
|
||||
#define MBED_PWMOUT_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_PWMOUT
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct pwmout_s pwmout_t;
|
||||
|
||||
void pwmout_init (pwmout_t* obj, PinName pin);
|
||||
void pwmout_free (pwmout_t* obj);
|
||||
|
||||
void pwmout_write (pwmout_t* obj, float percent);
|
||||
float pwmout_read (pwmout_t* obj);
|
||||
|
||||
void pwmout_period (pwmout_t* obj, float seconds);
|
||||
void pwmout_period_ms (pwmout_t* obj, int ms);
|
||||
void pwmout_period_us (pwmout_t* obj, int us);
|
||||
|
||||
void pwmout_pulsewidth (pwmout_t* obj, float seconds);
|
||||
void pwmout_pulsewidth_ms(pwmout_t* obj, int ms);
|
||||
void pwmout_pulsewidth_us(pwmout_t* obj, int us);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,42 +1,42 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_RTC_API_H
|
||||
#define MBED_RTC_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_RTC
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void rtc_init(void);
|
||||
void rtc_free(void);
|
||||
int rtc_isenabled(void);
|
||||
|
||||
time_t rtc_read(void);
|
||||
void rtc_write(time_t t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_RTC_API_H
|
||||
#define MBED_RTC_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_RTC
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void rtc_init(void);
|
||||
void rtc_free(void);
|
||||
int rtc_isenabled(void);
|
||||
|
||||
time_t rtc_read(void);
|
||||
void rtc_write(time_t t);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,78 +1,78 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_SERIAL_API_H
|
||||
#define MBED_SERIAL_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_SERIAL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ParityNone = 0,
|
||||
ParityOdd = 1,
|
||||
ParityEven = 2,
|
||||
ParityForced1 = 3,
|
||||
ParityForced0 = 4
|
||||
} SerialParity;
|
||||
|
||||
typedef enum {
|
||||
RxIrq,
|
||||
TxIrq
|
||||
} SerialIrq;
|
||||
|
||||
typedef enum {
|
||||
FlowControlNone,
|
||||
FlowControlRTS,
|
||||
FlowControlCTS,
|
||||
FlowControlRTSCTS
|
||||
} FlowControl;
|
||||
|
||||
typedef void (*uart_irq_handler)(uint32_t id, SerialIrq event);
|
||||
|
||||
typedef struct serial_s serial_t;
|
||||
|
||||
void serial_init (serial_t *obj, PinName tx, PinName rx);
|
||||
void serial_free (serial_t *obj);
|
||||
void serial_baud (serial_t *obj, int baudrate);
|
||||
void serial_format (serial_t *obj, int data_bits, SerialParity parity, int stop_bits);
|
||||
|
||||
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id);
|
||||
void serial_irq_set (serial_t *obj, SerialIrq irq, uint32_t enable);
|
||||
|
||||
int serial_getc (serial_t *obj);
|
||||
void serial_putc (serial_t *obj, int c);
|
||||
int serial_readable (serial_t *obj);
|
||||
int serial_writable (serial_t *obj);
|
||||
void serial_clear (serial_t *obj);
|
||||
|
||||
void serial_break_set (serial_t *obj);
|
||||
void serial_break_clear(serial_t *obj);
|
||||
|
||||
void serial_pinout_tx(PinName tx);
|
||||
|
||||
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_SERIAL_API_H
|
||||
#define MBED_SERIAL_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_SERIAL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ParityNone = 0,
|
||||
ParityOdd = 1,
|
||||
ParityEven = 2,
|
||||
ParityForced1 = 3,
|
||||
ParityForced0 = 4
|
||||
} SerialParity;
|
||||
|
||||
typedef enum {
|
||||
RxIrq,
|
||||
TxIrq
|
||||
} SerialIrq;
|
||||
|
||||
typedef enum {
|
||||
FlowControlNone,
|
||||
FlowControlRTS,
|
||||
FlowControlCTS,
|
||||
FlowControlRTSCTS
|
||||
} FlowControl;
|
||||
|
||||
typedef void (*uart_irq_handler)(uint32_t id, SerialIrq event);
|
||||
|
||||
typedef struct serial_s serial_t;
|
||||
|
||||
void serial_init (serial_t *obj, PinName tx, PinName rx);
|
||||
void serial_free (serial_t *obj);
|
||||
void serial_baud (serial_t *obj, int baudrate);
|
||||
void serial_format (serial_t *obj, int data_bits, SerialParity parity, int stop_bits);
|
||||
|
||||
void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id);
|
||||
void serial_irq_set (serial_t *obj, SerialIrq irq, uint32_t enable);
|
||||
|
||||
int serial_getc (serial_t *obj);
|
||||
void serial_putc (serial_t *obj, int c);
|
||||
int serial_readable (serial_t *obj);
|
||||
int serial_writable (serial_t *obj);
|
||||
void serial_clear (serial_t *obj);
|
||||
|
||||
void serial_break_set (serial_t *obj);
|
||||
void serial_break_clear(serial_t *obj);
|
||||
|
||||
void serial_pinout_tx(PinName tx);
|
||||
|
||||
void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,64 +1,64 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_SLEEP_API_H
|
||||
#define MBED_SLEEP_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_SLEEP
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Send the microcontroller to sleep
|
||||
*
|
||||
* The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the
|
||||
* system clock to the core is stopped until a reset or an interrupt occurs. This eliminates
|
||||
* dynamic power used by the processor, memory systems and buses. The processor, peripheral and
|
||||
* memory state are maintained, and the peripherals continue to work and can generate interrupts.
|
||||
*
|
||||
* The processor can be woken up by any internal peripheral interrupt or external pin interrupt.
|
||||
*
|
||||
* @note
|
||||
* The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
|
||||
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
|
||||
* able to access the LocalFileSystem
|
||||
*/
|
||||
void sleep(void);
|
||||
|
||||
/** Send the microcontroller to deep sleep
|
||||
*
|
||||
* This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode
|
||||
* has the same sleep features as sleep plus it powers down peripherals and clocks. All state
|
||||
* is still maintained.
|
||||
*
|
||||
* The processor can only be woken up by an external interrupt on a pin or a watchdog timer.
|
||||
*
|
||||
* @note
|
||||
* The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
|
||||
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
|
||||
* able to access the LocalFileSystem
|
||||
*/
|
||||
void deepsleep(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_SLEEP_API_H
|
||||
#define MBED_SLEEP_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_SLEEP
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Send the microcontroller to sleep
|
||||
*
|
||||
* The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the
|
||||
* system clock to the core is stopped until a reset or an interrupt occurs. This eliminates
|
||||
* dynamic power used by the processor, memory systems and buses. The processor, peripheral and
|
||||
* memory state are maintained, and the peripherals continue to work and can generate interrupts.
|
||||
*
|
||||
* The processor can be woken up by any internal peripheral interrupt or external pin interrupt.
|
||||
*
|
||||
* @note
|
||||
* The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
|
||||
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
|
||||
* able to access the LocalFileSystem
|
||||
*/
|
||||
void sleep(void);
|
||||
|
||||
/** Send the microcontroller to deep sleep
|
||||
*
|
||||
* This processor is setup ready for deep sleep, and sent to sleep using __WFI(). This mode
|
||||
* has the same sleep features as sleep plus it powers down peripherals and clocks. All state
|
||||
* is still maintained.
|
||||
*
|
||||
* The processor can only be woken up by an external interrupt on a pin or a watchdog timer.
|
||||
*
|
||||
* @note
|
||||
* The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
|
||||
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
|
||||
* able to access the LocalFileSystem
|
||||
*/
|
||||
void deepsleep(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,45 +1,45 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_SPI_API_H
|
||||
#define MBED_SPI_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_SPI
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct spi_s spi_t;
|
||||
|
||||
void spi_init (spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel);
|
||||
void spi_free (spi_t *obj);
|
||||
void spi_format (spi_t *obj, int bits, int mode, int slave);
|
||||
void spi_frequency (spi_t *obj, int hz);
|
||||
int spi_master_write (spi_t *obj, int value);
|
||||
int spi_slave_receive(spi_t *obj);
|
||||
int spi_slave_read (spi_t *obj);
|
||||
void spi_slave_write (spi_t *obj, int value);
|
||||
int spi_busy (spi_t *obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_SPI_API_H
|
||||
#define MBED_SPI_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_SPI
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct spi_s spi_t;
|
||||
|
||||
void spi_init (spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel);
|
||||
void spi_free (spi_t *obj);
|
||||
void spi_format (spi_t *obj, int bits, int mode, int slave);
|
||||
void spi_frequency (spi_t *obj, int hz);
|
||||
int spi_master_write (spi_t *obj, int value);
|
||||
int spi_slave_receive(spi_t *obj);
|
||||
int spi_slave_read (spi_t *obj);
|
||||
void spi_slave_write (spi_t *obj, int value);
|
||||
int spi_busy (spi_t *obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,44 +1,44 @@
|
|||
/* 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_GDMA_API_H
|
||||
#define MBED_GDMA_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct gdma_s {
|
||||
HAL_GDMA_OBJ gdma_obj;
|
||||
uint8_t gdma_allocated;
|
||||
};
|
||||
|
||||
typedef struct gdma_s gdma_t;
|
||||
|
||||
typedef void (*dma_irq_handler)(uint32_t id);
|
||||
|
||||
void dma_memcpy_init(gdma_t *dma_obj, dma_irq_handler handler, uint32_t id);
|
||||
void dma_memcpy_deinit(gdma_t *dma_obj);
|
||||
void dma_memcpy(gdma_t *dma_obj, void *dst, void* src, uint32_t len);
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // end of "#define MBED_GDMA_API_H"
|
||||
/* 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_GDMA_API_H
|
||||
#define MBED_GDMA_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct gdma_s {
|
||||
HAL_GDMA_OBJ gdma_obj;
|
||||
uint8_t gdma_allocated;
|
||||
};
|
||||
|
||||
typedef struct gdma_s gdma_t;
|
||||
|
||||
typedef void (*dma_irq_handler)(uint32_t id);
|
||||
|
||||
void dma_memcpy_init(gdma_t *dma_obj, dma_irq_handler handler, uint32_t id);
|
||||
void dma_memcpy_deinit(gdma_t *dma_obj);
|
||||
void dma_memcpy(gdma_t *dma_obj, void *dst, void* src, uint32_t len);
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // end of "#define MBED_GDMA_API_H"
|
||||
|
|
|
|||
|
|
@ -1,36 +1,36 @@
|
|||
/* 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
|
||||
|
||||
/* GPIO object */
|
||||
void gpio_direct_write(gpio_t *obj, BOOL value) ;
|
||||
void gpio_pull_ctrl(gpio_t *obj, PinMode pull_type);
|
||||
void gpio_deinit(gpio_t *obj, PinName pin);
|
||||
void gpio_change_dir(gpio_t *obj, PinDirection direction);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* 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
|
||||
|
||||
/* GPIO object */
|
||||
void gpio_direct_write(gpio_t *obj, BOOL value) ;
|
||||
void gpio_pull_ctrl(gpio_t *obj, PinMode pull_type);
|
||||
void gpio_deinit(gpio_t *obj, PinName pin);
|
||||
void gpio_change_dir(gpio_t *obj, PinDirection direction);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,40 +1,40 @@
|
|||
/* 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"
|
||||
|
||||
#if DEVICE_INTERRUPTIN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
IRQ_LOW = 3,
|
||||
IRQ_HIGH =4
|
||||
} gpio_irq_event_ex;
|
||||
|
||||
void gpio_irq_deinit(gpio_irq_t *obj);
|
||||
void gpio_irq_pull_ctrl(gpio_irq_t *obj, PinMode pull_type);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // end of "#if DEVICE_INTERRUPTIN"
|
||||
|
||||
/* 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"
|
||||
|
||||
#if DEVICE_INTERRUPTIN
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
IRQ_LOW = 3,
|
||||
IRQ_HIGH =4
|
||||
} gpio_irq_event_ex;
|
||||
|
||||
void gpio_irq_deinit(gpio_irq_t *obj);
|
||||
void gpio_irq_pull_ctrl(gpio_irq_t *obj, PinMode pull_type);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // end of "#if DEVICE_INTERRUPTIN"
|
||||
|
||||
#endif // end of #ifndef MBED_GPIO_IRQ_EX_API_H
|
||||
|
|
@ -1,66 +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 LOG_UART_API_H
|
||||
#define LOG_UART_API_H
|
||||
|
||||
#include "device.h"
|
||||
#include "serial_api.h"
|
||||
#include "hal_log_uart.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*loguart_irq_handler)(uint32_t id, LOG_UART_INT_ID event);
|
||||
|
||||
typedef struct log_uart_s log_uart_t;
|
||||
|
||||
int32_t log_uart_init (log_uart_t *obj, int baudrate, int data_bits, SerialParity parity, int stop_bits);
|
||||
void log_uart_free(log_uart_t *obj);
|
||||
void log_uart_baud(log_uart_t *obj, int baudrate);
|
||||
void log_uart_format(log_uart_t *obj, int data_bits, SerialParity parity, int stop_bits);
|
||||
void log_uart_irq_handler(log_uart_t *obj, loguart_irq_handler handler, uint32_t id);
|
||||
void log_uart_irq_set(log_uart_t *obj, LOG_UART_INT_ID irq, uint32_t enable);
|
||||
char log_uart_getc(log_uart_t *obj);
|
||||
void log_uart_putc(log_uart_t *obj, char c);
|
||||
int log_uart_readable(log_uart_t *obj);
|
||||
int log_uart_writable(log_uart_t *obj);
|
||||
void log_uart_clear(log_uart_t *obj);
|
||||
void log_uart_clear_tx(log_uart_t *obj);
|
||||
void log_uart_clear_rx(log_uart_t *obj);
|
||||
void log_uart_break_set(log_uart_t *obj);
|
||||
void log_uart_break_clear(log_uart_t *obj);
|
||||
void log_uart_tx_comp_handler(log_uart_t *obj, void *handler, uint32_t id);
|
||||
void log_uart_rx_comp_handler(log_uart_t *obj, void *handler, uint32_t id);
|
||||
void log_uart_line_status_handler(log_uart_t *obj, void *handler, uint32_t id);
|
||||
int32_t log_uart_recv (log_uart_t *obj, char *prxbuf, uint32_t len, uint32_t timeout_ms);
|
||||
int32_t log_uart_send (log_uart_t *obj, char *ptxbuf, uint32_t len, uint32_t timeout_ms);
|
||||
int32_t log_uart_recv_stream (log_uart_t *obj, char *prxbuf, uint32_t len);
|
||||
int32_t log_uart_send_stream (log_uart_t *obj, char *ptxbuf, uint32_t len);
|
||||
int32_t log_uart_recv_stream_timeout (log_uart_t *obj, char *prxbuf, uint32_t len,
|
||||
uint32_t timeout_ms, void *force_cs);
|
||||
int32_t log_uart_send_stream_abort (log_uart_t *obj);
|
||||
int32_t log_uart_recv_stream_abort (log_uart_t *obj);
|
||||
void log_uart_disable (log_uart_t *obj);
|
||||
void log_uart_enable (log_uart_t *obj);
|
||||
uint8_t log_uart_raed_lsr(log_uart_t *obj);
|
||||
uint8_t log_uart_raed_msr(log_uart_t *obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // end of "#ifndef LOG_UART_API_H"
|
||||
/* 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 LOG_UART_API_H
|
||||
#define LOG_UART_API_H
|
||||
|
||||
#include "device.h"
|
||||
#include "serial_api.h"
|
||||
#include "hal_log_uart.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*loguart_irq_handler)(uint32_t id, LOG_UART_INT_ID event);
|
||||
|
||||
typedef struct log_uart_s log_uart_t;
|
||||
|
||||
int32_t log_uart_init (log_uart_t *obj, int baudrate, int data_bits, SerialParity parity, int stop_bits);
|
||||
void log_uart_free(log_uart_t *obj);
|
||||
void log_uart_baud(log_uart_t *obj, int baudrate);
|
||||
void log_uart_format(log_uart_t *obj, int data_bits, SerialParity parity, int stop_bits);
|
||||
void log_uart_irq_handler(log_uart_t *obj, loguart_irq_handler handler, uint32_t id);
|
||||
void log_uart_irq_set(log_uart_t *obj, LOG_UART_INT_ID irq, uint32_t enable);
|
||||
char log_uart_getc(log_uart_t *obj);
|
||||
void log_uart_putc(log_uart_t *obj, char c);
|
||||
int log_uart_readable(log_uart_t *obj);
|
||||
int log_uart_writable(log_uart_t *obj);
|
||||
void log_uart_clear(log_uart_t *obj);
|
||||
void log_uart_clear_tx(log_uart_t *obj);
|
||||
void log_uart_clear_rx(log_uart_t *obj);
|
||||
void log_uart_break_set(log_uart_t *obj);
|
||||
void log_uart_break_clear(log_uart_t *obj);
|
||||
void log_uart_tx_comp_handler(log_uart_t *obj, void *handler, uint32_t id);
|
||||
void log_uart_rx_comp_handler(log_uart_t *obj, void *handler, uint32_t id);
|
||||
void log_uart_line_status_handler(log_uart_t *obj, void *handler, uint32_t id);
|
||||
int32_t log_uart_recv (log_uart_t *obj, char *prxbuf, uint32_t len, uint32_t timeout_ms);
|
||||
int32_t log_uart_send (log_uart_t *obj, char *ptxbuf, uint32_t len, uint32_t timeout_ms);
|
||||
int32_t log_uart_recv_stream (log_uart_t *obj, char *prxbuf, uint32_t len);
|
||||
int32_t log_uart_send_stream (log_uart_t *obj, char *ptxbuf, uint32_t len);
|
||||
int32_t log_uart_recv_stream_timeout (log_uart_t *obj, char *prxbuf, uint32_t len,
|
||||
uint32_t timeout_ms, void *force_cs);
|
||||
int32_t log_uart_send_stream_abort (log_uart_t *obj);
|
||||
int32_t log_uart_recv_stream_abort (log_uart_t *obj);
|
||||
void log_uart_disable (log_uart_t *obj);
|
||||
void log_uart_enable (log_uart_t *obj);
|
||||
uint8_t log_uart_raed_lsr(log_uart_t *obj);
|
||||
uint8_t log_uart_raed_msr(log_uart_t *obj);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // end of "#ifndef LOG_UART_API_H"
|
||||
|
|
|
|||
|
|
@ -1,70 +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
|
||||
/* 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
|
||||
|
|
|
|||
|
|
@ -1,60 +1,60 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_SERIAL_EX_API_H
|
||||
#define MBED_SERIAL_EX_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_SERIAL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// 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;
|
||||
|
||||
void serial_clear_tx(serial_t *obj);
|
||||
void serial_clear_rx(serial_t *obj);
|
||||
void serial_send_comp_handler(serial_t *obj, void *handler, uint32_t id);
|
||||
void serial_recv_comp_handler(serial_t *obj, void *handler, uint32_t id);
|
||||
int32_t serial_recv_blocked (serial_t *obj, char *prxbuf, uint32_t len, uint32_t timeout_ms);
|
||||
int32_t serial_send_blocked (serial_t *obj, char *ptxbuf, uint32_t len, uint32_t timeout_ms);
|
||||
int32_t serial_recv_stream (serial_t *obj, char *prxbuf, uint32_t len);
|
||||
int32_t serial_send_stream (serial_t *obj, char *ptxbuf, uint32_t len);
|
||||
int32_t serial_recv_stream_dma (serial_t *obj, char *prxbuf, uint32_t len);
|
||||
int32_t serial_send_stream_dma (serial_t *obj, char *ptxbuf, uint32_t len);
|
||||
int32_t serial_send_stream_abort (serial_t *obj);
|
||||
int32_t serial_recv_stream_abort (serial_t *obj);
|
||||
void serial_disable (serial_t *obj);
|
||||
void serial_enable (serial_t *obj);
|
||||
int32_t serial_recv_stream_timeout (serial_t *obj, char *prxbuf, uint32_t \
|
||||
len, uint32_t timeout_ms, void *force_cs);
|
||||
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
|
||||
|
||||
#endif // #ifndef MBED_SERIAL_EX_API_H
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_SERIAL_EX_API_H
|
||||
#define MBED_SERIAL_EX_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_SERIAL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// 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;
|
||||
|
||||
void serial_clear_tx(serial_t *obj);
|
||||
void serial_clear_rx(serial_t *obj);
|
||||
void serial_send_comp_handler(serial_t *obj, void *handler, uint32_t id);
|
||||
void serial_recv_comp_handler(serial_t *obj, void *handler, uint32_t id);
|
||||
int32_t serial_recv_blocked (serial_t *obj, char *prxbuf, uint32_t len, uint32_t timeout_ms);
|
||||
int32_t serial_send_blocked (serial_t *obj, char *ptxbuf, uint32_t len, uint32_t timeout_ms);
|
||||
int32_t serial_recv_stream (serial_t *obj, char *prxbuf, uint32_t len);
|
||||
int32_t serial_send_stream (serial_t *obj, char *ptxbuf, uint32_t len);
|
||||
int32_t serial_recv_stream_dma (serial_t *obj, char *prxbuf, uint32_t len);
|
||||
int32_t serial_send_stream_dma (serial_t *obj, char *ptxbuf, uint32_t len);
|
||||
int32_t serial_send_stream_abort (serial_t *obj);
|
||||
int32_t serial_recv_stream_abort (serial_t *obj);
|
||||
void serial_disable (serial_t *obj);
|
||||
void serial_enable (serial_t *obj);
|
||||
int32_t serial_recv_stream_timeout (serial_t *obj, char *prxbuf, uint32_t \
|
||||
len, uint32_t timeout_ms, void *force_cs);
|
||||
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
|
||||
|
||||
#endif // #ifndef MBED_SERIAL_EX_API_H
|
||||
|
|
|
|||
|
|
@ -1,98 +1,98 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_SLEEP_EX_API_H
|
||||
#define MBED_SLEEP_EX_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_SLEEP
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* 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;
|
||||
/** Send the microcontroller to sleep
|
||||
*
|
||||
* The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the
|
||||
* system clock to the core is stopped until a reset or an interrupt occurs. This eliminates
|
||||
* dynamic power used by the processor, memory systems and buses. The processor, peripheral and
|
||||
* memory state are maintained, and the peripherals continue to work and can generate interrupts.
|
||||
*
|
||||
* The processor can be woken up by any internal peripheral interrupt or external pin interrupt.
|
||||
*
|
||||
* @note
|
||||
* The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
|
||||
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
|
||||
* able to access the LocalFileSystem
|
||||
*/
|
||||
void sleep_ex(uint32_t wakeup_event, uint32_t sleep_duration);
|
||||
void sleep_ex_selective(uint32_t wakeup_event, uint32_t sleep_duration, uint32_t clk_sourec_enable, uint32_t sdr_enable);
|
||||
|
||||
void standby_wakeup_event_add(uint32_t wakeup_event, uint32_t sleep_duration_ms, uint32_t gpio_active);
|
||||
void standby_wakeup_event_del(uint32_t wakeup_event);
|
||||
void deepstandby_ex(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 timer.
|
||||
*
|
||||
* @note
|
||||
* The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
|
||||
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
|
||||
* able to access the LocalFileSystem
|
||||
*/
|
||||
void deepsleep_ex(uint32_t wakeup_event, uint32_t sleep_duration);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_SLEEP_EX_API_H
|
||||
#define MBED_SLEEP_EX_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_SLEEP
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* 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;
|
||||
/** Send the microcontroller to sleep
|
||||
*
|
||||
* The processor is setup ready for sleep, and sent to sleep using __WFI(). In this mode, the
|
||||
* system clock to the core is stopped until a reset or an interrupt occurs. This eliminates
|
||||
* dynamic power used by the processor, memory systems and buses. The processor, peripheral and
|
||||
* memory state are maintained, and the peripherals continue to work and can generate interrupts.
|
||||
*
|
||||
* The processor can be woken up by any internal peripheral interrupt or external pin interrupt.
|
||||
*
|
||||
* @note
|
||||
* The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
|
||||
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
|
||||
* able to access the LocalFileSystem
|
||||
*/
|
||||
void sleep_ex(uint32_t wakeup_event, uint32_t sleep_duration);
|
||||
void sleep_ex_selective(uint32_t wakeup_event, uint32_t sleep_duration, uint32_t clk_sourec_enable, uint32_t sdr_enable);
|
||||
|
||||
void standby_wakeup_event_add(uint32_t wakeup_event, uint32_t sleep_duration_ms, uint32_t gpio_active);
|
||||
void standby_wakeup_event_del(uint32_t wakeup_event);
|
||||
void deepstandby_ex(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 timer.
|
||||
*
|
||||
* @note
|
||||
* The mbed interface semihosting is disconnected as part of going to sleep, and can not be restored.
|
||||
* Flash re-programming and the USB serial port will remain active, but the mbed program will no longer be
|
||||
* able to access the LocalFileSystem
|
||||
*/
|
||||
void deepsleep_ex(uint32_t wakeup_event, uint32_t sleep_duration);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,94 +1,94 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_SPI_EXT_API_H
|
||||
#define MBED_SPI_EXT_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_SPI
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#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);
|
||||
|
||||
void spi_irq_hook(spi_t *obj, spi_irq_handler handler, uint32_t id);
|
||||
void spi_bus_tx_done_irq_hook(spi_t *obj, spi_irq_handler handler, uint32_t id);
|
||||
int32_t spi_slave_read_stream(spi_t *obj, char *rx_buffer, uint32_t length);
|
||||
int32_t spi_slave_write_stream(spi_t *obj, char *tx_buffer, uint32_t length);
|
||||
int32_t spi_master_read_stream(spi_t *obj, char *rx_buffer, uint32_t length);
|
||||
int32_t spi_master_write_stream(spi_t *obj, char *tx_buffer, uint32_t length);
|
||||
int32_t spi_master_write_read_stream(spi_t *obj, char *tx_buffer,
|
||||
char *rx_buffer, uint32_t length);
|
||||
int32_t spi_slave_read_stream_timeout(spi_t *obj, char *rx_buffer, uint32_t length, uint32_t timeout_ms);
|
||||
|
||||
#ifdef CONFIG_GDMA_EN
|
||||
int32_t spi_slave_read_stream_dma(spi_t *obj, char *rx_buffer, uint32_t length);
|
||||
int32_t spi_slave_write_stream_dma(spi_t *obj, char *tx_buffer, uint32_t length);
|
||||
int32_t spi_master_write_read_stream_dma(spi_t * obj, char * tx_buffer, char * rx_buffer, uint32_t length);
|
||||
int32_t spi_master_read_stream_dma(spi_t *obj, char *rx_buffer, uint32_t length);
|
||||
int32_t spi_master_write_stream_dma(spi_t *obj, char *tx_buffer, uint32_t length);
|
||||
int32_t spi_slave_read_stream_dma_timeout(spi_t *obj, char *rx_buffer, uint32_t length, uint32_t timeout_ms);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_SPI_EXT_API_H
|
||||
#define MBED_SPI_EXT_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#if DEVICE_SPI
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#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);
|
||||
|
||||
void spi_irq_hook(spi_t *obj, spi_irq_handler handler, uint32_t id);
|
||||
void spi_bus_tx_done_irq_hook(spi_t *obj, spi_irq_handler handler, uint32_t id);
|
||||
int32_t spi_slave_read_stream(spi_t *obj, char *rx_buffer, uint32_t length);
|
||||
int32_t spi_slave_write_stream(spi_t *obj, char *tx_buffer, uint32_t length);
|
||||
int32_t spi_master_read_stream(spi_t *obj, char *rx_buffer, uint32_t length);
|
||||
int32_t spi_master_write_stream(spi_t *obj, char *tx_buffer, uint32_t length);
|
||||
int32_t spi_master_write_read_stream(spi_t *obj, char *tx_buffer,
|
||||
char *rx_buffer, uint32_t length);
|
||||
int32_t spi_slave_read_stream_timeout(spi_t *obj, char *rx_buffer, uint32_t length, uint32_t timeout_ms);
|
||||
|
||||
#ifdef CONFIG_GDMA_EN
|
||||
int32_t spi_slave_read_stream_dma(spi_t *obj, char *rx_buffer, uint32_t length);
|
||||
int32_t spi_slave_write_stream_dma(spi_t *obj, char *tx_buffer, uint32_t length);
|
||||
int32_t spi_master_write_read_stream_dma(spi_t * obj, char * tx_buffer, char * rx_buffer, uint32_t length);
|
||||
int32_t spi_master_read_stream_dma(spi_t *obj, char *rx_buffer, uint32_t length);
|
||||
int32_t spi_master_write_stream_dma(spi_t *obj, char *tx_buffer, uint32_t length);
|
||||
int32_t spi_slave_read_stream_dma_timeout(spi_t *obj, char *rx_buffer, uint32_t length, uint32_t timeout_ms);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,52 +1,52 @@
|
|||
/* 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_WATCHDOG_API_H
|
||||
#define MBED_WATCHDOG_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Turn off the JTAG function
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void sys_jtag_off(void);
|
||||
void sys_clear_ota_signature(void);
|
||||
void sys_recover_ota_signature(void);
|
||||
void sys_log_uart_on(void);
|
||||
void sys_log_uart_off(void);
|
||||
void sys_adc_calibration(u8 write, u16 *offset, u16 *gain);
|
||||
u8 sys_is_sdram_power_on(void);
|
||||
void sys_sdram_off(void);
|
||||
|
||||
/**
|
||||
* @brief system software reset
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void sys_reset(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* 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_WATCHDOG_API_H
|
||||
#define MBED_WATCHDOG_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Turn off the JTAG function
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void sys_jtag_off(void);
|
||||
void sys_clear_ota_signature(void);
|
||||
void sys_recover_ota_signature(void);
|
||||
void sys_log_uart_on(void);
|
||||
void sys_log_uart_off(void);
|
||||
void sys_adc_calibration(u8 write, u16 *offset, u16 *gain);
|
||||
u8 sys_is_sdram_power_on(void);
|
||||
void sys_sdram_off(void);
|
||||
|
||||
/**
|
||||
* @brief system software reset
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void sys_reset(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,61 +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_WATCHDOG_API_H
|
||||
#define MBED_WATCHDOG_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*wdt_irq_handler)(uint32_t id);
|
||||
|
||||
/** Initial the watch dog time setting
|
||||
*
|
||||
* This function will initial and enable the watchdog timer with a given timeout value.
|
||||
* When the watchdog timer timeout event is triggered, the system will be reset. User also can
|
||||
* register a callback function to handle the watchdog timer timeout event.
|
||||
*/
|
||||
void watchdog_init(uint32_t timeout_ms);
|
||||
|
||||
/** Start the watchdog counting
|
||||
*
|
||||
* This function will active the watchdog timer down counting. When the watchdog timer count down
|
||||
* to 0, a callback function will be called or the system will be reset.
|
||||
*/
|
||||
void watchdog_start(void);
|
||||
|
||||
/** Stop the watchdog counting
|
||||
*
|
||||
* This function will stop the watchdog timer down counting. If a user application aware a
|
||||
* procedure may takes too long and cause the watchdog timer timeout, the application use this
|
||||
* function to stop the watchdog timer to prevent the watchdog timer timeout.
|
||||
*/
|
||||
void watchdog_stop(void);
|
||||
|
||||
/** Refresh the watchdog counting
|
||||
*
|
||||
* This function will reload the watchdog timer counting value. Usually a application do the watchdog
|
||||
* timer reflash in the main loop to prevent the watchdog timer timeout.
|
||||
*/
|
||||
void watchdog_refresh(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* 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_WATCHDOG_API_H
|
||||
#define MBED_WATCHDOG_API_H
|
||||
|
||||
#include "device.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*wdt_irq_handler)(uint32_t id);
|
||||
|
||||
/** Initial the watch dog time setting
|
||||
*
|
||||
* This function will initial and enable the watchdog timer with a given timeout value.
|
||||
* When the watchdog timer timeout event is triggered, the system will be reset. User also can
|
||||
* register a callback function to handle the watchdog timer timeout event.
|
||||
*/
|
||||
void watchdog_init(uint32_t timeout_ms);
|
||||
|
||||
/** Start the watchdog counting
|
||||
*
|
||||
* This function will active the watchdog timer down counting. When the watchdog timer count down
|
||||
* to 0, a callback function will be called or the system will be reset.
|
||||
*/
|
||||
void watchdog_start(void);
|
||||
|
||||
/** Stop the watchdog counting
|
||||
*
|
||||
* This function will stop the watchdog timer down counting. If a user application aware a
|
||||
* procedure may takes too long and cause the watchdog timer timeout, the application use this
|
||||
* function to stop the watchdog timer to prevent the watchdog timer timeout.
|
||||
*/
|
||||
void watchdog_stop(void);
|
||||
|
||||
/** Refresh the watchdog counting
|
||||
*
|
||||
* This function will reload the watchdog timer counting value. Usually a application do the watchdog
|
||||
* timer reflash in the main loop to prevent the watchdog timer timeout.
|
||||
*/
|
||||
void watchdog_refresh(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
/* mbed Microcontroller Library - CMSIS
|
||||
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
|
||||
*
|
||||
* A generic CMSIS include header, pulling in RTL8195A specifics
|
||||
*/
|
||||
|
||||
#ifndef MBED_CMSIS_H
|
||||
#define MBED_CMSIS_H
|
||||
|
||||
#include <platform/platform_stdlib.h>
|
||||
#include <hal_platform.h>
|
||||
|
||||
#endif
|
||||
|
||||
/* mbed Microcontroller Library - CMSIS
|
||||
* Copyright (C) 2009-2011 ARM Limited. All rights reserved.
|
||||
*
|
||||
* A generic CMSIS include header, pulling in RTL8195A specifics
|
||||
*/
|
||||
|
||||
#ifndef MBED_CMSIS_H
|
||||
#define MBED_CMSIS_H
|
||||
|
||||
#include <platform/platform_stdlib.h>
|
||||
#include <hal_platform.h>
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,100 +1,100 @@
|
|||
/* 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
|
||||
|
||||
#if 0
|
||||
typedef enum {
|
||||
UART_1 = (int)USART1_BASE,
|
||||
UART_2 = (int)USART2_BASE,
|
||||
UART_3 = (int)USART3_BASE,
|
||||
UART_4 = (int)UART4_BASE,
|
||||
UART_5 = (int)UART5_BASE,
|
||||
UART_6 = (int)USART6_BASE
|
||||
} UARTName;
|
||||
|
||||
typedef enum {
|
||||
ADC0_0 = 0,
|
||||
ADC0_1,
|
||||
ADC0_2,
|
||||
ADC0_3,
|
||||
ADC0_4,
|
||||
ADC0_5,
|
||||
ADC0_6,
|
||||
ADC0_7,
|
||||
ADC0_8,
|
||||
ADC0_9,
|
||||
ADC0_10,
|
||||
ADC0_11,
|
||||
ADC0_12,
|
||||
ADC0_13,
|
||||
ADC0_14,
|
||||
ADC0_15
|
||||
} ADCName;
|
||||
|
||||
typedef enum {
|
||||
DAC_0 = 0,
|
||||
DAC_1
|
||||
} DACName;
|
||||
|
||||
typedef enum {
|
||||
SPI_1 = (int)SPI1_BASE,
|
||||
SPI_2 = (int)SPI2_BASE,
|
||||
SPI_3 = (int)SPI3_BASE,
|
||||
} SPIName;
|
||||
|
||||
typedef enum {
|
||||
I2C_1 = (int)I2C1_BASE,
|
||||
I2C_2 = (int)I2C2_BASE,
|
||||
I2C_3 = (int)I2C3_BASE
|
||||
} I2CName;
|
||||
|
||||
typedef enum {
|
||||
PWM_1 = 1,
|
||||
PWM_2,
|
||||
PWM_3,
|
||||
PWM_4,
|
||||
PWM_5,
|
||||
PWM_6
|
||||
} PWMName;
|
||||
|
||||
typedef enum {
|
||||
CAN_1 = (int)CAN1_BASE,
|
||||
CAN_2 = (int)CAN2_BASE
|
||||
} CANName;
|
||||
#endif
|
||||
|
||||
#define STDIO_UART_TX PA_6
|
||||
#define STDIO_UART_RX PA_7
|
||||
#define STDIO_UART UART0
|
||||
|
||||
typedef enum {
|
||||
DAC_0 = 0,
|
||||
DAC_1
|
||||
} DACName;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* 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
|
||||
|
||||
#if 0
|
||||
typedef enum {
|
||||
UART_1 = (int)USART1_BASE,
|
||||
UART_2 = (int)USART2_BASE,
|
||||
UART_3 = (int)USART3_BASE,
|
||||
UART_4 = (int)UART4_BASE,
|
||||
UART_5 = (int)UART5_BASE,
|
||||
UART_6 = (int)USART6_BASE
|
||||
} UARTName;
|
||||
|
||||
typedef enum {
|
||||
ADC0_0 = 0,
|
||||
ADC0_1,
|
||||
ADC0_2,
|
||||
ADC0_3,
|
||||
ADC0_4,
|
||||
ADC0_5,
|
||||
ADC0_6,
|
||||
ADC0_7,
|
||||
ADC0_8,
|
||||
ADC0_9,
|
||||
ADC0_10,
|
||||
ADC0_11,
|
||||
ADC0_12,
|
||||
ADC0_13,
|
||||
ADC0_14,
|
||||
ADC0_15
|
||||
} ADCName;
|
||||
|
||||
typedef enum {
|
||||
DAC_0 = 0,
|
||||
DAC_1
|
||||
} DACName;
|
||||
|
||||
typedef enum {
|
||||
SPI_1 = (int)SPI1_BASE,
|
||||
SPI_2 = (int)SPI2_BASE,
|
||||
SPI_3 = (int)SPI3_BASE,
|
||||
} SPIName;
|
||||
|
||||
typedef enum {
|
||||
I2C_1 = (int)I2C1_BASE,
|
||||
I2C_2 = (int)I2C2_BASE,
|
||||
I2C_3 = (int)I2C3_BASE
|
||||
} I2CName;
|
||||
|
||||
typedef enum {
|
||||
PWM_1 = 1,
|
||||
PWM_2,
|
||||
PWM_3,
|
||||
PWM_4,
|
||||
PWM_5,
|
||||
PWM_6
|
||||
} PWMName;
|
||||
|
||||
typedef enum {
|
||||
CAN_1 = (int)CAN1_BASE,
|
||||
CAN_2 = (int)CAN2_BASE
|
||||
} CANName;
|
||||
#endif
|
||||
|
||||
#define STDIO_UART_TX PA_6
|
||||
#define STDIO_UART_RX PA_7
|
||||
#define STDIO_UART UART0
|
||||
|
||||
typedef enum {
|
||||
DAC_0 = 0,
|
||||
DAC_1
|
||||
} DACName;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,215 +1,215 @@
|
|||
|
||||
#ifndef _PINNAMES_H_
|
||||
#define _PINNAMES_H_
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PORT_A = 0,
|
||||
PORT_B = 1,
|
||||
PORT_C = 2,
|
||||
PORT_D = 3,
|
||||
PORT_E = 4,
|
||||
PORT_F = 5,
|
||||
PORT_G = 6,
|
||||
PORT_H = 7,
|
||||
PORT_I = 8,
|
||||
PORT_J = 9,
|
||||
PORT_K = 10,
|
||||
|
||||
PORT_V = 11,
|
||||
PORT_U = 12,
|
||||
PORT_MAX
|
||||
} GPIO_PORT;
|
||||
|
||||
#define RTL_PIN_PERI(FUN, IDX, SEL) ((int)(((FUN) << 8) | ((IDX)<<4) | (SEL)))
|
||||
#define RTL_PIN_FUNC(FUN, SEL) ((int)(((FUN) << 7) | (SEL)))
|
||||
#define RTL_GET_PERI_SEL(peri) ((int)((peri)&0x0F))
|
||||
#define RTL_GET_PERI_IDX(peri) ((int)(((peri) >> 4)&0x0F))
|
||||
|
||||
typedef enum {
|
||||
PIN_INPUT=0,
|
||||
PIN_OUTPUT
|
||||
} PinDirection;
|
||||
|
||||
typedef enum {
|
||||
PA_0 = (PORT_A<<4|0),
|
||||
PA_1 = (PORT_A<<4|1),
|
||||
PA_2 = (PORT_A<<4|2),
|
||||
PA_3 = (PORT_A<<4|3),
|
||||
PA_4 = (PORT_A<<4|4),
|
||||
PA_5 = (PORT_A<<4|5),
|
||||
PA_6 = (PORT_A<<4|6),
|
||||
PA_7 = (PORT_A<<4|7),
|
||||
|
||||
PB_0 = (PORT_B<<4|0),
|
||||
PB_1 = (PORT_B<<4|1),
|
||||
PB_2 = (PORT_B<<4|2),
|
||||
PB_3 = (PORT_B<<4|3),
|
||||
PB_4 = (PORT_B<<4|4),
|
||||
PB_5 = (PORT_B<<4|5),
|
||||
PB_6 = (PORT_B<<4|6),
|
||||
PB_7 = (PORT_B<<4|7),
|
||||
|
||||
PC_0 = (PORT_C<<4|0),
|
||||
PC_1 = (PORT_C<<4|1),
|
||||
PC_2 = (PORT_C<<4|2),
|
||||
PC_3 = (PORT_C<<4|3),
|
||||
PC_4 = (PORT_C<<4|4),
|
||||
PC_5 = (PORT_C<<4|5),
|
||||
PC_6 = (PORT_C<<4|6),
|
||||
PC_7 = (PORT_C<<4|7),
|
||||
PC_8 = (PORT_C<<4|8),
|
||||
PC_9 = (PORT_C<<4|9),
|
||||
|
||||
PD_0 = (PORT_D<<4|0),
|
||||
PD_1 = (PORT_D<<4|1),
|
||||
PD_2 = (PORT_D<<4|2),
|
||||
PD_3 = (PORT_D<<4|3),
|
||||
PD_4 = (PORT_D<<4|4),
|
||||
PD_5 = (PORT_D<<4|5),
|
||||
PD_6 = (PORT_D<<4|6),
|
||||
PD_7 = (PORT_D<<4|7),
|
||||
PD_8 = (PORT_D<<4|8),
|
||||
PD_9 = (PORT_D<<4|9),
|
||||
|
||||
PE_0 = (PORT_E<<4|0),
|
||||
PE_1 = (PORT_E<<4|1),
|
||||
PE_2 = (PORT_E<<4|2),
|
||||
PE_3 = (PORT_E<<4|3),
|
||||
PE_4 = (PORT_E<<4|4),
|
||||
PE_5 = (PORT_E<<4|5),
|
||||
PE_6 = (PORT_E<<4|6),
|
||||
PE_7 = (PORT_E<<4|7),
|
||||
PE_8 = (PORT_E<<4|8),
|
||||
PE_9 = (PORT_E<<4|9),
|
||||
PE_A = (PORT_E<<4|10),
|
||||
|
||||
PF_0 = (PORT_F<<4|0),
|
||||
PF_1 = (PORT_F<<4|1),
|
||||
PF_2 = (PORT_F<<4|2),
|
||||
PF_3 = (PORT_F<<4|3),
|
||||
PF_4 = (PORT_F<<4|4),
|
||||
PF_5 = (PORT_F<<4|5),
|
||||
// PF_6 = (PORT_F<<4|6),
|
||||
// PF_7 = (PORT_F<<4|7),
|
||||
|
||||
PG_0 = (PORT_G<<4|0),
|
||||
PG_1 = (PORT_G<<4|1),
|
||||
PG_2 = (PORT_G<<4|2),
|
||||
PG_3 = (PORT_G<<4|3),
|
||||
PG_4 = (PORT_G<<4|4),
|
||||
PG_5 = (PORT_G<<4|5),
|
||||
PG_6 = (PORT_G<<4|6),
|
||||
PG_7 = (PORT_G<<4|7),
|
||||
|
||||
PH_0 = (PORT_H<<4|0),
|
||||
PH_1 = (PORT_H<<4|1),
|
||||
PH_2 = (PORT_H<<4|2),
|
||||
PH_3 = (PORT_H<<4|3),
|
||||
PH_4 = (PORT_H<<4|4),
|
||||
PH_5 = (PORT_H<<4|5),
|
||||
PH_6 = (PORT_H<<4|6),
|
||||
PH_7 = (PORT_H<<4|7),
|
||||
|
||||
PI_0 = (PORT_I<<4|0),
|
||||
PI_1 = (PORT_I<<4|1),
|
||||
PI_2 = (PORT_I<<4|2),
|
||||
PI_3 = (PORT_I<<4|3),
|
||||
PI_4 = (PORT_I<<4|4),
|
||||
PI_5 = (PORT_I<<4|5),
|
||||
PI_6 = (PORT_I<<4|6),
|
||||
PI_7 = (PORT_I<<4|7),
|
||||
|
||||
PJ_0 = (PORT_J<<4|0),
|
||||
PJ_1 = (PORT_J<<4|1),
|
||||
PJ_2 = (PORT_J<<4|2),
|
||||
PJ_3 = (PORT_J<<4|3),
|
||||
PJ_4 = (PORT_J<<4|4),
|
||||
PJ_5 = (PORT_J<<4|5),
|
||||
PJ_6 = (PORT_J<<4|6),
|
||||
// PJ_7 = (PORT_J<<4|7),
|
||||
|
||||
PK_0 = (PORT_K<<4|0),
|
||||
PK_1 = (PORT_K<<4|1),
|
||||
PK_2 = (PORT_K<<4|2),
|
||||
PK_3 = (PORT_K<<4|3),
|
||||
PK_4 = (PORT_K<<4|4),
|
||||
PK_5 = (PORT_K<<4|5),
|
||||
PK_6 = (PORT_K<<4|6),
|
||||
// PK_7 = (PORT_K<<4|7),
|
||||
|
||||
AD_1 = (PORT_V<<4|1),
|
||||
AD_2 = (PORT_V<<4|2),
|
||||
AD_3 = (PORT_V<<4|3),
|
||||
|
||||
DA_0 = (PORT_U<<4|0),
|
||||
DA_1 = (PORT_U<<4|1),
|
||||
// Arduino connector namings
|
||||
/*
|
||||
A0 = PA_0,
|
||||
A1 = PA_1,
|
||||
A2 = PA_4,
|
||||
A3 = PB_0,
|
||||
A4 = PC_1,
|
||||
A5 = PC_0,
|
||||
D0 = PA_3,
|
||||
D1 = PA_2,
|
||||
D2 = PA_10,
|
||||
D3 = PB_3,
|
||||
D4 = PB_5,
|
||||
D5 = PB_4,
|
||||
D6 = PB_10,
|
||||
D7 = PA_8,
|
||||
D8 = PA_9,
|
||||
D9 = PC_7,
|
||||
D10 = PB_6,
|
||||
D11 = PA_7,
|
||||
D12 = PA_6,
|
||||
D13 = PA_5,
|
||||
D14 = PB_9,
|
||||
D15 = PB_8,
|
||||
*/
|
||||
|
||||
// Generic signals namings
|
||||
LED1 = PB_4,
|
||||
LED2 = PB_5,
|
||||
LED3 = PB_6,
|
||||
LED4 = PB_7,
|
||||
USER_BUTTON = PA_3,
|
||||
SERIAL_TX = PA_7,
|
||||
SERIAL_RX = PA_6,
|
||||
USBTX = PA_7,
|
||||
USBRX = PA_6,
|
||||
I2C_SCL = PC_5,
|
||||
I2C_SDA = PC_4,
|
||||
SPI_MOSI = PC_2,
|
||||
SPI_MISO = PC_3,
|
||||
SPI_SCK = PC_1,
|
||||
SPI_CS = PC_0,
|
||||
PWM_OUT = PD_4,
|
||||
|
||||
// Not connected
|
||||
NC = (uint32_t)0xFFFFFFFF
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
PullNone = 0,
|
||||
PullUp = 1,
|
||||
PullDown = 2,
|
||||
OpenDrain = 3,
|
||||
PullDefault = PullNone
|
||||
} PinMode;
|
||||
|
||||
#define PORT_NUM(pin) (((uint32_t)(pin) >> 4) & 0xF)
|
||||
#define PIN_NUM(pin) ((uint32_t)(pin) & 0xF)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _PINNAMES_H_
|
||||
#define _PINNAMES_H_
|
||||
|
||||
#include "cmsis.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
PORT_A = 0,
|
||||
PORT_B = 1,
|
||||
PORT_C = 2,
|
||||
PORT_D = 3,
|
||||
PORT_E = 4,
|
||||
PORT_F = 5,
|
||||
PORT_G = 6,
|
||||
PORT_H = 7,
|
||||
PORT_I = 8,
|
||||
PORT_J = 9,
|
||||
PORT_K = 10,
|
||||
|
||||
PORT_V = 11,
|
||||
PORT_U = 12,
|
||||
PORT_MAX
|
||||
} GPIO_PORT;
|
||||
|
||||
#define RTL_PIN_PERI(FUN, IDX, SEL) ((int)(((FUN) << 8) | ((IDX)<<4) | (SEL)))
|
||||
#define RTL_PIN_FUNC(FUN, SEL) ((int)(((FUN) << 7) | (SEL)))
|
||||
#define RTL_GET_PERI_SEL(peri) ((int)((peri)&0x0F))
|
||||
#define RTL_GET_PERI_IDX(peri) ((int)(((peri) >> 4)&0x0F))
|
||||
|
||||
typedef enum {
|
||||
PIN_INPUT=0,
|
||||
PIN_OUTPUT
|
||||
} PinDirection;
|
||||
|
||||
typedef enum {
|
||||
PA_0 = (PORT_A<<4|0),
|
||||
PA_1 = (PORT_A<<4|1),
|
||||
PA_2 = (PORT_A<<4|2),
|
||||
PA_3 = (PORT_A<<4|3),
|
||||
PA_4 = (PORT_A<<4|4),
|
||||
PA_5 = (PORT_A<<4|5),
|
||||
PA_6 = (PORT_A<<4|6),
|
||||
PA_7 = (PORT_A<<4|7),
|
||||
|
||||
PB_0 = (PORT_B<<4|0),
|
||||
PB_1 = (PORT_B<<4|1),
|
||||
PB_2 = (PORT_B<<4|2),
|
||||
PB_3 = (PORT_B<<4|3),
|
||||
PB_4 = (PORT_B<<4|4),
|
||||
PB_5 = (PORT_B<<4|5),
|
||||
PB_6 = (PORT_B<<4|6),
|
||||
PB_7 = (PORT_B<<4|7),
|
||||
|
||||
PC_0 = (PORT_C<<4|0),
|
||||
PC_1 = (PORT_C<<4|1),
|
||||
PC_2 = (PORT_C<<4|2),
|
||||
PC_3 = (PORT_C<<4|3),
|
||||
PC_4 = (PORT_C<<4|4),
|
||||
PC_5 = (PORT_C<<4|5),
|
||||
PC_6 = (PORT_C<<4|6),
|
||||
PC_7 = (PORT_C<<4|7),
|
||||
PC_8 = (PORT_C<<4|8),
|
||||
PC_9 = (PORT_C<<4|9),
|
||||
|
||||
PD_0 = (PORT_D<<4|0),
|
||||
PD_1 = (PORT_D<<4|1),
|
||||
PD_2 = (PORT_D<<4|2),
|
||||
PD_3 = (PORT_D<<4|3),
|
||||
PD_4 = (PORT_D<<4|4),
|
||||
PD_5 = (PORT_D<<4|5),
|
||||
PD_6 = (PORT_D<<4|6),
|
||||
PD_7 = (PORT_D<<4|7),
|
||||
PD_8 = (PORT_D<<4|8),
|
||||
PD_9 = (PORT_D<<4|9),
|
||||
|
||||
PE_0 = (PORT_E<<4|0),
|
||||
PE_1 = (PORT_E<<4|1),
|
||||
PE_2 = (PORT_E<<4|2),
|
||||
PE_3 = (PORT_E<<4|3),
|
||||
PE_4 = (PORT_E<<4|4),
|
||||
PE_5 = (PORT_E<<4|5),
|
||||
PE_6 = (PORT_E<<4|6),
|
||||
PE_7 = (PORT_E<<4|7),
|
||||
PE_8 = (PORT_E<<4|8),
|
||||
PE_9 = (PORT_E<<4|9),
|
||||
PE_A = (PORT_E<<4|10),
|
||||
|
||||
PF_0 = (PORT_F<<4|0),
|
||||
PF_1 = (PORT_F<<4|1),
|
||||
PF_2 = (PORT_F<<4|2),
|
||||
PF_3 = (PORT_F<<4|3),
|
||||
PF_4 = (PORT_F<<4|4),
|
||||
PF_5 = (PORT_F<<4|5),
|
||||
// PF_6 = (PORT_F<<4|6),
|
||||
// PF_7 = (PORT_F<<4|7),
|
||||
|
||||
PG_0 = (PORT_G<<4|0),
|
||||
PG_1 = (PORT_G<<4|1),
|
||||
PG_2 = (PORT_G<<4|2),
|
||||
PG_3 = (PORT_G<<4|3),
|
||||
PG_4 = (PORT_G<<4|4),
|
||||
PG_5 = (PORT_G<<4|5),
|
||||
PG_6 = (PORT_G<<4|6),
|
||||
PG_7 = (PORT_G<<4|7),
|
||||
|
||||
PH_0 = (PORT_H<<4|0),
|
||||
PH_1 = (PORT_H<<4|1),
|
||||
PH_2 = (PORT_H<<4|2),
|
||||
PH_3 = (PORT_H<<4|3),
|
||||
PH_4 = (PORT_H<<4|4),
|
||||
PH_5 = (PORT_H<<4|5),
|
||||
PH_6 = (PORT_H<<4|6),
|
||||
PH_7 = (PORT_H<<4|7),
|
||||
|
||||
PI_0 = (PORT_I<<4|0),
|
||||
PI_1 = (PORT_I<<4|1),
|
||||
PI_2 = (PORT_I<<4|2),
|
||||
PI_3 = (PORT_I<<4|3),
|
||||
PI_4 = (PORT_I<<4|4),
|
||||
PI_5 = (PORT_I<<4|5),
|
||||
PI_6 = (PORT_I<<4|6),
|
||||
PI_7 = (PORT_I<<4|7),
|
||||
|
||||
PJ_0 = (PORT_J<<4|0),
|
||||
PJ_1 = (PORT_J<<4|1),
|
||||
PJ_2 = (PORT_J<<4|2),
|
||||
PJ_3 = (PORT_J<<4|3),
|
||||
PJ_4 = (PORT_J<<4|4),
|
||||
PJ_5 = (PORT_J<<4|5),
|
||||
PJ_6 = (PORT_J<<4|6),
|
||||
// PJ_7 = (PORT_J<<4|7),
|
||||
|
||||
PK_0 = (PORT_K<<4|0),
|
||||
PK_1 = (PORT_K<<4|1),
|
||||
PK_2 = (PORT_K<<4|2),
|
||||
PK_3 = (PORT_K<<4|3),
|
||||
PK_4 = (PORT_K<<4|4),
|
||||
PK_5 = (PORT_K<<4|5),
|
||||
PK_6 = (PORT_K<<4|6),
|
||||
// PK_7 = (PORT_K<<4|7),
|
||||
|
||||
AD_1 = (PORT_V<<4|1),
|
||||
AD_2 = (PORT_V<<4|2),
|
||||
AD_3 = (PORT_V<<4|3),
|
||||
|
||||
DA_0 = (PORT_U<<4|0),
|
||||
DA_1 = (PORT_U<<4|1),
|
||||
// Arduino connector namings
|
||||
/*
|
||||
A0 = PA_0,
|
||||
A1 = PA_1,
|
||||
A2 = PA_4,
|
||||
A3 = PB_0,
|
||||
A4 = PC_1,
|
||||
A5 = PC_0,
|
||||
D0 = PA_3,
|
||||
D1 = PA_2,
|
||||
D2 = PA_10,
|
||||
D3 = PB_3,
|
||||
D4 = PB_5,
|
||||
D5 = PB_4,
|
||||
D6 = PB_10,
|
||||
D7 = PA_8,
|
||||
D8 = PA_9,
|
||||
D9 = PC_7,
|
||||
D10 = PB_6,
|
||||
D11 = PA_7,
|
||||
D12 = PA_6,
|
||||
D13 = PA_5,
|
||||
D14 = PB_9,
|
||||
D15 = PB_8,
|
||||
*/
|
||||
|
||||
// Generic signals namings
|
||||
LED1 = PB_4,
|
||||
LED2 = PB_5,
|
||||
LED3 = PB_6,
|
||||
LED4 = PB_7,
|
||||
USER_BUTTON = PA_3,
|
||||
SERIAL_TX = PA_7,
|
||||
SERIAL_RX = PA_6,
|
||||
USBTX = PA_7,
|
||||
USBRX = PA_6,
|
||||
I2C_SCL = PC_5,
|
||||
I2C_SDA = PC_4,
|
||||
SPI_MOSI = PC_2,
|
||||
SPI_MISO = PC_3,
|
||||
SPI_SCK = PC_1,
|
||||
SPI_CS = PC_0,
|
||||
PWM_OUT = PD_4,
|
||||
|
||||
// Not connected
|
||||
NC = (uint32_t)0xFFFFFFFF
|
||||
} PinName;
|
||||
|
||||
typedef enum {
|
||||
PullNone = 0,
|
||||
PullUp = 1,
|
||||
PullDown = 2,
|
||||
OpenDrain = 3,
|
||||
PullDefault = PullNone
|
||||
} PinMode;
|
||||
|
||||
#define PORT_NUM(pin) (((uint32_t)(pin) >> 4) & 0xF)
|
||||
#define PIN_NUM(pin) ((uint32_t)(pin) & 0xF)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,38 +1,38 @@
|
|||
/* 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,
|
||||
PortC = 2,
|
||||
PortD = 3,
|
||||
PortE = 4,
|
||||
PortF = 5,
|
||||
PortG = 6,
|
||||
PortH = 7,
|
||||
PortI = 8
|
||||
} PortName;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* 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,
|
||||
PortC = 2,
|
||||
PortD = 3,
|
||||
PortE = 4,
|
||||
PortF = 5,
|
||||
PortG = 6,
|
||||
PortH = 7,
|
||||
PortI = 8
|
||||
} PortName;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,48 +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 1
|
||||
|
||||
#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 1
|
||||
|
||||
#define DEVICE_PWMOUT 1
|
||||
|
||||
#define DEVICE_SLEEP 1
|
||||
|
||||
#include "objects.h"
|
||||
|
||||
#endif
|
||||
/* 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 1
|
||||
|
||||
#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 1
|
||||
|
||||
#define DEVICE_PWMOUT 1
|
||||
|
||||
#define DEVICE_SLEEP 1
|
||||
|
||||
#include "objects.h"
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,89 +1,89 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, Realtek
|
||||
* All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "dma_api.h"
|
||||
#include "cmsis.h"
|
||||
|
||||
extern BOOL HalGdmaMemCpyInit(PHAL_GDMA_OBJ pHalGdmaObj);
|
||||
extern VOID HalGdmaMemCpyDeInit(PHAL_GDMA_OBJ pHalGdmaObj);
|
||||
extern VOID* HalGdmaMemCpy(PHAL_GDMA_OBJ pHalGdmaObj, void* pDest, void* pSrc, u32 len);
|
||||
extern VOID HalGdmaMemAggr(PHAL_GDMA_OBJ pHalGdmaObj, PHAL_GDMA_BLOCK pHalGdmaBlock);
|
||||
extern BOOL HalGdmaMemCpyAggrInit(PHAL_GDMA_OBJ pHalGdmaObj);
|
||||
|
||||
/**
|
||||
* @brief Initial the GDMA
|
||||
*
|
||||
* @param dma_obj: the GDMA object
|
||||
* handler: the callback function for a DMA transfer complete.
|
||||
* id: the argument of the callback function.
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void dma_memcpy_aggr_init(gdma_t *dma_obj, dma_irq_handler handler, uint32_t id)
|
||||
{
|
||||
dma_obj->gdma_obj.GdmaIrqHandle.IrqFun = (IRQ_FUN)handler;
|
||||
dma_obj->gdma_obj.GdmaIrqHandle.Data = (u32)id;
|
||||
dma_obj->gdma_allocated = HalGdmaMemCpyAggrInit(&(dma_obj->gdma_obj));
|
||||
}
|
||||
|
||||
|
||||
void dma_memcpy_init(gdma_t *dma_obj, dma_irq_handler handler, uint32_t id)
|
||||
{
|
||||
dma_obj->gdma_obj.GdmaIrqHandle.IrqFun = (IRQ_FUN)handler;
|
||||
dma_obj->gdma_obj.GdmaIrqHandle.Data = (u32)id;
|
||||
dma_obj->gdma_allocated = HalGdmaMemCpyInit(&(dma_obj->gdma_obj));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief De-Initial the GDMA
|
||||
*
|
||||
* @param dma_obj: the GDMA object
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void dma_memcpy_deinit(gdma_t *dma_obj)
|
||||
{
|
||||
if (dma_obj->gdma_allocated) {
|
||||
HalGdmaMemCpyDeInit(&(dma_obj->gdma_obj));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To do a memory copy by DMA
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void dma_memcpy(gdma_t *dma_obj, void *dst, void* src, uint32_t len)
|
||||
{
|
||||
#if 0
|
||||
if (!dma_obj->gdma_allocated) {
|
||||
dma_irq_handler handler;
|
||||
|
||||
_memcpy(dst, src, len);
|
||||
handler = dma_obj->GdmaIrqHandle.IrqFun;
|
||||
handler(dma_obj->GdmaIrqHandle.Data);
|
||||
}
|
||||
#endif
|
||||
HalGdmaMemCpy(&(dma_obj->gdma_obj), dst, src, len);
|
||||
}
|
||||
|
||||
void dma_memcpy_aggr(gdma_t *dma_obj, PHAL_GDMA_BLOCK block_info)
|
||||
{
|
||||
HalGdmaMemAggr(&(dma_obj->gdma_obj), block_info);
|
||||
}
|
||||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, Realtek
|
||||
* All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "dma_api.h"
|
||||
#include "cmsis.h"
|
||||
|
||||
extern BOOL HalGdmaMemCpyInit(PHAL_GDMA_OBJ pHalGdmaObj);
|
||||
extern VOID HalGdmaMemCpyDeInit(PHAL_GDMA_OBJ pHalGdmaObj);
|
||||
extern VOID* HalGdmaMemCpy(PHAL_GDMA_OBJ pHalGdmaObj, void* pDest, void* pSrc, u32 len);
|
||||
extern VOID HalGdmaMemAggr(PHAL_GDMA_OBJ pHalGdmaObj, PHAL_GDMA_BLOCK pHalGdmaBlock);
|
||||
extern BOOL HalGdmaMemCpyAggrInit(PHAL_GDMA_OBJ pHalGdmaObj);
|
||||
|
||||
/**
|
||||
* @brief Initial the GDMA
|
||||
*
|
||||
* @param dma_obj: the GDMA object
|
||||
* handler: the callback function for a DMA transfer complete.
|
||||
* id: the argument of the callback function.
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void dma_memcpy_aggr_init(gdma_t *dma_obj, dma_irq_handler handler, uint32_t id)
|
||||
{
|
||||
dma_obj->gdma_obj.GdmaIrqHandle.IrqFun = (IRQ_FUN)handler;
|
||||
dma_obj->gdma_obj.GdmaIrqHandle.Data = (u32)id;
|
||||
dma_obj->gdma_allocated = HalGdmaMemCpyAggrInit(&(dma_obj->gdma_obj));
|
||||
}
|
||||
|
||||
|
||||
void dma_memcpy_init(gdma_t *dma_obj, dma_irq_handler handler, uint32_t id)
|
||||
{
|
||||
dma_obj->gdma_obj.GdmaIrqHandle.IrqFun = (IRQ_FUN)handler;
|
||||
dma_obj->gdma_obj.GdmaIrqHandle.Data = (u32)id;
|
||||
dma_obj->gdma_allocated = HalGdmaMemCpyInit(&(dma_obj->gdma_obj));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief De-Initial the GDMA
|
||||
*
|
||||
* @param dma_obj: the GDMA object
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void dma_memcpy_deinit(gdma_t *dma_obj)
|
||||
{
|
||||
if (dma_obj->gdma_allocated) {
|
||||
HalGdmaMemCpyDeInit(&(dma_obj->gdma_obj));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To do a memory copy by DMA
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void dma_memcpy(gdma_t *dma_obj, void *dst, void* src, uint32_t len)
|
||||
{
|
||||
#if 0
|
||||
if (!dma_obj->gdma_allocated) {
|
||||
dma_irq_handler handler;
|
||||
|
||||
_memcpy(dst, src, len);
|
||||
handler = dma_obj->GdmaIrqHandle.IrqFun;
|
||||
handler(dma_obj->GdmaIrqHandle.Data);
|
||||
}
|
||||
#endif
|
||||
HalGdmaMemCpy(&(dma_obj->gdma_obj), dst, src, len);
|
||||
}
|
||||
|
||||
void dma_memcpy_aggr(gdma_t *dma_obj, PHAL_GDMA_BLOCK block_info)
|
||||
{
|
||||
HalGdmaMemAggr(&(dma_obj->gdma_obj), block_info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,241 +1,241 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* 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.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "objects.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
#if CONFIG_GPIO_EN
|
||||
|
||||
#include "gpio_api.h"
|
||||
|
||||
// convert Mbed pin mode to HAL Pin Mode
|
||||
const u8 GPIO_InPinMode[] = {
|
||||
DIN_PULL_NONE, // PullNone
|
||||
DIN_PULL_HIGH, // PullUp
|
||||
DIN_PULL_LOW, // PullDown
|
||||
DIN_PULL_NONE // OpenDrain
|
||||
};
|
||||
|
||||
const u8 GPIO_SWPORT_DR_TBL[] = {
|
||||
GPIO_PORTA_DR,
|
||||
GPIO_PORTB_DR,
|
||||
GPIO_PORTC_DR
|
||||
};
|
||||
|
||||
const u8 GPIO_EXT_PORT_TBL[] = {
|
||||
GPIO_EXT_PORTA,
|
||||
GPIO_EXT_PORTB,
|
||||
GPIO_EXT_PORTC
|
||||
};
|
||||
|
||||
const u8 GPIO_SWPORT_DDR_TBL[] = {
|
||||
GPIO_PORTA_DDR,
|
||||
GPIO_PORTB_DDR,
|
||||
GPIO_PORTC_DDR
|
||||
};
|
||||
|
||||
#if 0
|
||||
void gpio_set_hal_pin_mode(gpio_t *obj)
|
||||
{
|
||||
if (obj->direction == PIN_OUTPUT) {
|
||||
switch (obj->mode) {
|
||||
case PullNone:
|
||||
case PullDown:
|
||||
case PullUp:
|
||||
obj->hal_pin.pin_mode = DOUT_PUSH_PULL;
|
||||
break;
|
||||
|
||||
case OpenDrain:
|
||||
obj->hal_pin.pin_mode = DOUT_OPEN_DRAIN;
|
||||
break;
|
||||
|
||||
default:
|
||||
obj->hal_pin.pin_mode = DOUT_PUSH_PULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (obj->mode) {
|
||||
case PullNone:
|
||||
case OpenDrain:
|
||||
obj->hal_pin.pin_mode = DIN_PULL_NONE;
|
||||
break;
|
||||
|
||||
case PullDown:
|
||||
obj->hal_pin.pin_mode = DIN_PULL_LOW;
|
||||
break;
|
||||
|
||||
case PullUp:
|
||||
obj->hal_pin.pin_mode = DIN_PULL_HIGH;
|
||||
break;
|
||||
|
||||
default:
|
||||
obj->hal_pin.pin_mode = DIN_PULL_NONE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
void gpio_set_hal_pin_mode(gpio_t *obj)
|
||||
{
|
||||
uint32_t mode;
|
||||
|
||||
mode = obj->mode;
|
||||
if (obj->direction == PIN_OUTPUT) {
|
||||
if (mode == OpenDrain) {
|
||||
obj->hal_pin.pin_mode = DOUT_OPEN_DRAIN;
|
||||
} else {
|
||||
obj->hal_pin.pin_mode = DOUT_PUSH_PULL;
|
||||
}
|
||||
} else {
|
||||
if (mode < 4) {
|
||||
obj->hal_pin.pin_mode = GPIO_InPinMode[mode];
|
||||
} else {
|
||||
obj->hal_pin.pin_mode = DIN_PULL_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t gpio_set(PinName pin)
|
||||
{
|
||||
u32 ip_pin;
|
||||
|
||||
//MBED_ASSERT(pin != (PinName)NC);
|
||||
DBG_ASSERT(pin != (PinName)NC);
|
||||
pin_function(pin, 0);
|
||||
ip_pin = HAL_GPIO_GetPinName((u32)pin);
|
||||
|
||||
return ip_pin;
|
||||
}
|
||||
|
||||
void gpio_init(gpio_t *obj, PinName pin)
|
||||
{
|
||||
uint32_t pin_name;
|
||||
|
||||
if (pin == (PinName)NC)
|
||||
return;
|
||||
|
||||
obj->pin = pin;
|
||||
obj->mode = PullNone;
|
||||
obj->direction = PIN_INPUT;
|
||||
pin_name = gpio_set(pin); // get the IP pin name
|
||||
obj->hal_pin.pin_name = pin_name;
|
||||
obj->hal_pin.pin_mode = DIN_PULL_NONE;
|
||||
obj->hal_port_num = HAL_GPIO_GET_PORT_BY_NAME(pin_name);
|
||||
obj->hal_pin_num = HAL_GPIO_GET_PIN_BY_NAME(pin_name);
|
||||
HAL_GPIO_Init(&obj->hal_pin);
|
||||
}
|
||||
|
||||
void gpio_mode(gpio_t *obj, PinMode mode)
|
||||
{
|
||||
obj->mode = mode;
|
||||
gpio_set_hal_pin_mode(obj);
|
||||
HAL_GPIO_Init(&obj->hal_pin);
|
||||
}
|
||||
|
||||
// Initial the Pin direction
|
||||
void gpio_dir(gpio_t *obj, PinDirection direction) {
|
||||
// DBG_ASSERT(obj->pin != (PinName)NC);
|
||||
obj->direction = direction;
|
||||
gpio_set_hal_pin_mode(obj);
|
||||
HAL_GPIO_Init(&obj->hal_pin);
|
||||
}
|
||||
|
||||
// Change the pin direction directly
|
||||
void gpio_change_dir(gpio_t *obj, PinDirection direction) {
|
||||
uint32_t reg_value;
|
||||
uint8_t port_num;
|
||||
uint8_t pin_num;
|
||||
|
||||
obj->direction = direction;
|
||||
gpio_set_hal_pin_mode(obj);
|
||||
port_num = obj->hal_port_num;
|
||||
pin_num = obj->hal_pin_num;
|
||||
|
||||
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_SWPORT_DDR_TBL[port_num]);
|
||||
if (direction) {
|
||||
// Out
|
||||
reg_value |= (1 << pin_num);
|
||||
} else {
|
||||
// In
|
||||
reg_value &= ~(1 << pin_num);
|
||||
}
|
||||
HAL_WRITE32(GPIO_REG_BASE, GPIO_SWPORT_DDR_TBL[port_num], reg_value);
|
||||
}
|
||||
|
||||
void gpio_write(gpio_t *obj, int value)
|
||||
{
|
||||
HAL_GPIO_PIN *hal_pin=&obj->hal_pin;
|
||||
volatile uint32_t reg_value;
|
||||
uint8_t port_num;
|
||||
uint8_t pin_num;
|
||||
|
||||
if (hal_pin->pin_mode != DOUT_OPEN_DRAIN) {
|
||||
port_num = obj->hal_port_num;
|
||||
pin_num = obj->hal_pin_num;
|
||||
|
||||
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num]);
|
||||
reg_value &= ~(1 << pin_num);
|
||||
reg_value |= ((value&0x01)<< pin_num);
|
||||
HAL_WRITE32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num], reg_value);
|
||||
} else {
|
||||
HAL_GPIO_WritePin(&obj->hal_pin, value);
|
||||
}
|
||||
}
|
||||
|
||||
int gpio_read(gpio_t *obj) {
|
||||
volatile uint32_t reg_value;
|
||||
uint8_t port_num;
|
||||
uint8_t pin_num;
|
||||
// HAL_GPIO_PIN_STATE pin_status;
|
||||
HAL_GPIO_PIN_MODE pin_mode;
|
||||
|
||||
port_num = obj->hal_port_num;
|
||||
pin_num = obj->hal_pin_num;
|
||||
pin_mode = obj->hal_pin.pin_mode;
|
||||
|
||||
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_EXT_PORT_TBL[port_num]);
|
||||
if (pin_mode != DOUT_OPEN_DRAIN) {
|
||||
return ((reg_value >> pin_num) & 0x01);
|
||||
} else {
|
||||
return (!((reg_value >> pin_num) & 0x01));
|
||||
}
|
||||
|
||||
// return pin_status;
|
||||
}
|
||||
|
||||
// This API only works for non-Open-Drain pin
|
||||
void gpio_direct_write(gpio_t *obj, BOOL value)
|
||||
{
|
||||
uint8_t port_num;
|
||||
uint8_t pin_num;
|
||||
uint32_t reg_value;
|
||||
|
||||
port_num = obj->hal_port_num;
|
||||
pin_num = obj->hal_pin_num;
|
||||
|
||||
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num]);
|
||||
reg_value &= ~(1 << pin_num);
|
||||
reg_value |= (value<< pin_num);
|
||||
HAL_WRITE32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num], reg_value);
|
||||
}
|
||||
|
||||
void gpio_pull_ctrl(gpio_t *obj, PinMode pull_type)
|
||||
{
|
||||
// obj->mode = pull_type;
|
||||
// gpio_set_hal_pin_mode(obj);
|
||||
HAL_GPIO_PullCtrl((u32) obj->pin, (u32)pull_type);
|
||||
}
|
||||
|
||||
|
||||
void gpio_deinit(gpio_t *obj) {
|
||||
HAL_GPIO_DeInit(&obj->hal_pin);
|
||||
}
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* 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.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "objects.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
#if CONFIG_GPIO_EN
|
||||
|
||||
#include "gpio_api.h"
|
||||
|
||||
// convert Mbed pin mode to HAL Pin Mode
|
||||
const u8 GPIO_InPinMode[] = {
|
||||
DIN_PULL_NONE, // PullNone
|
||||
DIN_PULL_HIGH, // PullUp
|
||||
DIN_PULL_LOW, // PullDown
|
||||
DIN_PULL_NONE // OpenDrain
|
||||
};
|
||||
|
||||
const u8 GPIO_SWPORT_DR_TBL[] = {
|
||||
GPIO_PORTA_DR,
|
||||
GPIO_PORTB_DR,
|
||||
GPIO_PORTC_DR
|
||||
};
|
||||
|
||||
const u8 GPIO_EXT_PORT_TBL[] = {
|
||||
GPIO_EXT_PORTA,
|
||||
GPIO_EXT_PORTB,
|
||||
GPIO_EXT_PORTC
|
||||
};
|
||||
|
||||
const u8 GPIO_SWPORT_DDR_TBL[] = {
|
||||
GPIO_PORTA_DDR,
|
||||
GPIO_PORTB_DDR,
|
||||
GPIO_PORTC_DDR
|
||||
};
|
||||
|
||||
#if 0
|
||||
void gpio_set_hal_pin_mode(gpio_t *obj)
|
||||
{
|
||||
if (obj->direction == PIN_OUTPUT) {
|
||||
switch (obj->mode) {
|
||||
case PullNone:
|
||||
case PullDown:
|
||||
case PullUp:
|
||||
obj->hal_pin.pin_mode = DOUT_PUSH_PULL;
|
||||
break;
|
||||
|
||||
case OpenDrain:
|
||||
obj->hal_pin.pin_mode = DOUT_OPEN_DRAIN;
|
||||
break;
|
||||
|
||||
default:
|
||||
obj->hal_pin.pin_mode = DOUT_PUSH_PULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch (obj->mode) {
|
||||
case PullNone:
|
||||
case OpenDrain:
|
||||
obj->hal_pin.pin_mode = DIN_PULL_NONE;
|
||||
break;
|
||||
|
||||
case PullDown:
|
||||
obj->hal_pin.pin_mode = DIN_PULL_LOW;
|
||||
break;
|
||||
|
||||
case PullUp:
|
||||
obj->hal_pin.pin_mode = DIN_PULL_HIGH;
|
||||
break;
|
||||
|
||||
default:
|
||||
obj->hal_pin.pin_mode = DIN_PULL_NONE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
void gpio_set_hal_pin_mode(gpio_t *obj)
|
||||
{
|
||||
uint32_t mode;
|
||||
|
||||
mode = obj->mode;
|
||||
if (obj->direction == PIN_OUTPUT) {
|
||||
if (mode == OpenDrain) {
|
||||
obj->hal_pin.pin_mode = DOUT_OPEN_DRAIN;
|
||||
} else {
|
||||
obj->hal_pin.pin_mode = DOUT_PUSH_PULL;
|
||||
}
|
||||
} else {
|
||||
if (mode < 4) {
|
||||
obj->hal_pin.pin_mode = GPIO_InPinMode[mode];
|
||||
} else {
|
||||
obj->hal_pin.pin_mode = DIN_PULL_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t gpio_set(PinName pin)
|
||||
{
|
||||
u32 ip_pin;
|
||||
|
||||
//MBED_ASSERT(pin != (PinName)NC);
|
||||
DBG_ASSERT(pin != (PinName)NC);
|
||||
pin_function(pin, 0);
|
||||
ip_pin = HAL_GPIO_GetPinName((u32)pin);
|
||||
|
||||
return ip_pin;
|
||||
}
|
||||
|
||||
void gpio_init(gpio_t *obj, PinName pin)
|
||||
{
|
||||
uint32_t pin_name;
|
||||
|
||||
if (pin == (PinName)NC)
|
||||
return;
|
||||
|
||||
obj->pin = pin;
|
||||
obj->mode = PullNone;
|
||||
obj->direction = PIN_INPUT;
|
||||
pin_name = gpio_set(pin); // get the IP pin name
|
||||
obj->hal_pin.pin_name = pin_name;
|
||||
obj->hal_pin.pin_mode = DIN_PULL_NONE;
|
||||
obj->hal_port_num = HAL_GPIO_GET_PORT_BY_NAME(pin_name);
|
||||
obj->hal_pin_num = HAL_GPIO_GET_PIN_BY_NAME(pin_name);
|
||||
HAL_GPIO_Init(&obj->hal_pin);
|
||||
}
|
||||
|
||||
void gpio_mode(gpio_t *obj, PinMode mode)
|
||||
{
|
||||
obj->mode = mode;
|
||||
gpio_set_hal_pin_mode(obj);
|
||||
HAL_GPIO_Init(&obj->hal_pin);
|
||||
}
|
||||
|
||||
// Initial the Pin direction
|
||||
void gpio_dir(gpio_t *obj, PinDirection direction) {
|
||||
// DBG_ASSERT(obj->pin != (PinName)NC);
|
||||
obj->direction = direction;
|
||||
gpio_set_hal_pin_mode(obj);
|
||||
HAL_GPIO_Init(&obj->hal_pin);
|
||||
}
|
||||
|
||||
// Change the pin direction directly
|
||||
void gpio_change_dir(gpio_t *obj, PinDirection direction) {
|
||||
uint32_t reg_value;
|
||||
uint8_t port_num;
|
||||
uint8_t pin_num;
|
||||
|
||||
obj->direction = direction;
|
||||
gpio_set_hal_pin_mode(obj);
|
||||
port_num = obj->hal_port_num;
|
||||
pin_num = obj->hal_pin_num;
|
||||
|
||||
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_SWPORT_DDR_TBL[port_num]);
|
||||
if (direction) {
|
||||
// Out
|
||||
reg_value |= (1 << pin_num);
|
||||
} else {
|
||||
// In
|
||||
reg_value &= ~(1 << pin_num);
|
||||
}
|
||||
HAL_WRITE32(GPIO_REG_BASE, GPIO_SWPORT_DDR_TBL[port_num], reg_value);
|
||||
}
|
||||
|
||||
void gpio_write(gpio_t *obj, int value)
|
||||
{
|
||||
HAL_GPIO_PIN *hal_pin=&obj->hal_pin;
|
||||
volatile uint32_t reg_value;
|
||||
uint8_t port_num;
|
||||
uint8_t pin_num;
|
||||
|
||||
if (hal_pin->pin_mode != DOUT_OPEN_DRAIN) {
|
||||
port_num = obj->hal_port_num;
|
||||
pin_num = obj->hal_pin_num;
|
||||
|
||||
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num]);
|
||||
reg_value &= ~(1 << pin_num);
|
||||
reg_value |= ((value&0x01)<< pin_num);
|
||||
HAL_WRITE32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num], reg_value);
|
||||
} else {
|
||||
HAL_GPIO_WritePin(&obj->hal_pin, value);
|
||||
}
|
||||
}
|
||||
|
||||
int gpio_read(gpio_t *obj) {
|
||||
volatile uint32_t reg_value;
|
||||
uint8_t port_num;
|
||||
uint8_t pin_num;
|
||||
// HAL_GPIO_PIN_STATE pin_status;
|
||||
HAL_GPIO_PIN_MODE pin_mode;
|
||||
|
||||
port_num = obj->hal_port_num;
|
||||
pin_num = obj->hal_pin_num;
|
||||
pin_mode = obj->hal_pin.pin_mode;
|
||||
|
||||
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_EXT_PORT_TBL[port_num]);
|
||||
if (pin_mode != DOUT_OPEN_DRAIN) {
|
||||
return ((reg_value >> pin_num) & 0x01);
|
||||
} else {
|
||||
return (!((reg_value >> pin_num) & 0x01));
|
||||
}
|
||||
|
||||
// return pin_status;
|
||||
}
|
||||
|
||||
// This API only works for non-Open-Drain pin
|
||||
void gpio_direct_write(gpio_t *obj, BOOL value)
|
||||
{
|
||||
uint8_t port_num;
|
||||
uint8_t pin_num;
|
||||
uint32_t reg_value;
|
||||
|
||||
port_num = obj->hal_port_num;
|
||||
pin_num = obj->hal_pin_num;
|
||||
|
||||
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num]);
|
||||
reg_value &= ~(1 << pin_num);
|
||||
reg_value |= (value<< pin_num);
|
||||
HAL_WRITE32(GPIO_REG_BASE, GPIO_SWPORT_DR_TBL[port_num], reg_value);
|
||||
}
|
||||
|
||||
void gpio_pull_ctrl(gpio_t *obj, PinMode pull_type)
|
||||
{
|
||||
// obj->mode = pull_type;
|
||||
// gpio_set_hal_pin_mode(obj);
|
||||
HAL_GPIO_PullCtrl((u32) obj->pin, (u32)pull_type);
|
||||
}
|
||||
|
||||
|
||||
void gpio_deinit(gpio_t *obj) {
|
||||
HAL_GPIO_DeInit(&obj->hal_pin);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,145 +1,145 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* 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.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "objects.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
//static uint32_t channel_ids[32] = {0};
|
||||
|
||||
//static gpio_irq_handler irq_handler;
|
||||
|
||||
#if CONFIG_GPIO_EN
|
||||
#include "gpio_irq_api.h"
|
||||
#include "gpio_irq_ex_api.h"
|
||||
|
||||
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id)
|
||||
{
|
||||
uint32_t pin_name;
|
||||
|
||||
if (pin == NC) return -1;
|
||||
|
||||
obj->pin = pin;
|
||||
pin_name = HAL_GPIO_GetPinName((u32)pin);; // get the IP pin name
|
||||
obj->hal_pin.pin_name = pin_name;
|
||||
obj->hal_pin.pin_mode = INT_FALLING; // default use Falling trigger
|
||||
obj->hal_port_num = HAL_GPIO_GET_PORT_BY_NAME(pin_name);
|
||||
obj->hal_pin_num = HAL_GPIO_GET_PIN_BY_NAME(pin_name);
|
||||
HAL_GPIO_Irq_Init(&obj->hal_pin);
|
||||
HAL_GPIO_UserRegIrq(&obj->hal_pin, (VOID*) handler, (VOID*) id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void gpio_irq_free(gpio_irq_t *obj)
|
||||
{
|
||||
HAL_GPIO_UserUnRegIrq(&obj->hal_pin);
|
||||
HAL_GPIO_DeInit(&obj->hal_pin);
|
||||
}
|
||||
|
||||
void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
|
||||
{
|
||||
switch((uint32_t)event) {
|
||||
case IRQ_RISE:
|
||||
obj->hal_pin.pin_mode = INT_RISING;
|
||||
break;
|
||||
|
||||
case IRQ_FALL:
|
||||
obj->hal_pin.pin_mode = INT_FALLING;
|
||||
break;
|
||||
|
||||
case IRQ_LOW:
|
||||
obj->hal_pin.pin_mode = INT_LOW;
|
||||
break;
|
||||
|
||||
case IRQ_HIGH:
|
||||
obj->hal_pin.pin_mode = INT_HIGH;
|
||||
break;
|
||||
|
||||
case IRQ_NONE:
|
||||
// ?
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// HAL_GPIO_Irq_Init(&obj->hal_pin);
|
||||
HAL_GPIO_Init_8195a(&obj->hal_pin);
|
||||
|
||||
HAL_GPIO_IntCtrl(&obj->hal_pin, enable);
|
||||
}
|
||||
|
||||
void gpio_irq_enable(gpio_irq_t *obj)
|
||||
{
|
||||
HAL_GPIO_UnMaskIrq(&obj->hal_pin);
|
||||
}
|
||||
|
||||
void gpio_irq_disable(gpio_irq_t *obj)
|
||||
{
|
||||
HAL_GPIO_MaskIrq(&obj->hal_pin);
|
||||
}
|
||||
|
||||
void gpio_irq_deinit(gpio_irq_t *obj)
|
||||
{
|
||||
HAL_GPIO_DeInit(&obj->hal_pin);
|
||||
}
|
||||
|
||||
void gpio_irq_pull_ctrl(gpio_irq_t *obj, PinMode pull_type)
|
||||
{
|
||||
HAL_GPIO_PullCtrl((u32) obj->pin, (u32)pull_type);
|
||||
}
|
||||
|
||||
void gpio_irq_set_event(gpio_irq_t *obj, gpio_irq_event event)
|
||||
{
|
||||
uint32_t reg_value;
|
||||
uint32_t level_edge;
|
||||
uint32_t polarity;
|
||||
uint8_t pin_num;
|
||||
|
||||
pin_num = obj->hal_pin_num & 0x1f; // Max 31
|
||||
|
||||
switch (event) {
|
||||
case IRQ_LOW:
|
||||
level_edge = 0; // level trigger
|
||||
polarity = 0; // active low
|
||||
break;
|
||||
|
||||
case IRQ_HIGH:
|
||||
level_edge = 0; // level trigger
|
||||
polarity = 1; // active high
|
||||
break;
|
||||
|
||||
case IRQ_FALL:
|
||||
level_edge = 1; // edge trigger
|
||||
polarity = 0; // active low
|
||||
break;
|
||||
|
||||
case IRQ_RISE:
|
||||
level_edge = 1; // edge trigger
|
||||
polarity = 1; // active high
|
||||
break;
|
||||
|
||||
default:
|
||||
DBG_GPIO_ERR("Unknow Interrupt Trigger Type(%d)\n", event);
|
||||
return;
|
||||
}
|
||||
|
||||
// Config Level or Edge trigger
|
||||
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_INT_TYPE);
|
||||
reg_value &= ~(1 << pin_num);
|
||||
reg_value |= (level_edge << pin_num);
|
||||
HAL_WRITE32(GPIO_REG_BASE, GPIO_INT_TYPE, reg_value);
|
||||
|
||||
// Config Low active or Gigh active
|
||||
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_INT_POLARITY);
|
||||
reg_value &= ~(1 << pin_num);
|
||||
reg_value |= (polarity << pin_num);
|
||||
HAL_WRITE32(GPIO_REG_BASE, GPIO_INT_POLARITY, reg_value);
|
||||
}
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* 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.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "objects.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
//static uint32_t channel_ids[32] = {0};
|
||||
|
||||
//static gpio_irq_handler irq_handler;
|
||||
|
||||
#if CONFIG_GPIO_EN
|
||||
#include "gpio_irq_api.h"
|
||||
#include "gpio_irq_ex_api.h"
|
||||
|
||||
int gpio_irq_init(gpio_irq_t *obj, PinName pin, gpio_irq_handler handler, uint32_t id)
|
||||
{
|
||||
uint32_t pin_name;
|
||||
|
||||
if (pin == NC) return -1;
|
||||
|
||||
obj->pin = pin;
|
||||
pin_name = HAL_GPIO_GetPinName((u32)pin);; // get the IP pin name
|
||||
obj->hal_pin.pin_name = pin_name;
|
||||
obj->hal_pin.pin_mode = INT_FALLING; // default use Falling trigger
|
||||
obj->hal_port_num = HAL_GPIO_GET_PORT_BY_NAME(pin_name);
|
||||
obj->hal_pin_num = HAL_GPIO_GET_PIN_BY_NAME(pin_name);
|
||||
HAL_GPIO_Irq_Init(&obj->hal_pin);
|
||||
HAL_GPIO_UserRegIrq(&obj->hal_pin, (VOID*) handler, (VOID*) id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void gpio_irq_free(gpio_irq_t *obj)
|
||||
{
|
||||
HAL_GPIO_UserUnRegIrq(&obj->hal_pin);
|
||||
HAL_GPIO_DeInit(&obj->hal_pin);
|
||||
}
|
||||
|
||||
void gpio_irq_set(gpio_irq_t *obj, gpio_irq_event event, uint32_t enable)
|
||||
{
|
||||
switch((uint32_t)event) {
|
||||
case IRQ_RISE:
|
||||
obj->hal_pin.pin_mode = INT_RISING;
|
||||
break;
|
||||
|
||||
case IRQ_FALL:
|
||||
obj->hal_pin.pin_mode = INT_FALLING;
|
||||
break;
|
||||
|
||||
case IRQ_LOW:
|
||||
obj->hal_pin.pin_mode = INT_LOW;
|
||||
break;
|
||||
|
||||
case IRQ_HIGH:
|
||||
obj->hal_pin.pin_mode = INT_HIGH;
|
||||
break;
|
||||
|
||||
case IRQ_NONE:
|
||||
// ?
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// HAL_GPIO_Irq_Init(&obj->hal_pin);
|
||||
HAL_GPIO_Init_8195a(&obj->hal_pin);
|
||||
|
||||
HAL_GPIO_IntCtrl(&obj->hal_pin, enable);
|
||||
}
|
||||
|
||||
void gpio_irq_enable(gpio_irq_t *obj)
|
||||
{
|
||||
HAL_GPIO_UnMaskIrq(&obj->hal_pin);
|
||||
}
|
||||
|
||||
void gpio_irq_disable(gpio_irq_t *obj)
|
||||
{
|
||||
HAL_GPIO_MaskIrq(&obj->hal_pin);
|
||||
}
|
||||
|
||||
void gpio_irq_deinit(gpio_irq_t *obj)
|
||||
{
|
||||
HAL_GPIO_DeInit(&obj->hal_pin);
|
||||
}
|
||||
|
||||
void gpio_irq_pull_ctrl(gpio_irq_t *obj, PinMode pull_type)
|
||||
{
|
||||
HAL_GPIO_PullCtrl((u32) obj->pin, (u32)pull_type);
|
||||
}
|
||||
|
||||
void gpio_irq_set_event(gpio_irq_t *obj, gpio_irq_event event)
|
||||
{
|
||||
uint32_t reg_value;
|
||||
uint32_t level_edge;
|
||||
uint32_t polarity;
|
||||
uint8_t pin_num;
|
||||
|
||||
pin_num = obj->hal_pin_num & 0x1f; // Max 31
|
||||
|
||||
switch (event) {
|
||||
case IRQ_LOW:
|
||||
level_edge = 0; // level trigger
|
||||
polarity = 0; // active low
|
||||
break;
|
||||
|
||||
case IRQ_HIGH:
|
||||
level_edge = 0; // level trigger
|
||||
polarity = 1; // active high
|
||||
break;
|
||||
|
||||
case IRQ_FALL:
|
||||
level_edge = 1; // edge trigger
|
||||
polarity = 0; // active low
|
||||
break;
|
||||
|
||||
case IRQ_RISE:
|
||||
level_edge = 1; // edge trigger
|
||||
polarity = 1; // active high
|
||||
break;
|
||||
|
||||
default:
|
||||
DBG_GPIO_ERR("Unknow Interrupt Trigger Type(%d)\n", event);
|
||||
return;
|
||||
}
|
||||
|
||||
// Config Level or Edge trigger
|
||||
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_INT_TYPE);
|
||||
reg_value &= ~(1 << pin_num);
|
||||
reg_value |= (level_edge << pin_num);
|
||||
HAL_WRITE32(GPIO_REG_BASE, GPIO_INT_TYPE, reg_value);
|
||||
|
||||
// Config Low active or Gigh active
|
||||
reg_value = HAL_READ32(GPIO_REG_BASE, GPIO_INT_POLARITY);
|
||||
reg_value &= ~(1 << pin_num);
|
||||
reg_value |= (polarity << pin_num);
|
||||
HAL_WRITE32(GPIO_REG_BASE, GPIO_INT_POLARITY, reg_value);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,39 +1,39 @@
|
|||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2006-2013 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#ifndef MBED_GPIO_OBJECT_H
|
||||
#define MBED_GPIO_OBJECT_H
|
||||
|
||||
#include "mbed_assert.h"
|
||||
|
||||
#include "basic_types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PinName pin;
|
||||
uint32_t mask;
|
||||
|
||||
uint32_t reg_out_offset;
|
||||
uint32_t reg_dir_offset;
|
||||
} gpio_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* 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
|
||||
|
||||
typedef struct {
|
||||
PinName pin;
|
||||
uint32_t mask;
|
||||
|
||||
uint32_t reg_out_offset;
|
||||
uint32_t reg_dir_offset;
|
||||
} gpio_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,243 +1,243 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* 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.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "objects.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
#if CONFIG_NFC_NORMAL
|
||||
|
||||
#include "nfc_api.h"
|
||||
|
||||
/**
|
||||
* @brief The NFC tag write callback function wrapper
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void nfc_tagwrite_callback(PNFC_ADAPTER pNFCAdp, uint32_t page, uint32_t wr_data)
|
||||
{
|
||||
nfctag_t *obj;
|
||||
nfc_write_cb handler;
|
||||
|
||||
obj = pNFCAdp->nfc_obj;
|
||||
|
||||
handler = (nfc_write_cb)obj->nfc_wr_cb;
|
||||
if (NULL != handler) {
|
||||
handler(obj->wr_cb_arg, page, wr_data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The NFC tag read callback function wrapper
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void nfc_event_callback(PNFC_ADAPTER pNFCAdp, uint32_t event)
|
||||
{
|
||||
nfctag_t *obj;
|
||||
nfc_event_cb handler;
|
||||
|
||||
obj = pNFCAdp->nfc_obj;
|
||||
|
||||
handler = (nfc_event_cb)obj->nfc_ev_cb;
|
||||
if (NULL != handler) {
|
||||
if (obj->event_mask & event) {
|
||||
handler(obj->ev_cb_arg, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The NFC tag read callback function wrapper
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void nfc_tagread_callback(PNFC_ADAPTER pNFCAdp, uint32_t page)
|
||||
{
|
||||
// notify upper layer when read tag page 0 only
|
||||
if (0 == page) {
|
||||
nfc_event_callback(pNFCAdp, NFC_EV_READ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief The NFC cache read done callback function wrapper
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void nfc_cache_read_callback(PNFC_ADAPTER pNFCAdp, uint32_t start_pg, uint32_t *pbuf)
|
||||
{
|
||||
nfctag_t *obj;
|
||||
nfc_write_cb handler;
|
||||
|
||||
obj = pNFCAdp->nfc_obj;
|
||||
|
||||
handler = (nfc_write_cb)obj->nfc_cache_rd_cb;
|
||||
if (NULL != handler) {
|
||||
handler(obj->cache_read_cb_arg, start_pg, (uint32_t)pbuf);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To initial NFC tag hardware and resource
|
||||
*
|
||||
* @return The result
|
||||
*
|
||||
*/
|
||||
int nfc_init(nfctag_t *obj, uint32_t *pg_init_val)
|
||||
{
|
||||
_memset((void *)obj, 0, sizeof(nfctag_t));
|
||||
HalNFCDmemInit(pg_init_val, NFCTAGLENGTH);
|
||||
HalNFCInit(&(obj->NFCAdapter));
|
||||
HalNFCFwDownload();
|
||||
obj->NFCAdapter.nfc_obj = obj;
|
||||
obj->pwr_status = NFC_PWR_RUNNING;
|
||||
|
||||
return NFC_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To free NFC tag hardware and resource
|
||||
*
|
||||
* @return The result
|
||||
*
|
||||
*/
|
||||
int nfc_free(nfctag_t *obj)
|
||||
{
|
||||
HalNFCDeinit(&(obj->NFCAdapter));
|
||||
return NFC_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To register the callback function for NFC read occurred
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void nfc_read(nfctag_t *obj, nfc_read_cb handler, void *arg)
|
||||
{
|
||||
obj->nfc_rd_cb = (void *)handler;
|
||||
obj->rd_cb_arg = arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To register the callback function for NFC write occurred
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void nfc_write(nfctag_t *obj, nfc_write_cb handler, void *arg)
|
||||
{
|
||||
obj->nfc_wr_cb = (void *)handler;
|
||||
obj->wr_cb_arg = arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To register the callback function for NFC events occurred
|
||||
* and the event mask
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void nfc_event(nfctag_t *obj, nfc_event_cb handler, void *arg, unsigned int event_mask)
|
||||
{
|
||||
obj->nfc_ev_cb = (void *)handler;
|
||||
obj->ev_cb_arg = arg;
|
||||
obj->event_mask = event_mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To set a new power mode to the NFC device
|
||||
*
|
||||
* @return The result
|
||||
*
|
||||
*/
|
||||
int nfc_power(nfctag_t *obj, int pwr_mode, int wake_event)
|
||||
{
|
||||
// TODO:
|
||||
|
||||
return NFC_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief to update the NFC read cache. The data in the NFC read cache
|
||||
* buffer will be transmitted out when NFC read occurred
|
||||
*
|
||||
* @return The result
|
||||
*
|
||||
*/
|
||||
int nfc_cache_write(nfctag_t *obj, uint32_t *tbuf, unsigned int spage, unsigned int pg_num)
|
||||
{
|
||||
u8 remain_pg;
|
||||
u8 pg_offset=0;
|
||||
u8 i;
|
||||
|
||||
if ((spage+pg_num) > NFC_MAX_CACHE_PAGE_NUM) {
|
||||
return NFC_ERROR;
|
||||
}
|
||||
|
||||
remain_pg = pg_num;
|
||||
while (remain_pg > 0) {
|
||||
if (remain_pg >= 4) {
|
||||
A2NWriteCatch (&obj->NFCAdapter, (spage+pg_offset), 4, (u32*)(&tbuf[pg_offset]));
|
||||
remain_pg -= 4;
|
||||
pg_offset += 4;
|
||||
}
|
||||
else {
|
||||
for(i=0;i<remain_pg;i++) {
|
||||
A2NWriteCatch (&obj->NFCAdapter, (spage+pg_offset), 1, (u32*)(&tbuf[pg_offset]));
|
||||
pg_offset++;
|
||||
}
|
||||
remain_pg = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return NFC_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To get current NFC status
|
||||
*
|
||||
* @return The result
|
||||
*
|
||||
*/
|
||||
int nfc_cache_raed(nfctag_t *obj, nfc_cache_read_cb handler,
|
||||
void *arg, unsigned int start_pg)
|
||||
{
|
||||
if (start_pg > NFC_MAX_CACHE_PAGE_NUM) {
|
||||
return NFC_ERROR;
|
||||
}
|
||||
|
||||
obj->nfc_cache_rd_cb = (void *)handler;
|
||||
obj->cache_read_cb_arg = arg;
|
||||
|
||||
A2NReadCatch(&(obj->NFCAdapter), (u8)start_pg);
|
||||
|
||||
return NFC_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief to read back the NFC read cache.
|
||||
*
|
||||
* @return The result
|
||||
*
|
||||
*/
|
||||
int nfc_status(nfctag_t *obj)
|
||||
{
|
||||
// TODO:
|
||||
|
||||
return (obj->pwr_status);
|
||||
}
|
||||
|
||||
#endif
|
||||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* 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.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "objects.h"
|
||||
#include "pinmap.h"
|
||||
|
||||
#if CONFIG_NFC_NORMAL
|
||||
|
||||
#include "nfc_api.h"
|
||||
|
||||
/**
|
||||
* @brief The NFC tag write callback function wrapper
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void nfc_tagwrite_callback(PNFC_ADAPTER pNFCAdp, uint32_t page, uint32_t wr_data)
|
||||
{
|
||||
nfctag_t *obj;
|
||||
nfc_write_cb handler;
|
||||
|
||||
obj = pNFCAdp->nfc_obj;
|
||||
|
||||
handler = (nfc_write_cb)obj->nfc_wr_cb;
|
||||
if (NULL != handler) {
|
||||
handler(obj->wr_cb_arg, page, wr_data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The NFC tag read callback function wrapper
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void nfc_event_callback(PNFC_ADAPTER pNFCAdp, uint32_t event)
|
||||
{
|
||||
nfctag_t *obj;
|
||||
nfc_event_cb handler;
|
||||
|
||||
obj = pNFCAdp->nfc_obj;
|
||||
|
||||
handler = (nfc_event_cb)obj->nfc_ev_cb;
|
||||
if (NULL != handler) {
|
||||
if (obj->event_mask & event) {
|
||||
handler(obj->ev_cb_arg, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The NFC tag read callback function wrapper
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void nfc_tagread_callback(PNFC_ADAPTER pNFCAdp, uint32_t page)
|
||||
{
|
||||
// notify upper layer when read tag page 0 only
|
||||
if (0 == page) {
|
||||
nfc_event_callback(pNFCAdp, NFC_EV_READ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief The NFC cache read done callback function wrapper
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void nfc_cache_read_callback(PNFC_ADAPTER pNFCAdp, uint32_t start_pg, uint32_t *pbuf)
|
||||
{
|
||||
nfctag_t *obj;
|
||||
nfc_write_cb handler;
|
||||
|
||||
obj = pNFCAdp->nfc_obj;
|
||||
|
||||
handler = (nfc_write_cb)obj->nfc_cache_rd_cb;
|
||||
if (NULL != handler) {
|
||||
handler(obj->cache_read_cb_arg, start_pg, (uint32_t)pbuf);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To initial NFC tag hardware and resource
|
||||
*
|
||||
* @return The result
|
||||
*
|
||||
*/
|
||||
int nfc_init(nfctag_t *obj, uint32_t *pg_init_val)
|
||||
{
|
||||
_memset((void *)obj, 0, sizeof(nfctag_t));
|
||||
HalNFCDmemInit(pg_init_val, NFCTAGLENGTH);
|
||||
HalNFCInit(&(obj->NFCAdapter));
|
||||
HalNFCFwDownload();
|
||||
obj->NFCAdapter.nfc_obj = obj;
|
||||
obj->pwr_status = NFC_PWR_RUNNING;
|
||||
|
||||
return NFC_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To free NFC tag hardware and resource
|
||||
*
|
||||
* @return The result
|
||||
*
|
||||
*/
|
||||
int nfc_free(nfctag_t *obj)
|
||||
{
|
||||
HalNFCDeinit(&(obj->NFCAdapter));
|
||||
return NFC_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To register the callback function for NFC read occurred
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void nfc_read(nfctag_t *obj, nfc_read_cb handler, void *arg)
|
||||
{
|
||||
obj->nfc_rd_cb = (void *)handler;
|
||||
obj->rd_cb_arg = arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To register the callback function for NFC write occurred
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void nfc_write(nfctag_t *obj, nfc_write_cb handler, void *arg)
|
||||
{
|
||||
obj->nfc_wr_cb = (void *)handler;
|
||||
obj->wr_cb_arg = arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To register the callback function for NFC events occurred
|
||||
* and the event mask
|
||||
*
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void nfc_event(nfctag_t *obj, nfc_event_cb handler, void *arg, unsigned int event_mask)
|
||||
{
|
||||
obj->nfc_ev_cb = (void *)handler;
|
||||
obj->ev_cb_arg = arg;
|
||||
obj->event_mask = event_mask;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To set a new power mode to the NFC device
|
||||
*
|
||||
* @return The result
|
||||
*
|
||||
*/
|
||||
int nfc_power(nfctag_t *obj, int pwr_mode, int wake_event)
|
||||
{
|
||||
// TODO:
|
||||
|
||||
return NFC_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief to update the NFC read cache. The data in the NFC read cache
|
||||
* buffer will be transmitted out when NFC read occurred
|
||||
*
|
||||
* @return The result
|
||||
*
|
||||
*/
|
||||
int nfc_cache_write(nfctag_t *obj, uint32_t *tbuf, unsigned int spage, unsigned int pg_num)
|
||||
{
|
||||
u8 remain_pg;
|
||||
u8 pg_offset=0;
|
||||
u8 i;
|
||||
|
||||
if ((spage+pg_num) > NFC_MAX_CACHE_PAGE_NUM) {
|
||||
return NFC_ERROR;
|
||||
}
|
||||
|
||||
remain_pg = pg_num;
|
||||
while (remain_pg > 0) {
|
||||
if (remain_pg >= 4) {
|
||||
A2NWriteCatch (&obj->NFCAdapter, (spage+pg_offset), 4, (u32*)(&tbuf[pg_offset]));
|
||||
remain_pg -= 4;
|
||||
pg_offset += 4;
|
||||
}
|
||||
else {
|
||||
for(i=0;i<remain_pg;i++) {
|
||||
A2NWriteCatch (&obj->NFCAdapter, (spage+pg_offset), 1, (u32*)(&tbuf[pg_offset]));
|
||||
pg_offset++;
|
||||
}
|
||||
remain_pg = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return NFC_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief To get current NFC status
|
||||
*
|
||||
* @return The result
|
||||
*
|
||||
*/
|
||||
int nfc_cache_raed(nfctag_t *obj, nfc_cache_read_cb handler,
|
||||
void *arg, unsigned int start_pg)
|
||||
{
|
||||
if (start_pg > NFC_MAX_CACHE_PAGE_NUM) {
|
||||
return NFC_ERROR;
|
||||
}
|
||||
|
||||
obj->nfc_cache_rd_cb = (void *)handler;
|
||||
obj->cache_read_cb_arg = arg;
|
||||
|
||||
A2NReadCatch(&(obj->NFCAdapter), (u8)start_pg);
|
||||
|
||||
return NFC_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief to read back the NFC read cache.
|
||||
*
|
||||
* @return The result
|
||||
*
|
||||
*/
|
||||
int nfc_status(nfctag_t *obj)
|
||||
{
|
||||
// TODO:
|
||||
|
||||
return (obj->pwr_status);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,206 +1,206 @@
|
|||
/* 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"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_GPIO_EN
|
||||
struct gpio_irq_s {
|
||||
PinName pin;
|
||||
uint32_t event;
|
||||
HAL_GPIO_PIN hal_pin;
|
||||
uint8_t hal_port_num;
|
||||
uint8_t hal_pin_num;
|
||||
};
|
||||
|
||||
typedef struct gpio_irq_s gpio_irq_t;
|
||||
|
||||
struct gpio_s {
|
||||
PinName pin;
|
||||
PinMode mode;
|
||||
PinDirection direction;
|
||||
HAL_GPIO_PIN hal_pin;
|
||||
uint8_t hal_port_num;
|
||||
uint8_t hal_pin_num;
|
||||
};
|
||||
|
||||
typedef struct gpio_s gpio_t;
|
||||
|
||||
struct port_s {
|
||||
PortName port;
|
||||
uint32_t mask;
|
||||
PinDirection direction;
|
||||
uint8_t *pin_def;
|
||||
};
|
||||
#endif // end of "#ifdef CONFIG_GPIO_EN"
|
||||
|
||||
#ifdef CONFIG_UART_EN
|
||||
struct serial_s {
|
||||
HAL_RUART_OP hal_uart_op;
|
||||
HAL_RUART_ADAPTER hal_uart_adp;
|
||||
#ifdef CONFIG_GDMA_EN
|
||||
UART_DMA_CONFIG uart_gdma_cfg;
|
||||
HAL_GDMA_ADAPTER uart_gdma_adp_tx;
|
||||
HAL_GDMA_ADAPTER uart_gdma_adp_rx;
|
||||
UART_DMA_MULTIBLK gdma_multiblk_list_tx;
|
||||
UART_DMA_MULTIBLK gdma_multiblk_list_rx;
|
||||
#endif
|
||||
uint32_t tx_len;
|
||||
uint32_t rx_len;
|
||||
};
|
||||
#endif // end of "#ifdef CONFIG_UART_EN"
|
||||
|
||||
struct log_uart_s {
|
||||
HAL_LOG_UART_ADAPTER log_hal_uart;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_SPI_COM_EN
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PWM_EN
|
||||
struct pwmout_s {
|
||||
uint8_t pwm_idx;
|
||||
uint8_t pin_sel;
|
||||
uint32_t period;
|
||||
uint32_t pulse;
|
||||
HAL_PWM_ADAPTER pwm_hal_adp;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_I2C_EN
|
||||
struct i2c_s {
|
||||
SAL_I2C_MNGT_ADPT SalI2CMngtAdpt;
|
||||
SAL_I2C_HND_PRIV SalI2CHndPriv;
|
||||
HAL_I2C_INIT_DAT HalI2CInitData;
|
||||
HAL_I2C_OP HalI2COp;
|
||||
IRQ_HANDLE I2CIrqHandleDat;
|
||||
HAL_GDMA_ADAPTER HalI2CTxGdmaAdpt;
|
||||
HAL_GDMA_ADAPTER HalI2CRxGdmaAdpt;
|
||||
HAL_GDMA_OP HalI2CGdmaOp;
|
||||
IRQ_HANDLE I2CTxGdmaIrqHandleDat;
|
||||
IRQ_HANDLE I2CRxGdmaIrqHandleDat;
|
||||
SAL_I2C_USER_CB SalI2CUserCB;
|
||||
SAL_I2C_USERCB_ADPT SalI2CUserCBAdpt[SAL_USER_CB_NUM];
|
||||
SAL_I2C_DMA_USER_DEF SalI2CDmaUserDef;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
struct flash_s
|
||||
{
|
||||
SPIC_INIT_PARA SpicInitPara;
|
||||
u32 Length;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef CONFIG_ADC_EN
|
||||
struct analogin_s {
|
||||
SAL_ADC_MNGT_ADPT SalADCMngtAdpt;
|
||||
SAL_ADC_HND_PRIV SalADCHndPriv;
|
||||
HAL_ADC_INIT_DAT HalADCInitData;
|
||||
HAL_ADC_OP HalADCOp;
|
||||
IRQ_HANDLE ADCIrqHandleDat;
|
||||
HAL_GDMA_ADAPTER HalADCGdmaAdpt;
|
||||
HAL_GDMA_OP HalADCGdmaOp;
|
||||
IRQ_HANDLE ADCGdmaIrqHandleDat;
|
||||
SAL_ADC_USER_CB SalADCUserCB;
|
||||
SAL_ADC_USERCB_ADPT SalADCUserCBAdpt[SAL_ADC_USER_CB_NUM];
|
||||
};
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
struct i2c_s {
|
||||
I2C_Type *i2c;
|
||||
};
|
||||
|
||||
struct spi_s {
|
||||
SPI_Type *spi;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NFC_EN
|
||||
struct nfctag_s {
|
||||
NFC_ADAPTER NFCAdapter;
|
||||
void *nfc_rd_cb; // read callback function
|
||||
void *rd_cb_arg;
|
||||
void *nfc_wr_cb; // write callback function
|
||||
void *wr_cb_arg;
|
||||
void *nfc_ev_cb; // event callback function
|
||||
void *ev_cb_arg;
|
||||
void *nfc_cache_rd_cb; // cache read callback function
|
||||
void *cache_read_cb_arg;
|
||||
unsigned int event_mask;
|
||||
int pwr_status;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIMER_EN
|
||||
struct gtimer_s {
|
||||
TIMER_ADAPTER hal_gtimer_adp;
|
||||
void *handler;
|
||||
u32 hid;
|
||||
u8 timer_id;
|
||||
u8 is_periodcal;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_I2S_EN
|
||||
struct i2s_s {
|
||||
HAL_I2S_ADAPTER I2SAdapter;
|
||||
HAL_I2S_INIT_DAT InitDat;
|
||||
u8 sampling_rate;
|
||||
u8 channel_num;
|
||||
u8 word_length;
|
||||
u8 direction;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DAC_EN
|
||||
/** \file objects.h
|
||||
* \brief A Documented file.
|
||||
*
|
||||
* A documented file.
|
||||
*/
|
||||
|
||||
/** \struct dac_s objects.h "rtl8195a/objects.h"
|
||||
* \brief This is a dac_s structure.
|
||||
*
|
||||
* For analogout APIs, a pointer to dac_s is used as an input paras.
|
||||
* A DAC initial data structure is the major element of dac_s.
|
||||
*/
|
||||
struct dac_s {
|
||||
HAL_DAC_INIT_DAT DACpara;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/* 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"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_GPIO_EN
|
||||
struct gpio_irq_s {
|
||||
PinName pin;
|
||||
uint32_t event;
|
||||
HAL_GPIO_PIN hal_pin;
|
||||
uint8_t hal_port_num;
|
||||
uint8_t hal_pin_num;
|
||||
};
|
||||
|
||||
typedef struct gpio_irq_s gpio_irq_t;
|
||||
|
||||
struct gpio_s {
|
||||
PinName pin;
|
||||
PinMode mode;
|
||||
PinDirection direction;
|
||||
HAL_GPIO_PIN hal_pin;
|
||||
uint8_t hal_port_num;
|
||||
uint8_t hal_pin_num;
|
||||
};
|
||||
|
||||
typedef struct gpio_s gpio_t;
|
||||
|
||||
struct port_s {
|
||||
PortName port;
|
||||
uint32_t mask;
|
||||
PinDirection direction;
|
||||
uint8_t *pin_def;
|
||||
};
|
||||
#endif // end of "#ifdef CONFIG_GPIO_EN"
|
||||
|
||||
#ifdef CONFIG_UART_EN
|
||||
struct serial_s {
|
||||
HAL_RUART_OP hal_uart_op;
|
||||
HAL_RUART_ADAPTER hal_uart_adp;
|
||||
#ifdef CONFIG_GDMA_EN
|
||||
UART_DMA_CONFIG uart_gdma_cfg;
|
||||
HAL_GDMA_ADAPTER uart_gdma_adp_tx;
|
||||
HAL_GDMA_ADAPTER uart_gdma_adp_rx;
|
||||
UART_DMA_MULTIBLK gdma_multiblk_list_tx;
|
||||
UART_DMA_MULTIBLK gdma_multiblk_list_rx;
|
||||
#endif
|
||||
uint32_t tx_len;
|
||||
uint32_t rx_len;
|
||||
};
|
||||
#endif // end of "#ifdef CONFIG_UART_EN"
|
||||
|
||||
struct log_uart_s {
|
||||
HAL_LOG_UART_ADAPTER log_hal_uart;
|
||||
};
|
||||
|
||||
#ifdef CONFIG_SPI_COM_EN
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_PWM_EN
|
||||
struct pwmout_s {
|
||||
uint8_t pwm_idx;
|
||||
uint8_t pin_sel;
|
||||
uint32_t period;
|
||||
uint32_t pulse;
|
||||
HAL_PWM_ADAPTER pwm_hal_adp;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_I2C_EN
|
||||
struct i2c_s {
|
||||
SAL_I2C_MNGT_ADPT SalI2CMngtAdpt;
|
||||
SAL_I2C_HND_PRIV SalI2CHndPriv;
|
||||
HAL_I2C_INIT_DAT HalI2CInitData;
|
||||
HAL_I2C_OP HalI2COp;
|
||||
IRQ_HANDLE I2CIrqHandleDat;
|
||||
HAL_GDMA_ADAPTER HalI2CTxGdmaAdpt;
|
||||
HAL_GDMA_ADAPTER HalI2CRxGdmaAdpt;
|
||||
HAL_GDMA_OP HalI2CGdmaOp;
|
||||
IRQ_HANDLE I2CTxGdmaIrqHandleDat;
|
||||
IRQ_HANDLE I2CRxGdmaIrqHandleDat;
|
||||
SAL_I2C_USER_CB SalI2CUserCB;
|
||||
SAL_I2C_USERCB_ADPT SalI2CUserCBAdpt[SAL_USER_CB_NUM];
|
||||
SAL_I2C_DMA_USER_DEF SalI2CDmaUserDef;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
struct flash_s
|
||||
{
|
||||
SPIC_INIT_PARA SpicInitPara;
|
||||
u32 Length;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#ifdef CONFIG_ADC_EN
|
||||
struct analogin_s {
|
||||
SAL_ADC_MNGT_ADPT SalADCMngtAdpt;
|
||||
SAL_ADC_HND_PRIV SalADCHndPriv;
|
||||
HAL_ADC_INIT_DAT HalADCInitData;
|
||||
HAL_ADC_OP HalADCOp;
|
||||
IRQ_HANDLE ADCIrqHandleDat;
|
||||
HAL_GDMA_ADAPTER HalADCGdmaAdpt;
|
||||
HAL_GDMA_OP HalADCGdmaOp;
|
||||
IRQ_HANDLE ADCGdmaIrqHandleDat;
|
||||
SAL_ADC_USER_CB SalADCUserCB;
|
||||
SAL_ADC_USERCB_ADPT SalADCUserCBAdpt[SAL_ADC_USER_CB_NUM];
|
||||
};
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
struct i2c_s {
|
||||
I2C_Type *i2c;
|
||||
};
|
||||
|
||||
struct spi_s {
|
||||
SPI_Type *spi;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_NFC_EN
|
||||
struct nfctag_s {
|
||||
NFC_ADAPTER NFCAdapter;
|
||||
void *nfc_rd_cb; // read callback function
|
||||
void *rd_cb_arg;
|
||||
void *nfc_wr_cb; // write callback function
|
||||
void *wr_cb_arg;
|
||||
void *nfc_ev_cb; // event callback function
|
||||
void *ev_cb_arg;
|
||||
void *nfc_cache_rd_cb; // cache read callback function
|
||||
void *cache_read_cb_arg;
|
||||
unsigned int event_mask;
|
||||
int pwr_status;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_TIMER_EN
|
||||
struct gtimer_s {
|
||||
TIMER_ADAPTER hal_gtimer_adp;
|
||||
void *handler;
|
||||
u32 hid;
|
||||
u8 timer_id;
|
||||
u8 is_periodcal;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_I2S_EN
|
||||
struct i2s_s {
|
||||
HAL_I2S_ADAPTER I2SAdapter;
|
||||
HAL_I2S_INIT_DAT InitDat;
|
||||
u8 sampling_rate;
|
||||
u8 channel_num;
|
||||
u8 word_length;
|
||||
u8 direction;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DAC_EN
|
||||
/** \file objects.h
|
||||
* \brief A Documented file.
|
||||
*
|
||||
* A documented file.
|
||||
*/
|
||||
|
||||
/** \struct dac_s objects.h "rtl8195a/objects.h"
|
||||
* \brief This is a dac_s structure.
|
||||
*
|
||||
* For analogout APIs, a pointer to dac_s is used as an input paras.
|
||||
* A DAC initial data structure is the major element of dac_s.
|
||||
*/
|
||||
struct dac_s {
|
||||
HAL_DAC_INIT_DAT DACpara;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,34 +1,34 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* 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.
|
||||
*******************************************************************************
|
||||
*/
|
||||
//#include "mbed_assert.h"
|
||||
#include "objects.h"
|
||||
#include "pinmap.h"
|
||||
//#include "error.h"
|
||||
|
||||
/**
|
||||
* Configure pin enable and function
|
||||
*/
|
||||
void pin_function(PinName pin, int function)
|
||||
{
|
||||
// MBED_ASSERT(pin != (PinName)NC);
|
||||
//1 Our HAL API cannot support to configure the pin function by this way
|
||||
/* the pin function (pin mux) is depends on each IP On/Off and priority, so we cannot
|
||||
set the pin function directly */
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure pin pull-up/pull-down
|
||||
*/
|
||||
void pin_mode(PinName pin, PinMode mode)
|
||||
{
|
||||
// MBED_ASSERT(pin != (PinName)NC);
|
||||
HAL_GPIO_PullCtrl((u32)pin, (u32)mode);
|
||||
|
||||
}
|
||||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* 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.
|
||||
*******************************************************************************
|
||||
*/
|
||||
//#include "mbed_assert.h"
|
||||
#include "objects.h"
|
||||
#include "pinmap.h"
|
||||
//#include "error.h"
|
||||
|
||||
/**
|
||||
* Configure pin enable and function
|
||||
*/
|
||||
void pin_function(PinName pin, int function)
|
||||
{
|
||||
// MBED_ASSERT(pin != (PinName)NC);
|
||||
//1 Our HAL API cannot support to configure the pin function by this way
|
||||
/* the pin function (pin mux) is depends on each IP On/Off and priority, so we cannot
|
||||
set the pin function directly */
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure pin pull-up/pull-down
|
||||
*/
|
||||
void pin_mode(PinName pin, PinMode mode)
|
||||
{
|
||||
// MBED_ASSERT(pin != (PinName)NC);
|
||||
HAL_GPIO_PullCtrl((u32)pin, (u32)mode);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,73 +1,73 @@
|
|||
/* 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 "basic_types.h"
|
||||
#include "diag.h"
|
||||
#include "pinmap.h"
|
||||
//#include "error.h"
|
||||
|
||||
__weak void pinmap_pinout(PinName pin, const PinMap *map) {
|
||||
#if 0
|
||||
if (pin == NC)
|
||||
return;
|
||||
|
||||
while (map->pin != NC) {
|
||||
if (map->pin == pin) {
|
||||
pin_function(pin, map->function);
|
||||
|
||||
pin_mode(pin, PullNone);
|
||||
return;
|
||||
}
|
||||
map++;
|
||||
}
|
||||
DBG_GPIO_ERR("%s: could not pinout\n", __FUNCTION__);
|
||||
#endif
|
||||
}
|
||||
|
||||
__weak uint32_t pinmap_merge(uint32_t a, uint32_t b) {
|
||||
// both are the same (inc both NC)
|
||||
if (a == b)
|
||||
return a;
|
||||
|
||||
// one (or both) is not connected
|
||||
if (a == (uint32_t)NC)
|
||||
return b;
|
||||
if (b == (uint32_t)NC)
|
||||
return a;
|
||||
|
||||
// mis-match error case
|
||||
DBG_GPIO_ERR("%s: pinmap mis-match\n", __FUNCTION__);
|
||||
return (uint32_t)NC;
|
||||
}
|
||||
|
||||
__weak uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map) {
|
||||
while (map->pin != NC) {
|
||||
if (map->pin == pin)
|
||||
return map->peripheral;
|
||||
map++;
|
||||
}
|
||||
return (uint32_t)NC;
|
||||
}
|
||||
|
||||
__weak uint32_t pinmap_peripheral(PinName pin, const PinMap* map) {
|
||||
uint32_t peripheral = (uint32_t)NC;
|
||||
|
||||
if (pin == (PinName)NC)
|
||||
return (uint32_t)NC;
|
||||
peripheral = pinmap_find_peripheral(pin, map);
|
||||
if ((uint32_t)NC == peripheral) // no mapping available
|
||||
DBG_GPIO_ERR("%s: pinmap not found for peripheral\n", __FUNCTION__);
|
||||
return peripheral;
|
||||
}
|
||||
/* 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 "basic_types.h"
|
||||
#include "diag.h"
|
||||
#include "pinmap.h"
|
||||
//#include "error.h"
|
||||
|
||||
__weak void pinmap_pinout(PinName pin, const PinMap *map) {
|
||||
#if 0
|
||||
if (pin == NC)
|
||||
return;
|
||||
|
||||
while (map->pin != NC) {
|
||||
if (map->pin == pin) {
|
||||
pin_function(pin, map->function);
|
||||
|
||||
pin_mode(pin, PullNone);
|
||||
return;
|
||||
}
|
||||
map++;
|
||||
}
|
||||
DBG_GPIO_ERR("%s: could not pinout\n", __FUNCTION__);
|
||||
#endif
|
||||
}
|
||||
|
||||
__weak uint32_t pinmap_merge(uint32_t a, uint32_t b) {
|
||||
// both are the same (inc both NC)
|
||||
if (a == b)
|
||||
return a;
|
||||
|
||||
// one (or both) is not connected
|
||||
if (a == (uint32_t)NC)
|
||||
return b;
|
||||
if (b == (uint32_t)NC)
|
||||
return a;
|
||||
|
||||
// mis-match error case
|
||||
DBG_GPIO_ERR("%s: pinmap mis-match\n", __FUNCTION__);
|
||||
return (uint32_t)NC;
|
||||
}
|
||||
|
||||
__weak uint32_t pinmap_find_peripheral(PinName pin, const PinMap* map) {
|
||||
while (map->pin != NC) {
|
||||
if (map->pin == pin)
|
||||
return map->peripheral;
|
||||
map++;
|
||||
}
|
||||
return (uint32_t)NC;
|
||||
}
|
||||
|
||||
__weak uint32_t pinmap_peripheral(PinName pin, const PinMap* map) {
|
||||
uint32_t peripheral = (uint32_t)NC;
|
||||
|
||||
if (pin == (PinName)NC)
|
||||
return (uint32_t)NC;
|
||||
peripheral = pinmap_find_peripheral(pin, map);
|
||||
if ((uint32_t)NC == peripheral) // no mapping available
|
||||
DBG_GPIO_ERR("%s: pinmap not found for peripheral\n", __FUNCTION__);
|
||||
return peripheral;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,290 +1,290 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "sleep_ex_api.h"
|
||||
#include "cmsis.h"
|
||||
|
||||
extern VOID SleepCG(u8 Option, u32 SDuration, u8 ClkSourceEn, u8 SDREn);
|
||||
extern VOID DeepStandby(u8 Option, u32 SDuration, u8 GpioOption);
|
||||
extern VOID DeepSleep(u8 Option, u32 SDuration);
|
||||
|
||||
SLEEP_WAKEUP_EVENT DStandbyWakeupEvent={0};
|
||||
|
||||
/**
|
||||
* @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. Available event:
|
||||
* SLEEP_WAKEUP_BY_STIMER
|
||||
* SLEEP_WAKEUP_BY_GTIMER
|
||||
* SLEEP_WAKEUP_BY_GPIO_INT
|
||||
* SLEEP_WAKEUP_BY_WLAN
|
||||
* SLEEP_WAKEUP_BY_NFC
|
||||
* SLEEP_WAKEUP_BY_SDIO
|
||||
* SLEEP_WAKEUP_BY_USB
|
||||
* 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)
|
||||
{
|
||||
u8 wake_ev=0;
|
||||
|
||||
wake_ev = wakeup_event & 0xff;
|
||||
|
||||
if (sleep_duration == 0) {
|
||||
wake_ev &= ~SLP_STIMER;
|
||||
}
|
||||
|
||||
if (wake_ev == 0) {
|
||||
// error: No wakeup event, skip the entering sleep mode
|
||||
return;
|
||||
}
|
||||
SleepCG(wake_ev, sleep_duration, 0, 0); // same as old configuration: SCLK off & SDR no power off
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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. Available event:
|
||||
* SLEEP_WAKEUP_BY_STIMER
|
||||
* SLEEP_WAKEUP_BY_GTIMER
|
||||
* SLEEP_WAKEUP_BY_GPIO_INT
|
||||
* SLEEP_WAKEUP_BY_WLAN
|
||||
* SLEEP_WAKEUP_BY_NFC
|
||||
* SLEEP_WAKEUP_BY_SDIO
|
||||
* SLEEP_WAKEUP_BY_USB
|
||||
* sleep_duration: the system sleep duration in ms, only valid
|
||||
* for SLEEP_WAKEUP_BY_STIMER wake up event.
|
||||
* clk_sourec_enable: the option for SCLK on(1)/off(0)
|
||||
* 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)
|
||||
{
|
||||
u8 wake_ev=0;
|
||||
u8 sdr_en=0;
|
||||
u8 clk_source_en=0;
|
||||
|
||||
wake_ev = wakeup_event & 0xff;
|
||||
sdr_en = sdr_enable & 0xff;
|
||||
clk_source_en = clk_sourec_enable & 0xff;
|
||||
|
||||
if (sleep_duration == 0) {
|
||||
wake_ev &= ~SLP_STIMER;
|
||||
}
|
||||
|
||||
if (wake_ev == 0) {
|
||||
// error: No wakeup event, skip the entering sleep mode
|
||||
return;
|
||||
}
|
||||
SleepCG(wake_ev, sleep_duration, clk_source_en, sdr_en);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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. Available event:
|
||||
* STANDBY_WAKEUP_BY_STIMER
|
||||
* STANDBY_WAKEUP_BY_NFC
|
||||
* STANDBY_WAKEUP_BY_PA5 (GPIO)
|
||||
* STANDBY_WAKEUP_BY_PC7 (GPIO)
|
||||
* STANDBY_WAKEUP_BY_PD5 (GPIO)
|
||||
* STANDBY_WAKEUP_BY_PE3 (GPIO)
|
||||
* sleep_duration_ms: the system sleep duration in ms, only valid
|
||||
* for STANDBY_WAKEUP_BY_STIMER wake up event.
|
||||
* gpio_active: for a GPIO pin to wake up the system by
|
||||
* goes high(1) or low(0)
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
void standby_wakeup_event_add(uint32_t wakeup_event, uint32_t sleep_duration_ms, uint32_t gpio_active)
|
||||
{
|
||||
u32 i;
|
||||
u8 gpio_event;
|
||||
u8 gpio_en;
|
||||
u8 gpio_act;
|
||||
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_STIMER) {
|
||||
DStandbyWakeupEvent.wakeup_event |= DSTBY_STIMER;
|
||||
DStandbyWakeupEvent.timer_duration = sleep_duration_ms;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_DS_TIMER) {
|
||||
DStandbyWakeupEvent.wakeup_event |= DSTBY_TIMER33;
|
||||
// TODO: Sleep Duration ?
|
||||
}
|
||||
#endif
|
||||
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_NFC) {
|
||||
DStandbyWakeupEvent.wakeup_event |= DSTBY_NFC;
|
||||
}
|
||||
|
||||
gpio_event = STANDBY_WAKEUP_BY_PA5;
|
||||
gpio_en = BIT0;
|
||||
gpio_act = BIT4;
|
||||
// Loop 4 to check 4 GPIO wake up event
|
||||
for (i=0;i<4;i++) {
|
||||
if (wakeup_event & gpio_event) {
|
||||
DStandbyWakeupEvent.wakeup_event |= DSTBY_GPIO;
|
||||
DStandbyWakeupEvent.gpio_option |= gpio_en;
|
||||
if (gpio_active) {
|
||||
// Active High
|
||||
DStandbyWakeupEvent.gpio_option |= gpio_act;
|
||||
}
|
||||
else {
|
||||
// Active Low
|
||||
DStandbyWakeupEvent.gpio_option &= ~gpio_act;
|
||||
}
|
||||
}
|
||||
gpio_event = gpio_event << 1;
|
||||
gpio_en = gpio_en << 1;
|
||||
gpio_act = gpio_act << 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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. Available event:
|
||||
* STANDBY_WAKEUP_BY_STIMER
|
||||
* STANDBY_WAKEUP_BY_NFC
|
||||
* STANDBY_WAKEUP_BY_PA5 (GPIO)
|
||||
* STANDBY_WAKEUP_BY_PC7 (GPIO)
|
||||
* STANDBY_WAKEUP_BY_PD5 (GPIO)
|
||||
* STANDBY_WAKEUP_BY_PE3 (GPIO)
|
||||
* @retval None
|
||||
*/
|
||||
void standby_wakeup_event_del(uint32_t wakeup_event)
|
||||
{
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_STIMER) {
|
||||
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_STIMER;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_DS_TIMER) {
|
||||
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_TIMER33;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_NFC) {
|
||||
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_NFC;
|
||||
}
|
||||
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_PA5) {
|
||||
DStandbyWakeupEvent.gpio_option &= ~BIT0;
|
||||
}
|
||||
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_PC7) {
|
||||
DStandbyWakeupEvent.gpio_option &= ~BIT1;
|
||||
}
|
||||
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_PD5) {
|
||||
DStandbyWakeupEvent.gpio_option &= ~BIT2;
|
||||
}
|
||||
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_PE3) {
|
||||
DStandbyWakeupEvent.gpio_option &= ~BIT3;
|
||||
}
|
||||
|
||||
if ((DStandbyWakeupEvent.gpio_option & 0x0f) == 0) {
|
||||
// All GPIO wake up pin are disabled
|
||||
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_GPIO;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
if ((DStandbyWakeupEvent.wakeup_event & (DSTBY_STIMER|DSTBY_NFC|DSTBY_GPIO)) == 0) {
|
||||
// error: no wakeup event was added, so skip the entering standby power saving
|
||||
return;
|
||||
}
|
||||
|
||||
DeepStandby(DStandbyWakeupEvent.wakeup_event,
|
||||
DStandbyWakeupEvent.timer_duration, DStandbyWakeupEvent.gpio_option);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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. Available event:
|
||||
* DSLEEP_WAKEUP_BY_TIMER
|
||||
* DSLEEP_WAKEUP_BY_GPIO
|
||||
* 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)
|
||||
{
|
||||
u8 wake_ev=0;
|
||||
|
||||
if ((wakeup_event & DSLEEP_WAKEUP_BY_TIMER) && (sleep_duration > 0)) {
|
||||
// wake up by timeout
|
||||
wake_ev |= DS_TIMER33;
|
||||
}
|
||||
|
||||
if (wakeup_event & DSLEEP_WAKEUP_BY_GPIO) {
|
||||
// wake up by GPIO pin goes high
|
||||
wake_ev |= DS_GPIO;
|
||||
}
|
||||
|
||||
if (wake_ev == 0) {
|
||||
// error: No wake up event, skip entering deep sleep mode
|
||||
return;
|
||||
}
|
||||
DeepSleep (wake_ev, sleep_duration);
|
||||
}
|
||||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, STMicroelectronics
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of STMicroelectronics nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "sleep_ex_api.h"
|
||||
#include "cmsis.h"
|
||||
|
||||
extern VOID SleepCG(u8 Option, u32 SDuration, u8 ClkSourceEn, u8 SDREn);
|
||||
extern VOID DeepStandby(u8 Option, u32 SDuration, u8 GpioOption);
|
||||
extern VOID DeepSleep(u8 Option, u32 SDuration);
|
||||
|
||||
SLEEP_WAKEUP_EVENT DStandbyWakeupEvent={0};
|
||||
|
||||
/**
|
||||
* @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. Available event:
|
||||
* SLEEP_WAKEUP_BY_STIMER
|
||||
* SLEEP_WAKEUP_BY_GTIMER
|
||||
* SLEEP_WAKEUP_BY_GPIO_INT
|
||||
* SLEEP_WAKEUP_BY_WLAN
|
||||
* SLEEP_WAKEUP_BY_NFC
|
||||
* SLEEP_WAKEUP_BY_SDIO
|
||||
* SLEEP_WAKEUP_BY_USB
|
||||
* 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)
|
||||
{
|
||||
u8 wake_ev=0;
|
||||
|
||||
wake_ev = wakeup_event & 0xff;
|
||||
|
||||
if (sleep_duration == 0) {
|
||||
wake_ev &= ~SLP_STIMER;
|
||||
}
|
||||
|
||||
if (wake_ev == 0) {
|
||||
// error: No wakeup event, skip the entering sleep mode
|
||||
return;
|
||||
}
|
||||
SleepCG(wake_ev, sleep_duration, 0, 0); // same as old configuration: SCLK off & SDR no power off
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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. Available event:
|
||||
* SLEEP_WAKEUP_BY_STIMER
|
||||
* SLEEP_WAKEUP_BY_GTIMER
|
||||
* SLEEP_WAKEUP_BY_GPIO_INT
|
||||
* SLEEP_WAKEUP_BY_WLAN
|
||||
* SLEEP_WAKEUP_BY_NFC
|
||||
* SLEEP_WAKEUP_BY_SDIO
|
||||
* SLEEP_WAKEUP_BY_USB
|
||||
* sleep_duration: the system sleep duration in ms, only valid
|
||||
* for SLEEP_WAKEUP_BY_STIMER wake up event.
|
||||
* clk_sourec_enable: the option for SCLK on(1)/off(0)
|
||||
* 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)
|
||||
{
|
||||
u8 wake_ev=0;
|
||||
u8 sdr_en=0;
|
||||
u8 clk_source_en=0;
|
||||
|
||||
wake_ev = wakeup_event & 0xff;
|
||||
sdr_en = sdr_enable & 0xff;
|
||||
clk_source_en = clk_sourec_enable & 0xff;
|
||||
|
||||
if (sleep_duration == 0) {
|
||||
wake_ev &= ~SLP_STIMER;
|
||||
}
|
||||
|
||||
if (wake_ev == 0) {
|
||||
// error: No wakeup event, skip the entering sleep mode
|
||||
return;
|
||||
}
|
||||
SleepCG(wake_ev, sleep_duration, clk_source_en, sdr_en);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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. Available event:
|
||||
* STANDBY_WAKEUP_BY_STIMER
|
||||
* STANDBY_WAKEUP_BY_NFC
|
||||
* STANDBY_WAKEUP_BY_PA5 (GPIO)
|
||||
* STANDBY_WAKEUP_BY_PC7 (GPIO)
|
||||
* STANDBY_WAKEUP_BY_PD5 (GPIO)
|
||||
* STANDBY_WAKEUP_BY_PE3 (GPIO)
|
||||
* sleep_duration_ms: the system sleep duration in ms, only valid
|
||||
* for STANDBY_WAKEUP_BY_STIMER wake up event.
|
||||
* gpio_active: for a GPIO pin to wake up the system by
|
||||
* goes high(1) or low(0)
|
||||
*
|
||||
* @retval None
|
||||
*/
|
||||
void standby_wakeup_event_add(uint32_t wakeup_event, uint32_t sleep_duration_ms, uint32_t gpio_active)
|
||||
{
|
||||
u32 i;
|
||||
u8 gpio_event;
|
||||
u8 gpio_en;
|
||||
u8 gpio_act;
|
||||
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_STIMER) {
|
||||
DStandbyWakeupEvent.wakeup_event |= DSTBY_STIMER;
|
||||
DStandbyWakeupEvent.timer_duration = sleep_duration_ms;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_DS_TIMER) {
|
||||
DStandbyWakeupEvent.wakeup_event |= DSTBY_TIMER33;
|
||||
// TODO: Sleep Duration ?
|
||||
}
|
||||
#endif
|
||||
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_NFC) {
|
||||
DStandbyWakeupEvent.wakeup_event |= DSTBY_NFC;
|
||||
}
|
||||
|
||||
gpio_event = STANDBY_WAKEUP_BY_PA5;
|
||||
gpio_en = BIT0;
|
||||
gpio_act = BIT4;
|
||||
// Loop 4 to check 4 GPIO wake up event
|
||||
for (i=0;i<4;i++) {
|
||||
if (wakeup_event & gpio_event) {
|
||||
DStandbyWakeupEvent.wakeup_event |= DSTBY_GPIO;
|
||||
DStandbyWakeupEvent.gpio_option |= gpio_en;
|
||||
if (gpio_active) {
|
||||
// Active High
|
||||
DStandbyWakeupEvent.gpio_option |= gpio_act;
|
||||
}
|
||||
else {
|
||||
// Active Low
|
||||
DStandbyWakeupEvent.gpio_option &= ~gpio_act;
|
||||
}
|
||||
}
|
||||
gpio_event = gpio_event << 1;
|
||||
gpio_en = gpio_en << 1;
|
||||
gpio_act = gpio_act << 1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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. Available event:
|
||||
* STANDBY_WAKEUP_BY_STIMER
|
||||
* STANDBY_WAKEUP_BY_NFC
|
||||
* STANDBY_WAKEUP_BY_PA5 (GPIO)
|
||||
* STANDBY_WAKEUP_BY_PC7 (GPIO)
|
||||
* STANDBY_WAKEUP_BY_PD5 (GPIO)
|
||||
* STANDBY_WAKEUP_BY_PE3 (GPIO)
|
||||
* @retval None
|
||||
*/
|
||||
void standby_wakeup_event_del(uint32_t wakeup_event)
|
||||
{
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_STIMER) {
|
||||
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_STIMER;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_DS_TIMER) {
|
||||
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_TIMER33;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_NFC) {
|
||||
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_NFC;
|
||||
}
|
||||
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_PA5) {
|
||||
DStandbyWakeupEvent.gpio_option &= ~BIT0;
|
||||
}
|
||||
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_PC7) {
|
||||
DStandbyWakeupEvent.gpio_option &= ~BIT1;
|
||||
}
|
||||
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_PD5) {
|
||||
DStandbyWakeupEvent.gpio_option &= ~BIT2;
|
||||
}
|
||||
|
||||
if (wakeup_event & STANDBY_WAKEUP_BY_PE3) {
|
||||
DStandbyWakeupEvent.gpio_option &= ~BIT3;
|
||||
}
|
||||
|
||||
if ((DStandbyWakeupEvent.gpio_option & 0x0f) == 0) {
|
||||
// All GPIO wake up pin are disabled
|
||||
DStandbyWakeupEvent.wakeup_event &= ~DSTBY_GPIO;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @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)
|
||||
{
|
||||
if ((DStandbyWakeupEvent.wakeup_event & (DSTBY_STIMER|DSTBY_NFC|DSTBY_GPIO)) == 0) {
|
||||
// error: no wakeup event was added, so skip the entering standby power saving
|
||||
return;
|
||||
}
|
||||
|
||||
DeepStandby(DStandbyWakeupEvent.wakeup_event,
|
||||
DStandbyWakeupEvent.timer_duration, DStandbyWakeupEvent.gpio_option);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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. Available event:
|
||||
* DSLEEP_WAKEUP_BY_TIMER
|
||||
* DSLEEP_WAKEUP_BY_GPIO
|
||||
* 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)
|
||||
{
|
||||
u8 wake_ev=0;
|
||||
|
||||
if ((wakeup_event & DSLEEP_WAKEUP_BY_TIMER) && (sleep_duration > 0)) {
|
||||
// wake up by timeout
|
||||
wake_ev |= DS_TIMER33;
|
||||
}
|
||||
|
||||
if (wakeup_event & DSLEEP_WAKEUP_BY_GPIO) {
|
||||
// wake up by GPIO pin goes high
|
||||
wake_ev |= DS_GPIO;
|
||||
}
|
||||
|
||||
if (wake_ev == 0) {
|
||||
// error: No wake up event, skip entering deep sleep mode
|
||||
return;
|
||||
}
|
||||
DeepSleep (wake_ev, sleep_duration);
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,94 +1,94 @@
|
|||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, Realtek
|
||||
* All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "wdt_api.h"
|
||||
#include "cmsis.h"
|
||||
|
||||
extern VOID WDGInitial(u32 Period);
|
||||
extern VOID WDGStart(VOID);
|
||||
extern VOID WDGStop(VOID);
|
||||
extern VOID WDGRefresh(VOID);
|
||||
extern VOID WDGIrqInitial(VOID);
|
||||
extern VOID WDGIrqCallBackReg(VOID *CallBack, u32 Id);
|
||||
|
||||
/**
|
||||
* @brief Initial the watch dog time setting
|
||||
*
|
||||
* @param timeout_ms: the watch-dog timer timeout value, in ms.
|
||||
* default action of timeout is to reset the whole system.
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void watchdog_init(uint32_t timeout_ms)
|
||||
{
|
||||
WDGInitial(timeout_ms);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Start the watchdog counting
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void watchdog_start(void)
|
||||
{
|
||||
WDGStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stop the watchdog counting
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void watchdog_stop(void)
|
||||
{
|
||||
WDGStop();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Refresh the watchdog counting to prevent WDT timeout
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void watchdog_refresh(void)
|
||||
{
|
||||
WDGRefresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
* id: the parameter for the callback function
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void watchdog_irq_init(wdt_irq_handler handler, uint32_t id)
|
||||
{
|
||||
WDGIrqCallBackReg((VOID*)handler, (u32)id);
|
||||
WDGIrqInitial();
|
||||
}
|
||||
|
||||
|
||||
/* mbed Microcontroller Library
|
||||
*******************************************************************************
|
||||
* Copyright (c) 2014, Realtek
|
||||
* All rights reserved.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "wdt_api.h"
|
||||
#include "cmsis.h"
|
||||
|
||||
extern VOID WDGInitial(u32 Period);
|
||||
extern VOID WDGStart(VOID);
|
||||
extern VOID WDGStop(VOID);
|
||||
extern VOID WDGRefresh(VOID);
|
||||
extern VOID WDGIrqInitial(VOID);
|
||||
extern VOID WDGIrqCallBackReg(VOID *CallBack, u32 Id);
|
||||
|
||||
/**
|
||||
* @brief Initial the watch dog time setting
|
||||
*
|
||||
* @param timeout_ms: the watch-dog timer timeout value, in ms.
|
||||
* default action of timeout is to reset the whole system.
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void watchdog_init(uint32_t timeout_ms)
|
||||
{
|
||||
WDGInitial(timeout_ms);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Start the watchdog counting
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void watchdog_start(void)
|
||||
{
|
||||
WDGStart();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Stop the watchdog counting
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void watchdog_stop(void)
|
||||
{
|
||||
WDGStop();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Refresh the watchdog counting to prevent WDT timeout
|
||||
*
|
||||
* @param None
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void watchdog_refresh(void)
|
||||
{
|
||||
WDGRefresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
* id: the parameter for the callback function
|
||||
* @return None
|
||||
*
|
||||
*/
|
||||
void watchdog_irq_init(wdt_irq_handler handler, uint32_t id)
|
||||
{
|
||||
WDGIrqCallBackReg((VOID*)handler, (u32)id);
|
||||
WDGIrqInitial();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue