[X9D] ADC driver added. Unused files removed.
This commit is contained in:
+1
-1
@@ -494,7 +494,7 @@ ifeq ($(PCB), X9D)
|
||||
EEPROMSRC = eeprom_avr.cpp # TODO later eeprom_conversions.cpp
|
||||
PULSESSRC = pulses_arm.cpp
|
||||
CPPSRC += sky9x/audio.cpp
|
||||
CPPSRC += x9d/pwr_driver.cpp x9d/eeprom_driver.cpp x9d/pulses_driver.cpp x9d/keys_driver.cpp x9d/audio_driver.cpp x9d/delays.cpp
|
||||
CPPSRC += x9d/pwr_driver.cpp x9d/eeprom_driver.cpp x9d/pulses_driver.cpp x9d/keys_driver.cpp x9d/adc_driver.cpp x9d/audio_driver.cpp x9d/delays.cpp
|
||||
CPPSRC += bmp.cpp monitors_views.cpp
|
||||
SRC += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Source/Templates/system_stm32f2xx.c
|
||||
SRC += x9d/STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/src/stm32f2xx_gpio.c
|
||||
|
||||
@@ -629,6 +629,9 @@ void lcd_invert_line(int8_t y)
|
||||
uint8_t *p = &displayBuf[y * DISPLAY_W];
|
||||
for (xcoord_t x=0; x<DISPLAY_W; x++) {
|
||||
ASSERT_IN_DISPLAY(p);
|
||||
#if defined(PCBX9D)
|
||||
*(p+DISPLAY_PLAN_SIZE) ^= 0xff;
|
||||
#endif
|
||||
*p++ ^= 0xff;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-9
@@ -1563,21 +1563,16 @@ uint16_t anaIn(uint8_t chan)
|
||||
#if defined(CPUARM)
|
||||
void getADC()
|
||||
{
|
||||
register uint32_t x;
|
||||
register uint32_t y;
|
||||
uint16_t temp[NUMBER_ANALOG] = { 0 };
|
||||
|
||||
for( y = 0; y < 4; y += 1 ) {
|
||||
// TODO change this function!
|
||||
read_9_adc();
|
||||
for( x = 0; x < NUMBER_ANALOG; x += 1 )
|
||||
{
|
||||
for (uint32_t i=0; i<4; i++) {
|
||||
adcRead();
|
||||
for (uint32_t x=0; x<NUMBER_ANALOG; x++) {
|
||||
temp[x] += Analog_values[x];
|
||||
}
|
||||
}
|
||||
|
||||
for( x = 0; x < NUMBER_ANALOG; x += 1 )
|
||||
{
|
||||
for (uint32_t x=0; x<NUMBER_ANALOG; x++) {
|
||||
s_anaFilt[x] = temp[x] >> 3;
|
||||
}
|
||||
}
|
||||
|
||||
+19
-3
@@ -935,11 +935,27 @@ void getADC();
|
||||
|
||||
extern void backlightOn();
|
||||
|
||||
#if defined(PCBSKY9X) && !defined(REVA)
|
||||
#define NUMBER_ANALOG 9
|
||||
enum Analogs {
|
||||
STICK1,
|
||||
STICK2,
|
||||
STICK3,
|
||||
STICK4,
|
||||
#if defined(PCBX9D)
|
||||
POT1,
|
||||
POT2,
|
||||
SLIDER1,
|
||||
SLIDER2,
|
||||
#else
|
||||
#define NUMBER_ANALOG 8
|
||||
POT1,
|
||||
POT2,
|
||||
POT3,
|
||||
#endif
|
||||
TX_VOLTAGE,
|
||||
#if defined(PCBSKY9X) && !defined(REVA)
|
||||
TX_CURRENT,
|
||||
#endif
|
||||
NUMBER_ANALOG
|
||||
};
|
||||
|
||||
#if defined(PCBSTD) && defined(VOICE) && !defined(SIMU)
|
||||
#define BACKLIGHT_ON() (Voice.Backlight = 1)
|
||||
|
||||
@@ -707,7 +707,7 @@ uint8_t maxTemperature = 0 ; // Raw temp reading
|
||||
|
||||
// Read 8 (9 for REVB) ADC channels
|
||||
// Documented bug, must do them 1 by 1
|
||||
void read_9_adc()
|
||||
void adcRead()
|
||||
{
|
||||
register Adc *padc;
|
||||
register uint32_t y;
|
||||
|
||||
@@ -128,6 +128,6 @@ uint32_t check_soft_power();
|
||||
#define __BACKLIGHT_OFF (PWM->PWM_CH_NUM[0].PWM_CDTY = 100)
|
||||
#define IS_BACKLIGHT_ON() (PWM->PWM_CH_NUM[0].PWM_CDTY != 100)
|
||||
|
||||
void read_9_adc(void);
|
||||
void adcRead(void);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
/*
|
||||
* Authors (alphabetical order)
|
||||
* - Bertrand Songis <bsongis@gmail.com>
|
||||
* - Bryan J. Rentoul (Gruvin) <gruvin@gmail.com>
|
||||
* - Cameron Weeks <th9xer@gmail.com>
|
||||
* - Erez Raviv
|
||||
* - Jean-Pierre Parisy
|
||||
* - Karl Szmutny <shadow@privy.de>
|
||||
* - Michael Blandford
|
||||
* - Michal Hlavinka
|
||||
* - Pat Mackenzie
|
||||
* - Philip Moss
|
||||
* - Rob Thomson
|
||||
* - Romolo Manfredini <romolo.manfredini@gmail.com>
|
||||
* - Thomas Husterer
|
||||
*
|
||||
* open9x is based on code named
|
||||
* gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/,
|
||||
* er9x by Erez Raviv: http://code.google.com/p/er9x/,
|
||||
* and the original (and ongoing) project by
|
||||
* Thomas Husterer, th9x: http://code.google.com/p/th9x/
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../open9x.h"
|
||||
|
||||
#define PIN_ANALOG 0x0003
|
||||
#define PIN_PORTA 0x0000
|
||||
#define PIN_PORTC 0x0200
|
||||
|
||||
#define STICK_LV 3
|
||||
#define STICK_LH 2
|
||||
#define STICK_RV 0
|
||||
#define STICK_RH 1
|
||||
#define POT_L 6
|
||||
#define POT_R 7
|
||||
#define SLIDE_L 14
|
||||
#define SLIDE_R 15
|
||||
#define BATTERY 10
|
||||
|
||||
// Sample time should exceed 1uS
|
||||
#define SAMPTIME 2 // sample time = 15 cycles
|
||||
|
||||
volatile uint16_t Analog_values[NUMBER_ANALOG];
|
||||
|
||||
void adcInit()
|
||||
{
|
||||
RCC->APB2ENR |= RCC_APB2ENR_ADC1EN ; // Enable clock
|
||||
RCC->AHB1ENR |= RCC_AHB1Periph_GPIOADC ; // Enable ports A&C clocks
|
||||
RCC->AHB1ENR |= RCC_AHB1ENR_DMA2EN ; // Enable DMA2 clock
|
||||
configure_pins( PIN_STK_J1 | PIN_STK_J2 | PIN_STK_J3 | PIN_STK_J4 |
|
||||
PIN_FLP_J1 | PIN_FLP_J2, PIN_ANALOG | PIN_PORTA ) ;
|
||||
configure_pins( PIN_SLD_J1 | PIN_SLD_J2 | PIN_MVOLT, PIN_ANALOG | PIN_PORTC ) ;
|
||||
|
||||
ADC1->CR1 = ADC_CR1_SCAN ;
|
||||
ADC1->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS ;
|
||||
ADC1->SQR1 = (NUMBER_ANALOG-1) << 20 ; // NUMBER_ANALOG Channels
|
||||
ADC1->SQR2 = SLIDE_L + (SLIDE_R<<5) + (BATTERY<<10) ;
|
||||
ADC1->SQR3 = STICK_LH + (STICK_LV<<5) + (STICK_RV<<10) + (STICK_RH<<15) + (POT_L<<20) + (POT_R<<25) ;
|
||||
ADC1->SMPR1 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12)
|
||||
+ (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24) ;
|
||||
ADC1->SMPR2 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12)
|
||||
+ (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24) + (SAMPTIME<<27) ;
|
||||
|
||||
ADC->CCR = 0 ; //ADC_CCR_ADCPRE_0 ; // Clock div 2
|
||||
|
||||
DMA2_Stream0->CR = DMA_SxCR_PL | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC ;
|
||||
DMA2_Stream0->PAR = (uint32_t) &ADC1->DR ;
|
||||
DMA2_Stream0->M0AR = (uint32_t)Analog_values;
|
||||
DMA2_Stream0->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0 ;
|
||||
}
|
||||
|
||||
void adcRead()
|
||||
{
|
||||
uint32_t i ;
|
||||
|
||||
DMA2_Stream0->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
ADC1->SR &= ~(uint32_t) ( ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR ) ;
|
||||
DMA2->LIFCR = DMA_LIFCR_CTCIF0 | DMA_LIFCR_CHTIF0 |DMA_LIFCR_CTEIF0 | DMA_LIFCR_CDMEIF0 | DMA_LIFCR_CFEIF0 ; // Write ones to clear bits
|
||||
DMA2_Stream0->M0AR = (uint32_t)Analog_values ;
|
||||
DMA2_Stream0->NDTR = NUMBER_ANALOG ;
|
||||
DMA2_Stream0->CR |= DMA_SxCR_EN ; // Enable DMA
|
||||
ADC1->CR2 |= (uint32_t)ADC_CR2_SWSTART ;
|
||||
for ( i = 0 ; i < 10000 ; i += 1 ) {
|
||||
if ( DMA2->LISR & DMA_LISR_TCIF0 ) {
|
||||
break ;
|
||||
}
|
||||
}
|
||||
DMA2_Stream0->CR &= ~DMA_SxCR_EN ; // Disable DMA
|
||||
// return ( i < 10000 ) ? 1 : 0 ;
|
||||
}
|
||||
|
||||
// TODO
|
||||
void adcStop()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+63
-11
@@ -33,7 +33,7 @@
|
||||
|
||||
#include "../open9x.h"
|
||||
|
||||
uint16_t Analog_values[NUMBER_ANALOG] ;
|
||||
// TODO needed?
|
||||
uint8_t temperature = 0; // Raw temp reading
|
||||
uint8_t maxTemperature = 0 ; // Raw temp reading
|
||||
volatile uint32_t Tenms ; // TODO to remove everywhere / use a #define
|
||||
@@ -43,21 +43,71 @@ uint32_t Master_frequency ;
|
||||
extern uint32_t Peri1_frequency ;
|
||||
extern uint32_t Peri2_frequency ;
|
||||
|
||||
void keysInit();
|
||||
void pwrInit();
|
||||
void eepromInit(); // TODO check it's not in another include
|
||||
void delaysInit();
|
||||
#define PIN_MODE_MASK 0x0003
|
||||
#define PIN_INPUT 0x0000
|
||||
#define PIN_OUTPUT 0x0001
|
||||
#define PIN_PERIPHERAL 0x0002
|
||||
#define PIN_ANALOG 0x0003
|
||||
#define PIN_PULL_MASK 0x000C
|
||||
#define PIN_PULLUP 0x0004
|
||||
#define PIN_NO_PULLUP 0x0000
|
||||
#define PIN_PULLDOWN 0x0008
|
||||
#define PIN_NO_PULLDOWN 0x0000
|
||||
#define PIN_PERI_MASK 0x00F0
|
||||
#define PIN_PUSHPULL 0x0000
|
||||
#define PIN_ODRAIN 0x8000
|
||||
#define PIN_PORT_MASK 0x0700
|
||||
#define PIN_SPEED_MASK 0x6000
|
||||
|
||||
void configure_pins( uint32_t pins, uint16_t config )
|
||||
{
|
||||
uint32_t address ;
|
||||
GPIO_TypeDef *pgpio ;
|
||||
uint32_t thispin ;
|
||||
uint32_t pos ;
|
||||
|
||||
address = ( config & PIN_PORT_MASK ) >> 8 ;
|
||||
address *= (GPIOB_BASE-GPIOA_BASE) ;
|
||||
address += GPIOA_BASE ;
|
||||
pgpio = (GPIO_TypeDef* ) address ;
|
||||
|
||||
/* -------------------------Configure the port pins---------------- */
|
||||
/*-- GPIO Mode Configuration --*/
|
||||
for (thispin = 0x0001, pos = 0; thispin < 0x10000; thispin <<= 1, pos +=1 )
|
||||
{
|
||||
if ( pins & thispin)
|
||||
{
|
||||
pgpio->MODER &= ~(GPIO_MODER_MODER0 << (pos * 2)) ;
|
||||
pgpio->MODER |= (config & PIN_MODE_MASK) << (pos * 2) ;
|
||||
|
||||
if ( ( (config & PIN_MODE_MASK ) == PIN_OUTPUT) || ( (config & PIN_MODE_MASK) == PIN_PERIPHERAL) )
|
||||
{
|
||||
/* Speed mode configuration */
|
||||
pgpio->OSPEEDR &= ~GPIO_OSPEEDER_OSPEEDR0 << (pos * 2) ;
|
||||
pgpio->OSPEEDR |= ((config & PIN_SPEED_MASK) >> 13 ) << (pos * 2) ;
|
||||
|
||||
/* Output mode configuration*/
|
||||
pgpio->OTYPER &= ~((GPIO_OTYPER_OT_0) << ((uint16_t)pos)) ;
|
||||
if ( config & PIN_ODRAIN )
|
||||
{
|
||||
pgpio->OTYPER |= (GPIO_OTYPER_OT_0) << pos ;
|
||||
}
|
||||
}
|
||||
/* Pull-up Pull down resistor configuration*/
|
||||
pgpio->PUPDR &= ~(GPIO_PUPDR_PUPDR0 << ((uint16_t)pos * 2));
|
||||
pgpio->PUPDR |= ((config & PIN_PULL_MASK) >> 2) << (pos * 2) ;
|
||||
|
||||
pgpio->AFR[pos >> 3] &= ~(0x000F << (pos & 7)) ;
|
||||
pgpio->AFR[pos >> 3] |= ((config & PIN_PERI_MASK) >> 4) << (pos & 7) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t getTemperature()
|
||||
{
|
||||
return temperature + g_eeGeneral.temperatureCalib;
|
||||
}
|
||||
|
||||
// TODO change this function!
|
||||
void read_9_adc()
|
||||
{
|
||||
}
|
||||
|
||||
void start_ppm_capture()
|
||||
{
|
||||
}
|
||||
@@ -121,12 +171,14 @@ void boardInit()
|
||||
{
|
||||
pwrInit();
|
||||
keysInit();
|
||||
adcInit();
|
||||
delaysInit();
|
||||
|
||||
init5msTimer();
|
||||
|
||||
__enable_irq() ;
|
||||
|
||||
eepromInit();
|
||||
delaysInit();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -118,4 +118,15 @@ uint32_t check_soft_power();
|
||||
void eeWriteBlockCmp(const void *pointer_ram, uint16_t pointer_eeprom, size_t size);
|
||||
#endif
|
||||
|
||||
void keysInit();
|
||||
void pwrInit();
|
||||
void eepromInit(); // TODO check it's not in another include
|
||||
void delaysInit();
|
||||
void adcInit();
|
||||
void adcRead();
|
||||
|
||||
extern volatile uint16_t Analog_values[];
|
||||
|
||||
void configure_pins( uint32_t pins, uint16_t config );
|
||||
|
||||
#endif
|
||||
|
||||
+9
-8
@@ -33,9 +33,9 @@
|
||||
|
||||
#include "../open9x.h"
|
||||
|
||||
void delaysInit(void) {
|
||||
|
||||
// Timer13
|
||||
void delaysInit(void)
|
||||
{
|
||||
// Timer13
|
||||
RCC->APB1ENR |= RCC_APB1ENR_TIM13EN; // Enable clock
|
||||
TIM13->PSC = Peri1_frequency / 100000; // 0.1uS from 30MHz
|
||||
TIM13->CCER = 0;
|
||||
@@ -46,9 +46,10 @@ void delaysInit(void) {
|
||||
}
|
||||
|
||||
|
||||
void delay_01us(uint16_t nb){
|
||||
TIM13->CNT = 0;
|
||||
TIM13->EGR = 1;
|
||||
while(((uint16_t)TIM13->CNT) < nb);
|
||||
TIM13->EGR = 0;
|
||||
void delay_01us(uint16_t nb)
|
||||
{
|
||||
TIM13->CNT = 0;
|
||||
TIM13->EGR = 1;
|
||||
while(((uint16_t)TIM13->CNT) < nb);
|
||||
TIM13->EGR = 0;
|
||||
}
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/main.c
|
||||
* @author X9D Application Team
|
||||
* @Hardware version V0.2
|
||||
* @date 11-July-2012
|
||||
* @brief This file provides the main fuction.
|
||||
* *
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "stm32f2xx.h"
|
||||
#include "intrinsics.h"
|
||||
#include "stdint.h"
|
||||
#include "stdio.h"
|
||||
#include "SYS_NVIC.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
|
||||
#include "lcd.h"
|
||||
#include "gui_tsk.h"
|
||||
#include "item.h"
|
||||
#include "Audio.h"
|
||||
#include "sys_man.h"
|
||||
#include "Macro_define.h"
|
||||
|
||||
#ifdef I2C_TEST
|
||||
#include "i2c_ee.h"
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef ADC_TEST
|
||||
#include "adc.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
|
||||
Delay(10000); //delay 200+ ms
|
||||
#ifdef DEBUG
|
||||
debug();
|
||||
#endif
|
||||
__disable_interrupt();
|
||||
|
||||
/*HCLK=120M,SYSCLK=120M,PCLK1=30M,PCLK2=60M,SO APB1=60M(div=4),APB2=120M(div=2)*/
|
||||
|
||||
RCC_ClocksTypeDef RCC_Clocks;
|
||||
RCC_GetClocksFreq(&RCC_Clocks);//add to watch to see the values
|
||||
|
||||
//clock init ok ,other peripherals init code;
|
||||
|
||||
__enable_interrupt();
|
||||
|
||||
while(1)
|
||||
{
|
||||
}
|
||||
//return 0;
|
||||
}
|
||||
|
||||
@@ -1,257 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/STM32F2xx_StdPeriph_Template/stm32f2xx_it.c
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 13-April-2012
|
||||
* @brief Main Interrupt Service Routines.
|
||||
* This file provides template for all exceptions handler and
|
||||
* peripherals interrupt service routine.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f2xx_it.h"
|
||||
#include "Macro_define.h"
|
||||
|
||||
/** @addtogroup Template_Project
|
||||
* @{
|
||||
*/
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
|
||||
/******************************************************************************/
|
||||
/* Cortex-M3 Processor Exceptions Handlers */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles NMI exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void NMI_Handler(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Hard Fault exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void HardFault_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Hard Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Memory Manage exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void MemManage_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Memory Manage exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Bus Fault exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void BusFault_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Bus Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles Usage Fault exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void UsageFault_Handler(void)
|
||||
{
|
||||
/* Go to infinite loop when Usage Fault exception occurs */
|
||||
while (1)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles SVCall exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
//void SVC_Handler(void)
|
||||
//{
|
||||
//}
|
||||
|
||||
/**
|
||||
* @brief This function handles Debug Monitor exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
void DebugMon_Handler(void)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles PendSVC exception.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
//void PendSV_Handler(void)
|
||||
//{
|
||||
//}
|
||||
|
||||
/**
|
||||
* @brief This function handles SysTick Handler.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
//void SysTick_Handler(void)
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
/******************************************************************************/
|
||||
/* STM32F2xx Peripherals Interrupt Handlers */
|
||||
/* Add here the Interrupt Handler for the used peripheral(s) (PPP), for the */
|
||||
/* available peripheral interrupt handler's name please refer to the startup */
|
||||
/* file (startup_stm32f2xx.s). */
|
||||
/******************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief This function handles PPP interrupt request.
|
||||
* @param None
|
||||
* @retval None
|
||||
*/
|
||||
/*void PPP_IRQHandler(void)
|
||||
{
|
||||
}*/
|
||||
|
||||
#ifdef AUDIO_TEST
|
||||
#include "Audio.h"
|
||||
void SPI3_IRQHandler(void)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
//all the available peripheral interrupt handler's name are followed
|
||||
/*
|
||||
; External Interrupts
|
||||
DCD WWDG_IRQHandler ; Window WatchDog
|
||||
DCD PVD_IRQHandler ; PVD through EXTI Line detection
|
||||
DCD TAMP_STAMP_IRQHandler ; Tamper and TimeStamps through the EXTI line
|
||||
DCD RTC_WKUP_IRQHandler ; RTC Wakeup through the EXTI line
|
||||
DCD FLASH_IRQHandler ; FLASH
|
||||
DCD RCC_IRQHandler ; RCC
|
||||
DCD EXTI0_IRQHandler ; EXTI Line0
|
||||
DCD EXTI1_IRQHandler ; EXTI Line1
|
||||
DCD EXTI2_IRQHandler ; EXTI Line2
|
||||
DCD EXTI3_IRQHandler ; EXTI Line3
|
||||
DCD EXTI4_IRQHandler ; EXTI Line4
|
||||
DCD DMA1_Stream0_IRQHandler ; DMA1 Stream 0
|
||||
DCD DMA1_Stream1_IRQHandler ; DMA1 Stream 1
|
||||
DCD DMA1_Stream2_IRQHandler ; DMA1 Stream 2
|
||||
DCD DMA1_Stream3_IRQHandler ; DMA1 Stream 3
|
||||
DCD DMA1_Stream4_IRQHandler ; DMA1 Stream 4
|
||||
DCD DMA1_Stream5_IRQHandler ; DMA1 Stream 5
|
||||
DCD DMA1_Stream6_IRQHandler ; DMA1 Stream 6
|
||||
DCD ADC_IRQHandler ; ADC1, ADC2 and ADC3s
|
||||
DCD CAN1_TX_IRQHandler ; CAN1 TX
|
||||
DCD CAN1_RX0_IRQHandler ; CAN1 RX0
|
||||
DCD CAN1_RX1_IRQHandler ; CAN1 RX1
|
||||
DCD CAN1_SCE_IRQHandler ; CAN1 SCE
|
||||
DCD EXTI9_5_IRQHandler ; External Line[9:5]s
|
||||
DCD TIM1_BRK_TIM9_IRQHandler ; TIM1 Break and TIM9
|
||||
DCD TIM1_UP_TIM10_IRQHandler ; TIM1 Update and TIM10
|
||||
DCD TIM1_TRG_COM_TIM11_IRQHandler ; TIM1 Trigger and Commutation and TIM11
|
||||
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare
|
||||
DCD TIM2_IRQHandler ; TIM2
|
||||
DCD TIM3_IRQHandler ; TIM3
|
||||
DCD TIM4_IRQHandler ; TIM4
|
||||
DCD I2C1_EV_IRQHandler ; I2C1 Event
|
||||
DCD I2C1_ER_IRQHandler ; I2C1 Error
|
||||
DCD I2C2_EV_IRQHandler ; I2C2 Event
|
||||
DCD I2C2_ER_IRQHandler ; I2C2 Error
|
||||
DCD SPI1_IRQHandler ; SPI1
|
||||
DCD SPI2_IRQHandler ; SPI2
|
||||
DCD USART1_IRQHandler ; USART1
|
||||
DCD USART2_IRQHandler ; USART2
|
||||
DCD USART3_IRQHandler ; USART3
|
||||
DCD EXTI15_10_IRQHandler ; External Line[15:10]s
|
||||
DCD RTC_Alarm_IRQHandler ; RTC Alarm (A and B) through EXTI Line
|
||||
DCD OTG_FS_WKUP_IRQHandler ; USB OTG FS Wakeup through EXTI line
|
||||
DCD TIM8_BRK_TIM12_IRQHandler ; TIM8 Break and TIM12
|
||||
DCD TIM8_UP_TIM13_IRQHandler ; TIM8 Update and TIM13
|
||||
DCD TIM8_TRG_COM_TIM14_IRQHandler ; TIM8 Trigger and Commutation and TIM14
|
||||
DCD TIM8_CC_IRQHandler ; TIM8 Capture Compare
|
||||
DCD DMA1_Stream7_IRQHandler ; DMA1 Stream7
|
||||
DCD FSMC_IRQHandler ; FSMC
|
||||
DCD SDIO_IRQHandler ; SDIO
|
||||
DCD TIM5_IRQHandler ; TIM5
|
||||
DCD SPI3_IRQHandler ; SPI3
|
||||
DCD UART4_IRQHandler ; UART4
|
||||
DCD UART5_IRQHandler ; UART5
|
||||
DCD TIM6_DAC_IRQHandler ; TIM6 and DAC1&2 underrun errors
|
||||
DCD TIM7_IRQHandler ; TIM7
|
||||
DCD DMA2_Stream0_IRQHandler ; DMA2 Stream 0
|
||||
DCD DMA2_Stream1_IRQHandler ; DMA2 Stream 1
|
||||
DCD DMA2_Stream2_IRQHandler ; DMA2 Stream 2
|
||||
DCD DMA2_Stream3_IRQHandler ; DMA2 Stream 3
|
||||
DCD DMA2_Stream4_IRQHandler ; DMA2 Stream 4
|
||||
DCD ETH_IRQHandler ; Ethernet
|
||||
DCD ETH_WKUP_IRQHandler ; Ethernet Wakeup through EXTI line
|
||||
DCD CAN2_TX_IRQHandler ; CAN2 TX
|
||||
DCD CAN2_RX0_IRQHandler ; CAN2 RX0
|
||||
DCD CAN2_RX1_IRQHandler ; CAN2 RX1
|
||||
DCD CAN2_SCE_IRQHandler ; CAN2 SCE
|
||||
DCD OTG_FS_IRQHandler ; USB OTG FS
|
||||
DCD DMA2_Stream5_IRQHandler ; DMA2 Stream 5
|
||||
DCD DMA2_Stream6_IRQHandler ; DMA2 Stream 6
|
||||
DCD DMA2_Stream7_IRQHandler ; DMA2 Stream 7
|
||||
DCD USART6_IRQHandler ; USART6
|
||||
DCD I2C3_EV_IRQHandler ; I2C3 event
|
||||
DCD I2C3_ER_IRQHandler ; I2C3 error
|
||||
DCD OTG_HS_EP1_OUT_IRQHandler ; USB OTG HS End Point 1 Out
|
||||
DCD OTG_HS_EP1_IN_IRQHandler ; USB OTG HS End Point 1 In
|
||||
DCD OTG_HS_WKUP_IRQHandler ; USB OTG HS Wakeup through EXTI
|
||||
DCD OTG_HS_IRQHandler ; USB OTG HS
|
||||
DCD DCMI_IRQHandler ; DCMI
|
||||
DCD CRYP_IRQHandler ; CRYP crypto
|
||||
DCD HASH_RNG_IRQHandler ; Hash and Rng
|
||||
*/
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -1,60 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file Project/STM32F2xx_StdPeriph_Template/stm32f2xx_it.h
|
||||
* @author MCD Application Team
|
||||
* @version V1.1.0
|
||||
* @date 13-April-2012
|
||||
* @brief This file contains the headers of the interrupt handlers.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
|
||||
*
|
||||
* Licensed under MCD-ST Liberty SW License Agreement V2, (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.st.com/software_license_agreement_liberty_v2
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __STM32F2xx_IT_H
|
||||
#define __STM32F2xx_IT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32f2xx.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
void NMI_Handler(void);
|
||||
void HardFault_Handler(void);
|
||||
void MemManage_Handler(void);
|
||||
void BusFault_Handler(void);
|
||||
void UsageFault_Handler(void);
|
||||
void SVC_Handler(void);
|
||||
void DebugMon_Handler(void);
|
||||
void PendSV_Handler(void);
|
||||
void SysTick_Handler(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __STM32F2xx_IT_H */
|
||||
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
@@ -1,227 +0,0 @@
|
||||
#include "stm32f2xx.h"
|
||||
#include "timer_init.h"
|
||||
#include "hal.h"
|
||||
#include "msg_que.h"
|
||||
//Hardware Init Of Timer
|
||||
|
||||
//TIM10_CH1 LCD backlight
|
||||
//PWM OUTPUT MODE 500HZ,400HZ闪动。修改TIM10-> CCR1(1-4000)改变占空比,正比。
|
||||
void TIM10_CH1_BL_Init()
|
||||
{
|
||||
uint16_t PrescalerValue = 0;
|
||||
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
TIM_OCInitTypeDef TIM_OCInitStructure;
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
/* TIM10 clock enable ,GPIOBL clock enable */
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM10, ENABLE);
|
||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOBL, ENABLE);
|
||||
|
||||
/* GPIOC Configuration: TIM10_CH1 (PB.08)*/
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_BL;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
|
||||
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
|
||||
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP ;
|
||||
GPIO_Init(GPIOBL, &GPIO_InitStructure);
|
||||
/* Connect TIM10 pins to AF3 */
|
||||
GPIO_PinAFConfig(GPIOBL, GPIO_PinSource_BL, GPIO_AF_TIM10);
|
||||
|
||||
/*
|
||||
APB2 = 120M,分频系数6,TIM10计数频率2M。TIM10频率为2M/4000=500HZ.
|
||||
so the TIM10 Channel 1 generates a PWM signal with a frequency equal to
|
||||
500Hz and a duty cycle = (TIM10_CCR1/ TIM10_ARR + 1)* 100 = 50%
|
||||
*/
|
||||
|
||||
/* Compute the prescaler value */
|
||||
PrescalerValue = (uint16_t) ((SystemCoreClock ) / 2000000) - 1;
|
||||
/* Time base configuration */
|
||||
TIM_TimeBaseStructure.TIM_Period = 3999; //ARR=19999
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||
|
||||
TIM_TimeBaseInit(TIM10, &TIM_TimeBaseStructure);
|
||||
|
||||
/* PWM1 Mode configuration: Channel1 */
|
||||
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
|
||||
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
|
||||
TIM_OCInitStructure.TIM_Pulse =2000; //TIM10-> CCR1
|
||||
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
|
||||
|
||||
TIM_OC1Init(TIM10, &TIM_OCInitStructure);
|
||||
TIM_OC1PreloadConfig(TIM10, TIM_OCPreload_Enable);
|
||||
|
||||
/* TIM10 enable counter */
|
||||
TIM_Cmd(TIM10, ENABLE);
|
||||
}
|
||||
|
||||
void TIM10_CH1_BL_Adjust(char mode)
|
||||
{
|
||||
switch(mode)
|
||||
{
|
||||
case BKL_DEC:
|
||||
TIM10->CCR1 += 250;
|
||||
if(TIM10->CCR1>4000)
|
||||
TIM10->CCR1 = 4000;
|
||||
break;
|
||||
case BKL_INC:
|
||||
if(TIM10->CCR1 < 250)
|
||||
TIM10->CCR1 = 0;
|
||||
else
|
||||
TIM10->CCR1 -= 250;
|
||||
break;
|
||||
case BKL_OFF: TIM_Cmd(TIM10, DISABLE);break;
|
||||
case BKL_ON: TIM_Cmd(TIM10, ENABLE);break;
|
||||
|
||||
default:break;
|
||||
}
|
||||
}
|
||||
|
||||
//TIM1_CH1:CPPM_OUTPUT
|
||||
void TIM1_CH1_CPPM_Init()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
static struct TimerStruct timer_struct[MAX_TIMER];
|
||||
char led_lights;
|
||||
|
||||
/*******************************************
|
||||
初始化应用层定时器
|
||||
*******************************************/
|
||||
static void initTimerStruct(void)
|
||||
{
|
||||
char i;
|
||||
for(i=0;i<MAX_TIMER;i++)
|
||||
{
|
||||
timer_struct[i].valid=0;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* timer hardware init
|
||||
*****************************************/
|
||||
void initTimer(void)
|
||||
{
|
||||
initTimerStruct();
|
||||
}
|
||||
/********************************************
|
||||
定时器 tick 处理
|
||||
********************************************/
|
||||
void timer_tick(void)
|
||||
{
|
||||
{
|
||||
short i;
|
||||
struct TimerStruct *p=timer_struct;
|
||||
|
||||
for(i=0;i<MAX_TIMER;i++)
|
||||
{
|
||||
if(p->valid){
|
||||
p->expires--;
|
||||
if(p->expires==0)
|
||||
{
|
||||
p->valid=0;
|
||||
//raiseEvent(p->event);
|
||||
postMessage(p->pMsg->hWnd, p->pMsg->iMsg, p->pMsg->wParam, p->pMsg->lParam);
|
||||
}
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************
|
||||
* 设置定时器
|
||||
****************************************/
|
||||
void setTimer(char timerID,char expires,PMSG pMsg)
|
||||
{
|
||||
struct TimerStruct *p=&timer_struct[timerID];
|
||||
p->expires=expires;
|
||||
p->pMsg =pMsg;
|
||||
p->valid=1;
|
||||
}
|
||||
/****************************************
|
||||
* 取消定时器
|
||||
****************************************/
|
||||
void cancelTimer(char timerID)
|
||||
{
|
||||
timer_struct[timerID].valid=0;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
*****************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
static struct TimerStruct timer_struct[MAX_TIMER];
|
||||
|
||||
/*******************************************
|
||||
初始化应用层定时器
|
||||
*******************************************/
|
||||
static void initTimerStruct(void)
|
||||
{
|
||||
char i;
|
||||
for(i=0;i<MAX_TIMER;i++)
|
||||
{
|
||||
timer_struct[i].valid=0;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* timer hardware init
|
||||
*****************************************/
|
||||
void initTimer(void)
|
||||
{
|
||||
initTimerStruct();
|
||||
}
|
||||
/********************************************
|
||||
定时器 tick 处理
|
||||
********************************************/
|
||||
void timer_tick(void)
|
||||
{
|
||||
{
|
||||
short i;
|
||||
struct TimerStruct *p=timer_struct;
|
||||
|
||||
for(i=0;i<MAX_TIMER;i++)
|
||||
{
|
||||
if(p->valid){
|
||||
p->expires--;
|
||||
if(p->expires==0)
|
||||
{
|
||||
p->valid=0;
|
||||
//raiseEvent(p->event);
|
||||
postMessage(p->pMsg->hWnd, p->pMsg->iMsg, p->pMsg->wParam, p->pMsg->lParam);
|
||||
}
|
||||
}
|
||||
p++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************
|
||||
* 设置定时器
|
||||
****************************************/
|
||||
void setTimer(char timerID,char expires,PMSG pMsg)
|
||||
{
|
||||
struct TimerStruct *p=&timer_struct[timerID];
|
||||
p->expires=expires;
|
||||
p->pMsg =pMsg;
|
||||
p->valid=1;
|
||||
}
|
||||
/****************************************
|
||||
* 取消定时器
|
||||
****************************************/
|
||||
void cancelTimer(char timerID)
|
||||
{
|
||||
timer_struct[timerID].valid=0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
****************************************************************************/
|
||||
@@ -1,34 +0,0 @@
|
||||
#ifndef _TIMER_INIT_H_
|
||||
#define _TIMER_INIT_H_
|
||||
|
||||
#include "frgui.h"
|
||||
|
||||
#define MAX_TIMER (5) //×î´óµÄtimerID
|
||||
|
||||
#define TIMER_1 (0)
|
||||
#define TIMER_2 (1)
|
||||
#define TIMER_3 (2)
|
||||
#define TIMER_4 (3)
|
||||
#define TIMER_5 (4)
|
||||
|
||||
struct TimerStruct
|
||||
{
|
||||
char valid;
|
||||
char expires;
|
||||
PMSG pMsg;
|
||||
};
|
||||
|
||||
void initTimer(void);
|
||||
void setTimer(char timerID,char expires,PMSG pMsg);
|
||||
void cancelTimer(char timerID);
|
||||
void timer_interrupt(void);
|
||||
void timer_tick(void);
|
||||
void TIM10_CH1_BL_Init();
|
||||
|
||||
#define BKL_DEC (0)
|
||||
#define BKL_INC (1)
|
||||
#define BKL_OFF (2)
|
||||
#define BKL_ON (3)
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user