mirror of
https://github.com/taubel/sdk-ameba-v4.0b-gcc.git
synced 2026-07-04 02:25:39 +00:00
initial commit
This commit is contained in:
commit
60a7afcc83
2528 changed files with 1001987 additions and 0 deletions
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
|
||||
.PHONY: all copy clean
|
||||
|
||||
#*****************************************************************************#
|
||||
# Source FILE LIST #
|
||||
#*****************************************************************************#
|
||||
CSRC = src inc
|
||||
|
||||
|
||||
|
||||
#*****************************************************************************#
|
||||
# RULES TO GENERATE TARGETS #
|
||||
#*****************************************************************************#
|
||||
|
||||
# Define the Rules to build the core targets
|
||||
all: copy
|
||||
copy:
|
||||
for cpf in $(CSRC); do \
|
||||
cp -rf $$cpf ../..; \
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
Example Description
|
||||
|
||||
This example describes how to use deep standby api.
|
||||
|
||||
Requirement Components:
|
||||
a LED
|
||||
a push button
|
||||
a wakeup pin
|
||||
|
||||
Pin name PA_0, PA_5 and PA_22 map to GPIOA_0, GPIOA_5 and GPIOA_22:
|
||||
- PA_5 as input to wakeup the system
|
||||
- PA_0 as output, connect a LED to this pin and ground.
|
||||
- PA_22 as input with internal pull-high, connect a push button to this pin and ground.
|
||||
|
||||
In this example, LED is turned on after device initialize.
|
||||
User push the button to turn off LED and trigger device enter deep standby mode for 8s.
|
||||
If user give failing edge at PA_5 before sleep timeout, the system will resume.
|
||||
LED is turned on again after device initialize.
|
||||
|
||||
It can be easily measure power consumption in normal mode and deep standby mode before/after push the putton.
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
|
||||
include $(MAKE_INCLUDE_GEN)
|
||||
#include ./Makefile.inc
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
CHIP = rtl8195a
|
||||
HALINCDIR = realtek/v3_0/include
|
||||
|
||||
MODULE_IFLAGS += -I$(shell pwd -L)/../inc
|
||||
MODULE_IFLAGS += -I$(SWLIBDIR)/api
|
||||
MODULE_IFLAGS += -I$(SWLIBDIR)/api/mbed/hal/
|
||||
MODULE_IFLAGS += -I$(SWLIBDIR)/api/mbed/api/
|
||||
MODULE_IFLAGS += -I$(SWLIBDIR)/drivers/targets/cmsis/rtl8195a/
|
||||
MODULE_IFLAGS += -I$(SWLIBDIR)/drivers/targets/hal/rtl8195a/
|
||||
|
||||
GLOBAL_CFLAGS += -DCONFIG_PLATFORM_8195A
|
||||
#*****************************************************************************#
|
||||
# Source FILE LIST #
|
||||
#*****************************************************************************#
|
||||
CSRC += main.c
|
||||
|
||||
|
||||
#*****************************************************************************#
|
||||
# Object FILE LIST #
|
||||
#*****************************************************************************#
|
||||
OBJS = $(CSRC:.c=.o)
|
||||
|
||||
|
||||
#*****************************************************************************#
|
||||
# Object FILE LIST #
|
||||
#*****************************************************************************#
|
||||
#OBJS = monitor.o rtl_consol.o
|
||||
|
||||
#*****************************************************************************#
|
||||
# RULES TO GENERATE TARGETS #
|
||||
#*****************************************************************************#
|
||||
|
||||
# Define the Rules to build the core targets
|
||||
all: CORE_TARGETS COPY_RAM_OBJS
|
||||
|
||||
#*****************************************************************************#
|
||||
# GENERATE OBJECT FILE
|
||||
#*****************************************************************************#
|
||||
CORE_TARGETS: $(OBJS)
|
||||
|
||||
|
||||
#*****************************************************************************#
|
||||
# GENERATE OBJECT FILE
|
||||
#*****************************************************************************#
|
||||
clean:
|
||||
rm -f $(CSRC:.c=.o) $(CSRC:.c=.d) $(CSRC:.c=.i) $(CSRC:.c=.s)
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2015 Realtek Semiconductor Corp.
|
||||
*
|
||||
* This module is a confidential and proprietary property of RealTek and
|
||||
* possession or use of this module requires written permission of RealTek.
|
||||
*/
|
||||
|
||||
#include "device.h"
|
||||
#include "gpio_api.h" // mbed
|
||||
#include "sleep_ex_api.h"
|
||||
#include "diag.h"
|
||||
#include "main.h"
|
||||
|
||||
#define GPIO_LED_PIN PA_0
|
||||
#define GPIO_PUSHBT_PIN PA_22
|
||||
#define GPIO_WAKE_PIN PA_5
|
||||
|
||||
void gpio_pull_control()
|
||||
{
|
||||
/* please use pmap_func to config sleep gpio pull control */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Main program.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void main(void)
|
||||
{
|
||||
gpio_t gpio_led, gpio_btn, gpio_wake;
|
||||
int old_btn_state, new_btn_state;
|
||||
|
||||
DBG_INFO_MSG_OFF(_DBG_GPIO_);
|
||||
|
||||
// Init LED control pin
|
||||
gpio_init(&gpio_led, GPIO_LED_PIN);
|
||||
gpio_dir(&gpio_led, PIN_OUTPUT); // Direction: Output
|
||||
gpio_mode(&gpio_led, PullNone); // No pull
|
||||
|
||||
// Initial Push Button pin
|
||||
gpio_init(&gpio_btn, GPIO_PUSHBT_PIN);
|
||||
gpio_dir(&gpio_btn, PIN_INPUT); // Direction: Input
|
||||
gpio_mode(&gpio_btn, PullUp);
|
||||
|
||||
// Initial Wake pin
|
||||
gpio_init(&gpio_wake, GPIO_WAKE_PIN);
|
||||
gpio_dir(&gpio_wake, PIN_INPUT); // Direction: Input
|
||||
gpio_mode(&gpio_wake, PullUp);
|
||||
|
||||
old_btn_state = new_btn_state = 0;
|
||||
gpio_write(&gpio_led, 1);
|
||||
|
||||
DiagPrintf("Push button to enter deepstandby...\r\n");
|
||||
while(1){
|
||||
new_btn_state = gpio_read(&gpio_btn);
|
||||
|
||||
if (old_btn_state == 1 && new_btn_state == 0) {
|
||||
gpio_write(&gpio_led, 0);
|
||||
|
||||
DiagPrintf("Sleep 8s... (Or wakeup by giving failing edge at PA_5)\r\n");
|
||||
//turn off log uart to avoid warning in gpio_pull_control()
|
||||
//sys_log_uart_off();
|
||||
// Please note that the pull control is different in different board
|
||||
// This example is a sample code for RTL Ameba Dev Board
|
||||
gpio_pull_control();
|
||||
standby_wakeup_event_add(STANDBY_WAKEUP_BY_STIMER, 0);
|
||||
standby_wakeup_event_add(STANDBY_WAKEUP_BY_GPIO, WAKEUP_BY_GPIO_WAKEUP1_LOW);
|
||||
deepstandby_ex(8000);
|
||||
|
||||
DiagPrintf("This line should not be printed\r\n");
|
||||
}
|
||||
old_btn_state = new_btn_state;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue