mirror of https://github.com/g4klx/MMDVM.git
Adding Pi board support
This commit is contained in:
parent
e6e887e4af
commit
004205192c
12
Config.h
12
Config.h
|
@ -39,24 +39,30 @@
|
||||||
// #define USE_COS_AS_LOCKOUT
|
// #define USE_COS_AS_LOCKOUT
|
||||||
|
|
||||||
// Use pins to output the current mode
|
// Use pins to output the current mode
|
||||||
// #define ARDUINO_MODE_PINS
|
#define ARDUINO_MODE_PINS
|
||||||
|
|
||||||
// For the original Arduino Due pin layout
|
// For the original Arduino Due pin layout
|
||||||
// #define ARDUINO_DUE_PAPA
|
// #define ARDUINO_DUE_PAPA
|
||||||
|
|
||||||
// For the ZUM V1.0 and V1.0.1 boards pin layout
|
// For the ZUM V1.0 and V1.0.1 boards pin layout
|
||||||
#define ARDUINO_DUE_ZUM_V10
|
// #define ARDUINO_DUE_ZUM_V10
|
||||||
|
|
||||||
// For the SP8NTH board
|
// For the SP8NTH board
|
||||||
// #define ARDUINO_DUE_NTH
|
// #define ARDUINO_DUE_NTH
|
||||||
|
|
||||||
|
// For the STM32F4 Discovery Board
|
||||||
|
#define STM32F4_DISCOVERY
|
||||||
|
|
||||||
|
// For the STM32F4 Pi Board
|
||||||
|
// #define STM32F4_PI
|
||||||
|
|
||||||
// To use wider C4FSK filters for DMR, System Fusion and P25 on transmit
|
// To use wider C4FSK filters for DMR, System Fusion and P25 on transmit
|
||||||
// #define WIDE_C4FSK_FILTERS_TX
|
// #define WIDE_C4FSK_FILTERS_TX
|
||||||
// To use wider C4FSK filters for DMR, System Fusion and P25 on receive
|
// To use wider C4FSK filters for DMR, System Fusion and P25 on receive
|
||||||
// #define WIDE_C4FSK_FILTERS_RX
|
// #define WIDE_C4FSK_FILTERS_RX
|
||||||
|
|
||||||
// Pass RSSI information to the host
|
// Pass RSSI information to the host
|
||||||
// #define SEND_RSSI_DATA
|
#define SEND_RSSI_DATA
|
||||||
|
|
||||||
// Use the modem as a serial repeater for Nextion displays
|
// Use the modem as a serial repeater for Nextion displays
|
||||||
// #define SERIAL_REPEATER
|
// #define SERIAL_REPEATER
|
||||||
|
|
202
IOSTM.cpp
202
IOSTM.cpp
|
@ -23,44 +23,124 @@
|
||||||
|
|
||||||
#if defined(STM32F4XX) || defined(STM32F4)
|
#if defined(STM32F4XX) || defined(STM32F4)
|
||||||
|
|
||||||
|
#if defined(STM32F4_DISCOVERY)
|
||||||
/*
|
/*
|
||||||
Pin definitions:
|
Pin definitions for STM32F4 Discovery Board:
|
||||||
|
|
||||||
PTT PA6 output
|
PTT PA6 output
|
||||||
COSLED PA7 output
|
COSLED PA7 output
|
||||||
LED PD15 output
|
LED PD15 output
|
||||||
COS PA5 input
|
COS PA5 input
|
||||||
ADC1 PA0 analog input
|
|
||||||
ADC2 PA1 analog input
|
|
||||||
DAC1 PA4 analog output
|
|
||||||
|
|
||||||
DSTAR PD12 output
|
DSTAR PD12 output
|
||||||
DMR PD13 output
|
DMR PD13 output
|
||||||
YSF PD14 output
|
YSF PD14 output
|
||||||
P25 PD11 output
|
P25 PD11 output
|
||||||
|
|
||||||
|
RX PA0 analog input
|
||||||
|
RSSI PA1 analog input
|
||||||
|
TX PA4 analog output
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define PIN_COS GPIO_Pin_5
|
#define PIN_COS GPIO_Pin_5
|
||||||
#define PORT_COS GPIOA
|
#define PORT_COS GPIOA
|
||||||
#define PIN_PTT GPIO_Pin_6
|
#define RCC_Per_COS RCC_AHB1Periph_GPIOA
|
||||||
#define PORT_PTT GPIOA
|
|
||||||
#define PIN_COSLED GPIO_Pin_7
|
#define PIN_PTT GPIO_Pin_6
|
||||||
#define PORT_COSLED GPIOA
|
#define PORT_PTT GPIOA
|
||||||
#define PIN_LED GPIO_Pin_15
|
#define RCC_Per_PTT RCC_AHB1Periph_GPIOA
|
||||||
#define PORT_LED GPIOD
|
|
||||||
#define PIN_ADC GPIO_Pin_0
|
#define PIN_COSLED GPIO_Pin_7
|
||||||
#define PORT_ADC GPIOA
|
#define PORT_COSLED GPIOA
|
||||||
#define PIN_DAC GPIO_Pin_4
|
#define RCC_Per_COSLED RCC_AHB1Periph_GPIOA
|
||||||
#define PORT_DAC GPIOA
|
|
||||||
|
#define PIN_LED GPIO_Pin_15
|
||||||
|
#define PORT_LED GPIOD
|
||||||
|
#define RCC_Per_LED RCC_AHB1Periph_GPIOD
|
||||||
|
|
||||||
|
#define PIN_P25 GPIO_Pin_11
|
||||||
|
#define PORT_P25 GPIOD
|
||||||
|
#define RCC_Per_P25 RCC_AHB1Periph_GPIOD
|
||||||
|
|
||||||
|
#define PIN_DSTAR GPIO_Pin_12
|
||||||
|
#define PORT_DSTAR GPIOD
|
||||||
|
#define RCC_Per_DSTAR RCC_AHB1Periph_GPIOD
|
||||||
|
|
||||||
|
#define PIN_DMR GPIO_Pin_13
|
||||||
|
#define PORT_DMR GPIOD
|
||||||
|
#define RCC_Per_DMR RCC_AHB1Periph_GPIOD
|
||||||
|
|
||||||
|
#define PIN_YSF GPIO_Pin_14
|
||||||
|
#define PORT_YSF GPIOD
|
||||||
|
#define RCC_Per_YSF RCC_AHB1Periph_GPIOD
|
||||||
|
|
||||||
|
#define PIN_RX GPIO_Pin_0
|
||||||
|
#define PIN_RX_CH ADC_Channel_0
|
||||||
|
|
||||||
|
#define PIN_RSSI GPIO_Pin_1
|
||||||
|
#define PIN_RSSI_CH ADC_Channel_1
|
||||||
|
|
||||||
|
#elif defined(STM32F4_PI)
|
||||||
|
/*
|
||||||
|
Pin definitions for STM32F4 Pi Board:
|
||||||
|
|
||||||
|
PTT PB13 output
|
||||||
|
COSLED PB14 output
|
||||||
|
LED PB15 output
|
||||||
|
COS PC0 input
|
||||||
|
|
||||||
|
DSTAR PC7 output
|
||||||
|
DMR PC8 output
|
||||||
|
YSF PA8 output
|
||||||
|
P25 PC9 output
|
||||||
|
|
||||||
|
RX PA0 analog input
|
||||||
|
RSSI PA7 analog input
|
||||||
|
TX PA4 analog output
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define PIN_COS GPIO_Pin_0
|
||||||
|
#define PORT_COS GPIOC
|
||||||
|
#define RCC_Per_COS RCC_AHB1Periph_GPIOC
|
||||||
|
|
||||||
|
#define PIN_PTT GPIO_Pin_13
|
||||||
|
#define PORT_PTT GPIOB
|
||||||
|
#define RCC_Per_PTT RCC_AHB1Periph_GPIOB
|
||||||
|
|
||||||
|
#define PIN_COSLED GPIO_Pin_14
|
||||||
|
#define PORT_COSLED GPIOB
|
||||||
|
#define RCC_Per_COSLED RCC_AHB1Periph_GPIOB
|
||||||
|
|
||||||
|
#define PIN_LED GPIO_Pin_15
|
||||||
|
#define PORT_LED GPIOB
|
||||||
|
#define RCC_Per_LED RCC_AHB1Periph_GPIOB
|
||||||
|
|
||||||
|
#define PIN_P25 GPIO_Pin_9
|
||||||
|
#define PORT_P25 GPIOC
|
||||||
|
#define RCC_Per_P25 RCC_AHB1Periph_GPIOC
|
||||||
|
|
||||||
|
#define PIN_DSTAR GPIO_Pin_7
|
||||||
|
#define PORT_DSTAR GPIOC
|
||||||
|
#define RCC_Per_DSTAR RCC_AHB1Periph_GPIOC
|
||||||
|
|
||||||
|
#define PIN_DMR GPIO_Pin_8
|
||||||
|
#define PORT_DMR GPIOC
|
||||||
|
#define RCC_Per_DMR RCC_AHB1Periph_GPIOC
|
||||||
|
|
||||||
|
#define PIN_YSF GPIO_Pin_8
|
||||||
|
#define PORT_YSF GPIOA
|
||||||
|
#define RCC_Per_YSF RCC_AHB1Periph_GPIOA
|
||||||
|
|
||||||
|
#define PIN_RX GPIO_Pin_0
|
||||||
|
#define PIN_RX_CH ADC_Channel_0
|
||||||
|
|
||||||
|
#define PIN_RSSI GPIO_Pin_7
|
||||||
|
#define PIN_RSSI_CH ADC_Channel_7
|
||||||
|
|
||||||
|
#else
|
||||||
|
#error "Either STM32F4_DISCOVERY or STM32F4_PI need to be defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define PIN_P25 GPIO_Pin_11
|
|
||||||
#define PORT_P25 GPIOD
|
|
||||||
#define PIN_DSTAR GPIO_Pin_12
|
|
||||||
#define PORT_DSTAR GPIOD
|
|
||||||
#define PIN_DMR GPIO_Pin_13
|
|
||||||
#define PORT_DMR GPIOD
|
|
||||||
#define PIN_YSF GPIO_Pin_14
|
|
||||||
#define PORT_YSF GPIOD
|
|
||||||
|
|
||||||
const uint16_t DC_OFFSET = 2048U;
|
const uint16_t DC_OFFSET = 2048U;
|
||||||
|
|
||||||
|
@ -76,86 +156,58 @@ extern "C" {
|
||||||
void CIO::initInt()
|
void CIO::initInt()
|
||||||
{
|
{
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
GPIO_InitTypeDef GPIO_InitStruct;
|
||||||
|
|
||||||
// PTT pin
|
|
||||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
|
|
||||||
GPIO_StructInit(&GPIO_InitStruct);
|
GPIO_StructInit(&GPIO_InitStruct);
|
||||||
GPIO_InitStruct.GPIO_Pin = PIN_PTT;
|
|
||||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
|
||||||
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
||||||
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
|
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
|
||||||
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
|
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
|
||||||
|
|
||||||
|
// PTT pin
|
||||||
|
RCC_AHB1PeriphClockCmd(RCC_Per_PTT, ENABLE);
|
||||||
|
GPIO_InitStruct.GPIO_Pin = PIN_PTT;
|
||||||
|
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
||||||
GPIO_Init(PORT_PTT, &GPIO_InitStruct);
|
GPIO_Init(PORT_PTT, &GPIO_InitStruct);
|
||||||
|
|
||||||
// COSLED pin
|
// COSLED pin
|
||||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
|
RCC_AHB1PeriphClockCmd(RCC_Per_COSLED, ENABLE);
|
||||||
GPIO_StructInit(&GPIO_InitStruct);
|
|
||||||
GPIO_InitStruct.GPIO_Pin = PIN_COSLED;
|
GPIO_InitStruct.GPIO_Pin = PIN_COSLED;
|
||||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
||||||
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
|
||||||
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
|
|
||||||
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
|
|
||||||
GPIO_Init(PORT_COSLED, &GPIO_InitStruct);
|
GPIO_Init(PORT_COSLED, &GPIO_InitStruct);
|
||||||
|
|
||||||
// LED pin
|
// LED pin
|
||||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
|
RCC_AHB1PeriphClockCmd(RCC_Per_LED, ENABLE);
|
||||||
GPIO_StructInit(&GPIO_InitStruct);
|
|
||||||
GPIO_InitStruct.GPIO_Pin = PIN_LED;
|
GPIO_InitStruct.GPIO_Pin = PIN_LED;
|
||||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
||||||
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
|
||||||
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
|
|
||||||
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
|
|
||||||
GPIO_Init(PORT_LED, &GPIO_InitStruct);
|
GPIO_Init(PORT_LED, &GPIO_InitStruct);
|
||||||
|
|
||||||
// Init the input pins PIN_COS
|
// Init the input pins PIN_COS
|
||||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
|
RCC_AHB1PeriphClockCmd(RCC_Per_COS, ENABLE);
|
||||||
GPIO_StructInit(&GPIO_InitStruct);
|
|
||||||
GPIO_InitStruct.GPIO_Pin = PIN_COS;
|
GPIO_InitStruct.GPIO_Pin = PIN_COS;
|
||||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;
|
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN;
|
||||||
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
|
||||||
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
|
|
||||||
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
|
||||||
GPIO_Init(PORT_COS, &GPIO_InitStruct);
|
GPIO_Init(PORT_COS, &GPIO_InitStruct);
|
||||||
|
|
||||||
#if defined(ARDUINO_MODE_PINS)
|
#if defined(ARDUINO_MODE_PINS)
|
||||||
// DSTAR pin
|
// DSTAR pin
|
||||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
|
RCC_AHB1PeriphClockCmd(RCC_Per_DSTAR, ENABLE);
|
||||||
GPIO_StructInit(&GPIO_InitStruct);
|
|
||||||
GPIO_InitStruct.GPIO_Pin = PIN_DSTAR;
|
GPIO_InitStruct.GPIO_Pin = PIN_DSTAR;
|
||||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
||||||
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
|
||||||
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
|
|
||||||
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
|
|
||||||
GPIO_Init(PORT_DSTAR, &GPIO_InitStruct);
|
GPIO_Init(PORT_DSTAR, &GPIO_InitStruct);
|
||||||
|
|
||||||
// DMR pin
|
// DMR pin
|
||||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
|
RCC_AHB1PeriphClockCmd(RCC_Per_DMR, ENABLE);
|
||||||
GPIO_StructInit(&GPIO_InitStruct);
|
|
||||||
GPIO_InitStruct.GPIO_Pin = PIN_DMR;
|
GPIO_InitStruct.GPIO_Pin = PIN_DMR;
|
||||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
||||||
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
|
||||||
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
|
|
||||||
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
|
|
||||||
GPIO_Init(PORT_DMR, &GPIO_InitStruct);
|
GPIO_Init(PORT_DMR, &GPIO_InitStruct);
|
||||||
|
|
||||||
// YSF pin
|
// YSF pin
|
||||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
|
RCC_AHB1PeriphClockCmd(RCC_Per_YSF, ENABLE);
|
||||||
GPIO_StructInit(&GPIO_InitStruct);
|
|
||||||
GPIO_InitStruct.GPIO_Pin = PIN_YSF;
|
GPIO_InitStruct.GPIO_Pin = PIN_YSF;
|
||||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
||||||
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
|
||||||
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
|
|
||||||
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
|
|
||||||
GPIO_Init(PORT_YSF, &GPIO_InitStruct);
|
GPIO_Init(PORT_YSF, &GPIO_InitStruct);
|
||||||
|
|
||||||
// P25 pin
|
// P25 pin
|
||||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
|
RCC_AHB1PeriphClockCmd(RCC_Per_P25, ENABLE);
|
||||||
GPIO_StructInit(&GPIO_InitStruct);
|
|
||||||
GPIO_InitStruct.GPIO_Pin = PIN_P25;
|
GPIO_InitStruct.GPIO_Pin = PIN_P25;
|
||||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
|
||||||
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
|
|
||||||
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
|
|
||||||
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_DOWN;
|
|
||||||
GPIO_Init(PORT_P25, &GPIO_InitStruct);
|
GPIO_Init(PORT_P25, &GPIO_InitStruct);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -165,10 +217,6 @@ void CIO::startInt()
|
||||||
if ((ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) != RESET))
|
if ((ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) != RESET))
|
||||||
io.interrupt(0U);
|
io.interrupt(0U);
|
||||||
|
|
||||||
// ADC1 PA0 analog input
|
|
||||||
// ADC2 PA1 analog input
|
|
||||||
// DAC1 PA4 analog output
|
|
||||||
|
|
||||||
// Init the ADC
|
// Init the ADC
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
GPIO_InitTypeDef GPIO_InitStruct;
|
||||||
ADC_InitTypeDef ADC_InitStructure;
|
ADC_InitTypeDef ADC_InitStructure;
|
||||||
|
@ -186,11 +234,10 @@ void CIO::startInt()
|
||||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
|
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For ADC1 on PA0, ADC2 on PA1
|
|
||||||
#if defined(SEND_RSSI_DATA)
|
#if defined(SEND_RSSI_DATA)
|
||||||
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1;
|
GPIO_InitStruct.GPIO_Pin = PIN_RX | PIN_RSSI;
|
||||||
#else
|
#else
|
||||||
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
|
GPIO_InitStruct.GPIO_Pin = PIN_RX;
|
||||||
#endif
|
#endif
|
||||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AN;
|
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AN;
|
||||||
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL ;
|
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL ;
|
||||||
|
@ -219,7 +266,7 @@ void CIO::startInt()
|
||||||
ADC_Init(ADC1, &ADC_InitStructure);
|
ADC_Init(ADC1, &ADC_InitStructure);
|
||||||
|
|
||||||
ADC_EOCOnEachRegularChannelCmd(ADC1, ENABLE);
|
ADC_EOCOnEachRegularChannelCmd(ADC1, ENABLE);
|
||||||
ADC_RegularChannelConfig(ADC1, ADC_Channel_0, 1, ADC_SampleTime_3Cycles);
|
ADC_RegularChannelConfig(ADC1, PIN_RX_CH, 1, ADC_SampleTime_3Cycles);
|
||||||
|
|
||||||
// Enable ADC1
|
// Enable ADC1
|
||||||
ADC_Cmd(ADC1, ENABLE);
|
ADC_Cmd(ADC1, ENABLE);
|
||||||
|
@ -228,7 +275,7 @@ void CIO::startInt()
|
||||||
ADC_Init(ADC2, &ADC_InitStructure);
|
ADC_Init(ADC2, &ADC_InitStructure);
|
||||||
|
|
||||||
ADC_EOCOnEachRegularChannelCmd(ADC2, ENABLE);
|
ADC_EOCOnEachRegularChannelCmd(ADC2, ENABLE);
|
||||||
ADC_RegularChannelConfig(ADC2, ADC_Channel_1, 1, ADC_SampleTime_3Cycles);
|
ADC_RegularChannelConfig(ADC2, PIN_RSSI_CH, 1, ADC_SampleTime_3Cycles);
|
||||||
|
|
||||||
// Enable ADC2
|
// Enable ADC2
|
||||||
ADC_Cmd(ADC2, ENABLE);
|
ADC_Cmd(ADC2, ENABLE);
|
||||||
|
@ -240,13 +287,13 @@ void CIO::startInt()
|
||||||
GPIO_StructInit(&GPIO_InitStruct);
|
GPIO_StructInit(&GPIO_InitStruct);
|
||||||
DAC_StructInit(&DAC_InitStructure);
|
DAC_StructInit(&DAC_InitStructure);
|
||||||
|
|
||||||
// GPIOA & D clock enable
|
// GPIOA clock enable
|
||||||
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
|
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
|
||||||
|
|
||||||
// DAC Periph clock enable
|
// DAC Periph clock enable
|
||||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
|
RCC_APB1PeriphClockCmd(RCC_APB1Periph_DAC, ENABLE);
|
||||||
|
|
||||||
// GPIO CONFIGURATION of DAC Pins
|
// GPIO CONFIGURATION of DAC Pins (PA4)
|
||||||
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;
|
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_4;
|
||||||
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AN;
|
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AN;
|
||||||
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
GPIO_InitStruct.GPIO_PuPd = GPIO_PuPd_NOPULL;
|
||||||
|
@ -263,7 +310,10 @@ void CIO::startInt()
|
||||||
|
|
||||||
TIM_TimeBaseInitTypeDef timerInitStructure;
|
TIM_TimeBaseInitTypeDef timerInitStructure;
|
||||||
TIM_TimeBaseStructInit (&timerInitStructure);
|
TIM_TimeBaseStructInit (&timerInitStructure);
|
||||||
timerInitStructure.TIM_Prescaler = 1749; // 24 kHz
|
|
||||||
|
// TIM2 at 24 kHz
|
||||||
|
timerInitStructure.TIM_Prescaler = (uint16_t) ((SystemCoreClock/(4*24000)) - 1);
|
||||||
|
|
||||||
timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
timerInitStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||||
timerInitStructure.TIM_Period = 1;
|
timerInitStructure.TIM_Period = 1;
|
||||||
timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
|
timerInitStructure.TIM_ClockDivision = TIM_CKD_DIV1;
|
||||||
|
|
Loading…
Reference in New Issue