ameba micropython sdk first commit

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

View file

View file

@ -0,0 +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)

View file

@ -0,0 +1,118 @@
/* 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 <stddef.h>
#include "us_ticker_api.h"
#include "cmsis.h"
static ticker_event_handler event_handler;
static ticker_event_t *head = NULL;
void us_ticker_set_handler(ticker_event_handler handler) {
us_ticker_init();
event_handler = handler;
}
void us_ticker_irq_handler(void) {
us_ticker_clear_interrupt();
/* Go through all the pending TimerEvents */
while (1) {
if (head == NULL) {
// There are no more TimerEvents left, so disable matches.
us_ticker_disable_interrupt();
return;
}
if ((int)(head->timestamp - us_ticker_read()) <= 0) {
// This event was in the past:
// point to the following one and execute its handler
ticker_event_t *p = head;
head = head->next;
if (event_handler != NULL) {
event_handler(p->id); // NOTE: the handler can set new events
}
/* Note: We continue back to examining the head because calling the
* event handler may have altered the chain of pending events. */
} else {
// This event and the following ones in the list are in the future:
// set it as next interrupt and return
us_ticker_set_interrupt(head->timestamp);
return;
}
}
}
void us_ticker_insert_event(ticker_event_t *obj, timestamp_t timestamp, uint32_t id) {
/* disable interrupts for the duration of the function */
__disable_irq();
// initialise our data
obj->timestamp = timestamp;
obj->id = id;
/* Go through the list until we either reach the end, or find
an element this should come before (which is possibly the
head). */
ticker_event_t *prev = NULL, *p = head;
while (p != NULL) {
/* check if we come before p */
if ((int)(timestamp - p->timestamp) <= 0) {
break;
}
/* go to the next element */
prev = p;
p = p->next;
}
/* if prev is NULL we're at the head */
if (prev == NULL) {
head = obj;
us_ticker_set_interrupt(timestamp);
} else {
prev->next = obj;
}
/* if we're at the end p will be NULL, which is correct */
obj->next = p;
__enable_irq();
}
void us_ticker_remove_event(ticker_event_t *obj) {
__disable_irq();
// remove this object from the list
if (head == obj) {
// first in the list, so just drop me
head = obj->next;
if (head == NULL) {
us_ticker_disable_interrupt();
} else {
us_ticker_set_interrupt(head->timestamp);
}
} else {
// find the object before me, then drop me
ticker_event_t* p = head;
while (p != NULL) {
if (p->next == obj) {
p->next = obj->next;
break;
}
p = p->next;
}
}
__enable_irq();
}

View file

@ -0,0 +1,30 @@
/* 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 "wait_api.h"
#include "us_ticker_api.h"
void wait(float s) {
wait_us((int)(s * 1000000.0f));
}
void wait_ms(int ms) {
wait_us(ms * 1000);
}
void wait_us(int us) {
uint32_t start = us_ticker_read();
while ((us_ticker_read() - start) < (uint32_t)us);
}