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,8 @@
|
|||
Example Description
|
||||
|
||||
This example describes how to use adc vabt channel to measure 5V vlotage.
|
||||
|
||||
Requirement Components:
|
||||
none
|
||||
|
||||
|
||||
|
|
@ -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,67 @@
|
|||
/*
|
||||
* Routines to access hardware
|
||||
*
|
||||
* Copyright (c) 2013 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 "analogin_api.h"
|
||||
#include <sys_api.h>
|
||||
|
||||
/*
|
||||
* OFFSET: value of measuring at 0.000v, value(0.000v)
|
||||
* GAIN_DIV: value(1.000v)-value(0.000v) or value(2.000v)-value(1.000v) or value(3.000v)-value(2.000v)
|
||||
*
|
||||
* MSB 12bit of value is valid, need to truncate LSB 4bit (0xABCD -> 0xABC). OFFSET and GAIN_DIV are truncated values.
|
||||
*/
|
||||
|
||||
/* Vbat channel */
|
||||
#define OFFSET 0x496
|
||||
#define GAIN_DIV 0xBA
|
||||
#define AD2MV(ad,offset,gain) (((ad >> 4) -offset) * 1000 / gain)
|
||||
|
||||
void adc_delay(void)
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<1600000;i++)
|
||||
asm(" nop");
|
||||
}
|
||||
|
||||
void adc_vbat_en(void)
|
||||
{
|
||||
uint16_t adc_read = 0;
|
||||
int32_t voltage;
|
||||
analogin_t adc_vbat;
|
||||
|
||||
analogin_init(&adc_vbat, AD_2);
|
||||
|
||||
DBG_8195A("ADC:offset = 0x%x, gain = 0x%x\n", OFFSET, GAIN_DIV);
|
||||
|
||||
for (;;){
|
||||
adc_read = analogin_read_u16(&adc_vbat);
|
||||
|
||||
voltage = AD2MV(adc_read, OFFSET, GAIN_DIV);
|
||||
|
||||
DBG_8195A("ADC_Vbat: 0x%x = %d mv\n", adc_read, voltage);
|
||||
adc_delay();
|
||||
}
|
||||
analogin_deinit(&adc_vbat);
|
||||
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
VOID main (VOID)
|
||||
{
|
||||
if(xTaskCreate( (TaskFunction_t)adc_vbat_en, "ADC VBAT DEMO", (2048/4), NULL, (tskIDLE_PRIORITY + 1), NULL)!= pdPASS) {
|
||||
DBG_8195A("Cannot create ADC Vbat demo task\n\r");
|
||||
}
|
||||
|
||||
vTaskStartScheduler();
|
||||
|
||||
while(1);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue