initial commit

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

View file

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

View file

@ -0,0 +1,13 @@
Example Description
This example describes how to use pwm
Requirement Components:
1~4 LED
Connect LED to below PWM pins and ground, then the LED would gradually become brighter and then darker with different speed.
- connect a LED to PA_23 and ground
- connect a LED to PA_22 and ground
- connect a LED to PA_0 and ground
- connect a LED to PA_12 and ground

View file

@ -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)

View file

@ -0,0 +1,106 @@
/*
* 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 "pwmout_api.h" // mbed
#include "main.h"
#define PWM_1 PA_23
#define PWM_2 PA_22
#define PWM_3 PA_0
#define PWM_4 PA_12
#define PWM_PERIOD 20000
#define USE_FLOAT 0
#define HIGH_FREQUENCY 0
#if USE_FLOAT
#if !HIGH_FREQUENCY
#define PWM_STEP (1.0/20.0)
float pwms[4]={0.0, 0.25, 0.5, 0.75};
float steps[4]={PWM_STEP, PWM_STEP, PWM_STEP, PWM_STEP};
#else
#define PWM_STEP (1.0/10000.0)
float pwms[4]={0.0, 0.25, 0.5, 0.75};
float steps[4]={PWM_STEP, PWM_STEP, PWM_STEP, PWM_STEP};
#undef PWM_PERIOD
#define PWM_PERIOD 500
#endif
#else
#define PWM_STEP (PWM_PERIOD/20)
int pwms[4]={0, PWM_PERIOD/4, PWM_PERIOD/2, PWM_PERIOD/4*3};
int steps[4]={PWM_STEP,PWM_STEP,PWM_STEP,PWM_STEP};
#endif
pwmout_t pwm_led[4];
PinName pwm_led_pin[4] = {PWM_1, PWM_2, PWM_3, PWM_4};
extern void RtlMsleepOS(u32 ms);
void pwm_delay(void)
{
int i;
for(i=0;i<1000000;i++)
asm(" nop");
}
/**
* @brief Main program.
* @param None
* @retval None
*/
//int main_app(IN u16 argc, IN u8 *argv[])
void main(void)
{
int i;
for (i=0; i<4; i++) {
pwmout_init(&pwm_led[i], pwm_led_pin[i]);
pwmout_period_us(&pwm_led[i], PWM_PERIOD);
}
while (1) {
#if USE_FLOAT
for (i=0; i<4; i++) {
pwmout_write(&pwm_led[i], pwms[i]);
pwms[i] += steps[i];
if (pwms[i] >= 1.0) {
steps[i] = -PWM_STEP;
pwms[i] = 1.0;
}
if (pwms[i] <= 0.0) {
steps[i] = PWM_STEP;
pwms[i] = 0.0;
}
}
#else
for (i=0; i<4; i++) {
pwmout_pulsewidth_us(&pwm_led[i], pwms[i]);
pwms[i] += steps[i];
if (pwms[i] >= PWM_PERIOD) {
steps[i] = -PWM_STEP;
pwms[i] = PWM_PERIOD;
}
if (pwms[i] <= 0) {
steps[i] = PWM_STEP;
pwms[i] = 0;
}
}
#endif
// wait_ms(20);
// RtlMsleepOS(25);
#if !HIGH_FREQUENCY
pwm_delay();
#endif
}
}