本文整理汇总了C++中ADC_Init函数的典型用法代码示例。如果您正苦于以下问题:C++ ADC_Init函数的具体用法?C++ ADC_Init怎么用?C++ ADC_Init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ADC_Init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(void)
{
// b. Umleiten der Standardausgabe stdout (Teil 2)
//stdout = &mystdout;
// Init everything
// Init Touch & Potis
DDRA = 0x00; // ADWandler-Pins auf Eingang schalten
uint16_t ADC_val;
ADC_Init();
// Init LED Matrix
TLC5940_Init();
// Init SPI
init_SPI();
// Init Timer
timer_config();
TLC5940_SetAllDC(63);
TLC5940_ClockInDC();
TLC5940_SetAllGS(0);
// Init all 74hc595
init_74hc595();
// Init all 74hc165
init_74hc165();
// Enable Interrupts globally
// TEMP TEMP TEMP
DDRC |= 0b01000000;
// Kalibriere Touchpanel
calibrate();
sei();
// Init UART
uart_init();
while (1)
{
static uint8_t current_potentiometer = 0;
// POTENTIOMETER auslesen
{
/* switch( current_potentiometer )
{
// case 1:
// PORTC &= ~0b01000000;
// break;
case 2:
PORTC |= 0b01000000;
break;
} */
// erstes Auslesen immer Fehlerhaft wegen Touchpanel evtl
// zweiter Wert beinhaltet richtiges Ergebniss!
// POTI_ADC_SAMPLES sollte daher 2 sein damit nach dem zweiten lesen in ADC_val das richtige ergebniss steht
ADC_val = 0;
for ( uint8_t count = 0 ; count < POTI_ADC_SAMPLES ; count++ )
ADC_val = ADC_Read(potentiometer[current_potentiometer].adc_channel);
if( ADC_val > ( potentiometer[current_potentiometer].value + ADC_delta_for_change_poti ) || ( ADC_val < ( potentiometer[current_potentiometer].value - ADC_delta_for_change_poti ) ) ) // +- 8 von 1024 Quantisierungsstufen / 128 Midi Schritte . // if( ADC_val > ( potentiometer[current_potentiometer].value + 10 ) || ( ADC_val < ( potentiometer[current_potentiometer].value - 10 ) ) )
{
potentiometer[current_potentiometer].value = ADC_val;
controlChange(midi_channel, midi_poti_offset + current_potentiometer,ADC_val/8);
//printf("%i. Poti %i\n", current_potentiometer , potentiometer[current_potentiometer].value );
}
current_potentiometer++;
if ( current_potentiometer == potentiometer_count)
current_potentiometer = 0;
}
//Display_SetCross(4,2);
// TOUCHPANEL auslesen
read_touchscreen();
if(touchscreen.FLAG_Display_change)
{
TLC5940_SetAllGS(0);
//Display_SetParabel(touchscreen.last_x , touchscreen.last_y );
Display_SetCross(touchscreen.last_LED_x,touchscreen.last_LED_y);
touchscreen.FLAG_Display_change = 0;
}
}
}
示例2: ADC_DMA_Config
void ADC_DMA_Config(void)
{
ADC_InitTypeDef ADC_InitStructure;
ADC_CommonInitTypeDef ADC_CommonInitStructure;
DMA_InitTypeDef DMA_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
/* Enable ADC3, DMA2 and GPIO clocks ****************************************/
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2 | RCC_AHB1Periph_GPIOF, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC3, ENABLE);
/* DMA2 Stream0 channel0 configuration **************************************/
DMA_InitStructure.DMA_Channel = DMA_Channel_2;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC3->DR;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)&ADCConvertedValue;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_InitStructure.DMA_BufferSize = 4;//--------------
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;//----------------
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_Low;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(DMA2_Stream0, &DMA_InitStructure);
DMA_Cmd(DMA2_Stream0, ENABLE);
/* Configure ADC3 Channel12 pin as analog input ******************************/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10;//-------------
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_Init(GPIOF, &GPIO_InitStructure);
/* ADC Common Init **********************************************************/
ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_5Cycles;
ADC_CommonInit(&ADC_CommonInitStructure);
/* ADC3 Init ****************************************************************/
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;//------------------
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfConversion = 4;
ADC_Init(ADC3, &ADC_InitStructure);
/* ADC3 regular channel12 configuration *************************************/
ADC_RegularChannelConfig(ADC3, ADC_Channel_5, 1, ADC_SampleTime_3Cycles);
ADC_RegularChannelConfig(ADC3, ADC_Channel_6, 2, ADC_SampleTime_3Cycles);
ADC_RegularChannelConfig(ADC3, ADC_Channel_7, 3, ADC_SampleTime_3Cycles);
ADC_RegularChannelConfig(ADC3, ADC_Channel_8, 4, ADC_SampleTime_3Cycles);
/* Enable DMA request after last transfer (Single-ADC mode) */
ADC_DMARequestAfterLastTransferCmd(ADC3, ENABLE);
/* Enable ADC3 DMA */
ADC_DMACmd(ADC3, ENABLE);
/* Enable ADC3 */
ADC_Cmd(ADC3, ENABLE);
}
示例3: Init_Task
void Init_Task(uint32_t task_init_data)
{
int tester=0;
//uint_8 sys=0;
bool bInitOpen=FALSE;
bool bInitStill=FALSE;
bool bInitVLPS=FALSE;
MQX_TICK_STRUCT ttt;
_mqx_uint mqx_ret;
trace_init();
show_version_information();
//////////////zga add
//Set LPTMR to timeout about 5 seconds
Lptmr_Init(1000, LPOCLK);
ADC_Init();
Calibrate_ADC();
ADC_Init();
DMA1_Init();
//////////////zga add
// clear flag
APP_TRACE("start 1\n\r");
_task_create_at(0, SHELL_TASK, 0, shell_task_stack, SHELL_TASK_STACK_SIZE);
_task_create_at(0, MMA8415_TASK, 0, mma8451_task_stack, MMA8451_TASK_STACK_SIZE);
Lptmr_Start();
for(;;)
{
mqx_ret = _lwsem_wait(&g_lptmr_int_sem);
// _time_delay_ticks(10);
tester++;
//_time_delay_ticks(10);
//APP_TRACE("tester is: %d\r\n",tester);
_time_get_elapsed_ticks(&ttt);
APP_TRACE("high ttt %d, low ttt%d\r\n", ttt.TICKS[1],ttt.TICKS[0]);
if(Measured)
{ Measured=0;
APP_TRACE ("light: %d ,%d \r\n", (uint16_t) MeasuredValues[1],tester);
}
if((GetTouchON()==TRUE))
{
SetSysStatus(ACTIVE_OPEN);
}
// for test
SetSysStatus(ACTIVE_OPEN);
switch (sysStatus)
{
case ACTIVE_OPEN:
bInitStill=FALSE;
bInitVLPS=FALSE;
APP_TRACE ("ACTIVE_OPEN\r\n");
if(bInitOpen==FALSE)
{
bInitOpen=TRUE;
putmma8451running();
SysTick_PDD_EnableDevice(SysTick_BASE_PTR, PDD_ENABLE);
}
break;
case ACTIVE_STILL:
bInitOpen=FALSE;
bInitVLPS=FALSE;
APP_TRACE ("ACTIVE_still\r\n");
if(bInitStill==FALSE)
{
bInitStill=TRUE;
putmma8451detect();
}
enter_vlps();
case VLPSMODE:
bInitOpen=FALSE;
bInitStill=FALSE;
APP_TRACE ("vlpsmode\r\n");
if(bInitVLPS==FALSE)
{
bInitVLPS=TRUE;
putmma8451standby();
}
enter_vlps();
default:
break;
}
}
}
示例4: main
void main()
{
delay1s();
AUXR = AUXR|0x40; // T1, 1T Mode
// IE2 |= ESPI;
EXTI0_Init(); //4432的中断设置
UART_Init(); //波特率9600
SPI_Init(MASTER);
delay1s();
SI4432_Init();
SI4432_SetRxMode(); //接收模式
ADC_Init(AFPORT_P1_4);
delay1s();
#if MULTI_SENSOR
SendString("ROMID Search...\r\n");
SendROMID(DS18B20_SearchRomID());
SendString("\r\n"); //调试信息时候用
#endif
//-----------------------------------------------------
EA = 1; //注意:外设初始化完再开中断!
while(1)
{
if(Trans_RevPakFin)
{
Trans_RevPakFin = 0;
//液位采集计算
ADC_STARTCOV(ADC_CH4,ADC_SPEED_540T);
while(!(g_sensor_sta1&PRS_RDY)); //等待压力采集完成
//温度采集计算
// TemperDatHandle();
//液位开关采集
sensor_data.possw = POSSW;
//流量开关采集
// sensor_data.flow = FLOW;
//打包
if(1==Pak_Handle())
{
g_sensor_sta1 = 0; //清除所有传感器标志位
LED2 = 0;
SendString("valid cmd received.\r\n");
delay200ms();
LED2 = 1;
}
}
//********************code for test**************************************
// DATA_Cmd_ACK();
// LED2 = 0;
// SendString("valid cmd received.\r\n");
// delay200ms();
// LED2 = 1;
// ADC_STARTCOV(ADC_CH4,ADC_SPEED_540T);
// while(!(g_sensor_sta1&PRS_RDY)); //等待压力采集完成
// sprintf("level: %d:\r\n",);
// SendString("level: %s:\r\n");
// sensor_data.flow = FLOW;
// SendString("flow data:\r\n");
// SendByteASCII(sensor_data.flow);
// SendString("\r\n");
// delay1s();
// delay1s();
//********************end of code for test**************************************
}//end of while
}//end of main
示例5: adcInit
void adcInit(drv_adc_config_t *init)
{
ADC_InitTypeDef ADC_InitStructure;
ADC_CommonInitTypeDef ADC_CommonInitStructure;
DMA_InitTypeDef DMA_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
bool multiChannel = init->powerAdcChannel > 0;
/* Enable ADC1, DMA2 clocks *************************************************/
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
/* DMA2 Stream0 channel0 configuration **************************************/
DMA_DeInit(DMA2_Stream0);
DMA_InitStructure.DMA_Channel = DMA_Channel_0;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&ADC1->DR;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)adcValues;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_InitStructure.DMA_BufferSize = multiChannel ? 2 : 1;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(DMA2_Stream0, &DMA_InitStructure);
DMA_Cmd(DMA2_Stream0, ENABLE);
/* Configure ADC3 Channel12 pin as analog input ******************************/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_Init(GPIOC, &GPIO_InitStructure);
/* ADC Common Init **********************************************************/
ADC_DeInit();
ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_20Cycles;
ADC_CommonInit(&ADC_CommonInitStructure);
/* ADC1 Init ****************************************************************/
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
ADC_InitStructure.ADC_ScanConvMode = multiChannel ? ENABLE : DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
ADC_InitStructure.ADC_ExternalTrigConv = 0;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfConversion = multiChannel ? 2 : 1;
ADC_Init(ADC1, &ADC_InitStructure);
/* Enable ADC1 DMA */
//ADC_DMACmd(ADC1, ENABLE);
ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 1, ADC_SampleTime_28Cycles);
if (multiChannel)
ADC_RegularChannelConfig(ADC1, init->powerAdcChannel, 2, ADC_SampleTime_28Cycles);
ADC_DMACmd(ADC1, ENABLE);
ADC_Cmd(ADC1, ENABLE);
// Calibrate ADC
//ADC_ResetCalibration(ADC1);
//while(ADC_GetResetCalibrationStatus(ADC1));
// ADC_StartCalibration(ADC1);
// while(ADC_GetCalibrationStatus(ADC1));
// Fire off ADC
ADC_SoftwareStartConv(ADC1);
}
示例6: main
int main(void)
{
char temp, i;
LCD_Initialize();
DDRB = 0b00000000;
PORTB = 0b00001111;
DDRA = 0xFF;
ADC_Init();
int value = 0;
int calculations = 0;
char dzialanie = 0;
int digit = 0;
do{
int digit = getADC(0);
char sw0 = PINB & 0b00000001;
char sw1 = PINB & 0b00000010;
if(sw0 != 0b00000001) {
state++;
_delay_ms(300);
}
char str[15];
sprintf(str, "%15d", lastValue);
LCD_GoTo(1,0);
LCD_WriteText(str);
switch(state){
case 0:
if(sw1 != 0b00000010){
setNewValue(mappingLogToLinear(digit, digitMap, 10));
_delay_ms(300);
}
sprintf(str, "%15d", mappingLogToLinear(digit, digitMap,10));
LCD_GoTo(1,1);
LCD_WriteText(str);
break;
case 1:
if(sw1 != 0b00000010){
setSign(mappingLogToLinear(digit, signMap, 2));
power = 0;
_delay_ms(300);
}
switch(mappingLogToLinear(digit, signMap,2)){
case 0:
LCD_GoTo(1,1);
LCD_WriteText("-");
break;
case 1:
LCD_GoTo(1,1);
LCD_WriteText("+");
break;
}
break;
case 2:
if(sw1 != 0b00000010){
doCalculations(mappingLogToLinear(digit, expressionMap, 4));
power = 0;
newValue=0;
state = 0;
_delay_ms(300);
}
switch(mappingLogToLinear(digit, expressionMap,4)){
case 0:
LCD_GoTo(1,1);
LCD_WriteText("+");
break;
case 1:
LCD_GoTo(1,1);
LCD_WriteText("-");
break;
case 2:
LCD_GoTo(1,1);
LCD_WriteText("*");
break;
case 3:
LCD_GoTo(1,1);
LCD_WriteText("/");
break;
}
break;
}
/*
char sw0 = PINB & 0b00000001;
//.........这里部分代码省略.........
示例7: hal_adc_open
int hal_adc_open(HAL_ADC_HANDLE *handle, void *params)
{
ADC_InitTypeDef ADC_InitStructure;
ADC_CommonInitTypeDef ADC_CommonInitStructure;
DMA_InitTypeDef DMA_InitStructure;
UNUSED(params);
/* DMA2_Stream0 channel0 configuration **************************************/
DMA_DeInit(DMA2_Stream0);
DMA_InitStructure.DMA_Channel = DMA_Channel_0;
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)ADC1_DR_Address;
DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)convertedValues;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralToMemory;
DMA_InitStructure.DMA_BufferSize = 1;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Disable;
DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_HalfFull;
DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single;
DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single;
DMA_Init(DMA2_Stream0, &DMA_InitStructure);
/* DMA2_Stream0 enable */
DMA_Cmd(DMA2_Stream0, ENABLE);
/* ADC Common Init **********************************************************/
ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_CommonInitStructure.ADC_Prescaler = ADC_Prescaler_Div2;
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_20Cycles;
ADC_CommonInit(&ADC_CommonInitStructure);
/* ADC1 Init ****************************************************************/
ADC_InitStructure.ADC_Resolution = ADC_Resolution_12b;
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfConversion = 1;
ADC_Init(ADC1, &ADC_InitStructure);
/* Enable ADC1 DMA */
ADC_DMACmd(ADC1, ENABLE);
/* ADC1 regular channel18 (VBAT) configuration ******************************/
ADC_RegularChannelConfig(ADC1, ADC_Channel_4, 1, ADC_SampleTime_480Cycles);
/* Enable DMA request after last transfer (Single-ADC mode) */
ADC_DMARequestAfterLastTransferCmd(ADC1, ENABLE);
/* Enable ADC1 **************************************************************/
ADC_Cmd(ADC1, ENABLE);
ADC_SoftwareStartConv(ADC1);
*handle = (void *)convertedValues;
return HAL_ADC_E_SUCCESS;
}
示例8: main
/*******************************************************************************
* Function Name : main
* Description : Main program
* Input : None
* Output : None
* Return : None
*******************************************************************************/
int main(void)
{
/* define local values */
u16 DataValue = 0x0;
u16 Keta = 0;
u16 cnt = 0; // counter
u32 wcnt = 0; // counter for wait
u16 Temperature = 0 ;
u8 a, b, c, d;
#ifdef DEBUG
debug();
#endif
/* System Clocks Configuration */
RCC_Configuration();
/* NVIC configuration */
NVIC_Configuration();
/* Configure the GPIO ports */
GPIO_Configuration(); // ADC用のGPIOの設定はしなくていいよね。
/* USART2 configuration ------------------------------------------------------*/
/* USART2 configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Hardware flow control enabled (RTS and CTS signals)
- Receive and transmit enabled
*/
USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No ;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_RTS_CTS;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART2, &USART_InitStructure);
/* Enable the USART2 */
USART_Cmd(USART2, ENABLE);
/* ADC1 configuration ------------------------------------------------------*/
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(ADC1, &ADC_InitStructure);
/* ADC1 regular channels configuration */
ADC_RegularChannelConfig(ADC1, ADC_Channel_16, 1, ADC_SampleTime_239Cycles5);
ADC_RegularChannelConfig(ADC1, ADC_Channel_17, 2, ADC_SampleTime_239Cycles5);
/* Enable ADC1 DMA */
// ADC_DMACmd(ADC1, ENABLE);
/* Enable Vrefint channel17 */
ADC_TempSensorVrefintCmd(ENABLE);
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE);
/* Enable ADC1 reset calibaration register */
ADC_ResetCalibration(ADC1);
/* Check the end of ADC1 reset calibration register */
while(ADC_GetResetCalibrationStatus(ADC1));
/* Start ADC1 calibaration */
ADC_StartCalibration(ADC1);
/* Check the end of ADC1 calibration */
while(ADC_GetCalibrationStatus(ADC1));
/* Start ADC1 Software Conversion */
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
/* Test on DMA1 channel1 transfer complete flag */
//while(!DMA_GetFlagStatus(DMA1_FLAG_TC1));
/* Clear DMA1 channel1 transfer complete flag */
//DMA_ClearFlag(DMA1_FLAG_TC1);
/* DEBUG MARKER */
/* ************* */
/* Turn on led connected to PC.06 pin */
//GPIO_SetBits(GPIOC, GPIO_Pin_6);
/* Turn off led connected to PC.06 pin */
GPIO_ResetBits(GPIOC, GPIO_Pin_6);
/* Communication hyperterminal-USART2 using hardware flow control -------------*/
/* Send a buffer from USART to hyperterminal */
while(NbrOfDataToTransfer--)
//.........这里部分代码省略.........
示例9: sys_adc_init
/*----------------------------------------------------------------------------*/
void sys_adc_init()
{
GPIO_InitTypeDef GPIO_InitStructure;
ADC_InitTypeDef ADC_InitStructure;
DMA_InitTypeDef DMA_InitStructure;
/* Enable DMA1 clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
#define DIV RCC_PCLK2_Div2
//#define DIV RCC_PCLK2_Div4
//#define DIV RCC_PCLK2_Div6
//#define DIV RCC_PCLK2_Div8
RCC_ADCCLKConfig(DIV);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
/* GPIO */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
//GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
/* DMA1 channel1 configuration ----------------------------------------------*/
DMA_DeInit(DMA1_Channel1);
DMA_InitStructure.DMA_PeripheralBaseAddr = ADC1_DR_Address;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&adc_buffer;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralSRC;
DMA_InitStructure.DMA_BufferSize = ADC_BUFFER_SIZE;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel1, &DMA_InitStructure);
/* Enable DMA1 channel1 */
DMA_Cmd(DMA1_Channel1, ENABLE);
/* ADC1 configuration ------------------------------------------------------*/
ADC_Cmd(ADC1, DISABLE);
ADC_DeInit(ADC1);
ADC_StructInit(&ADC_InitStructure);
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = ENABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(ADC1, &ADC_InitStructure);
/* ADC1 regular channel12 configuration */
//#define SAMPLE_TIME ADC_SampleTime_1Cycles5
//#define SAMPLE_TIME ADC_SampleTime_7Cycles5
//#define SAMPLE_TIME ADC_SampleTime_13Cycles5
#define SAMPLE_TIME ADC_SampleTime_28Cycles5
//#define SAMPLE_TIME ADC_SampleTime_41Cycles5
//#define SAMPLE_TIME ADC_SampleTime_55Cycles5
//#define SAMPLE_TIME ADC_SampleTime_71Cycles5
//#define SAMPLE_TIME ADC_SampleTime_239Cycles5
ADC_RegularChannelConfig(ADC1, ADC_Channel_12, 1, SAMPLE_TIME);
/* Enable ADC1 DMA */
ADC_DMACmd(ADC1, ENABLE);
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE);
sys_sleep(2);
/* Enable ADC1 reset calibration register */
ADC_ResetCalibration(ADC1);
/* Check the end of ADC1 reset calibration register */
while(ADC_GetResetCalibrationStatus(ADC1));
/* Start ADC1 calibration */
ADC_StartCalibration(ADC1);
/* Check the end of ADC1 calibration */
while(ADC_GetCalibrationStatus(ADC1));
/* Start ADC1 Software Conversion */
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
#ifdef USE_CONSOLE
console_cmd_init(&adc_console1);
adc_console1.cmd = "adc";
adc_console1.help = "adc - ADC read ADC DMA statistic";
adc_console1.handler = adc_cmd1;
console_add_cmd(&adc_console1);
#endif //USE_CONSOLE
}
示例10: main
/**
* @brief Main program
* @param None
* @retval : None
*/
int main(void)
{
/* System Clocks Configuration */
RCC_Configuration();
/* Configure the GPIO ports */
GPIO_Configuration();
/* DMA1 Channel5 configuration ----------------------------------------------*/
DMA_DeInit(DMA1_Channel5);
DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)TIM1_CCR1_Address;
DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)ADC1_DR_Address;
DMA_InitStructure.DMA_DIR = DMA_DIR_PeripheralDST;
DMA_InitStructure.DMA_BufferSize = 1;
DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable;
DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Disable;
DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_HalfWord;
DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_HalfWord;
DMA_InitStructure.DMA_Mode = DMA_Mode_Circular;
DMA_InitStructure.DMA_Priority = DMA_Priority_High;
DMA_InitStructure.DMA_M2M = DMA_M2M_Disable;
DMA_Init(DMA1_Channel5, &DMA_InitStructure);
/* Enable DMA1 Channel5 */
DMA_Cmd(DMA1_Channel5, ENABLE);
/* ADC1 configuration ------------------------------------------------------*/
ADC_InitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_InitStructure.ADC_ScanConvMode = DISABLE;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_None;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_NbrOfChannel = 1;
ADC_Init(ADC1, &ADC_InitStructure);
/* ADC1 RegularChannelConfig Test */
ADC_RegularChannelConfig(ADC1, ADC_Channel_14, 1, ADC_SampleTime_55Cycles5);
/* TIM1 configuration ------------------------------------------------------*/
/* Time Base configuration */
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_TimeBaseStructure.TIM_Period = 0xFF0;
TIM_TimeBaseStructure.TIM_Prescaler = 0x0;
TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);
/* Channel1 Configuration in PWM mode */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC1Init(TIM1, &TIM_OCInitStructure);
/* Enable TIM1 */
TIM_Cmd(TIM1, ENABLE);
/* Enable TIM1 outputs */
TIM_CtrlPWMOutputs(TIM1, ENABLE);
/* Enable TIM1 DMA interface */
TIM_DMACmd(TIM1, TIM_DMA_Update, ENABLE);
/* Enable ADC1 */
ADC_Cmd(ADC1, ENABLE);
/* Enable ADC1 reset calibaration register */
ADC_ResetCalibration(ADC1);
/* Check the end of ADC1 reset calibration register */
while(ADC_GetResetCalibrationStatus(ADC1));
/* Start ADC1 calibaration */
ADC_StartCalibration(ADC1);
/* Check the end of ADC1 calibration */
while(ADC_GetCalibrationStatus(ADC1));
/* Start ADC1 conversion */
ADC_SoftwareStartConvCmd(ADC1, ENABLE);
while (1)
{
}
}
示例11: F_InitialADC
//==============================================================================
// ADC 初始化
//==============================================================================
void F_InitialADC(void)
{
ADC_InitTypeDef ADC_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; // 聲明定時器初始化結構體
TIM_OCInitTypeDef TIM_OCInitStructure;
/* GPIOC Periph clock enable */
RCC_AHBPeriphClockCmd(P_VR2_GPIO_CLK, ENABLE);
/* ADC1 Periph clock enable */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
/* TIM3 Periph clock enable */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3, ENABLE);
/* Configure ADC Channel0 as analog input */
GPIO_InitStructure.GPIO_Pin = P_VR2_PIN ;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_Init(P_VR2_GPIO_PORT, &GPIO_InitStructure);
/* TIM3 Configuration *******************************************************/
TIM_DeInit(TIM3);
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
TIM_OCStructInit(&TIM_OCInitStructure);
/* Time base configuration */
TIM_TimeBaseStructure.TIM_Period = 0xFF;
TIM_TimeBaseStructure.TIM_Prescaler = 0x0;
TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);
/* TIM3 TRGO selection */
TIM_SelectOutputTrigger(TIM3, TIM_TRGOSource_Update);
/* ADC2 Configuration *******************************************************/
/* ADCs DeInit */
ADC_DeInit(ADC1);
/* Configure the ADC1 in continous mode withe a resolutuion equal to 8 bits*/
ADC_InitStructure.ADC_Resolution = ADC_Resolution_8b;
ADC_InitStructure.ADC_ContinuousConvMode = ENABLE;
ADC_InitStructure.ADC_ExternalTrigConvEdge = ADC_ExternalTrigConvEdge_Rising;
ADC_InitStructure.ADC_ExternalTrigConv = ADC_ExternalTrigConv_T3_TRGO;
ADC_InitStructure.ADC_DataAlign = ADC_DataAlign_Right;
ADC_InitStructure.ADC_ScanDirection = ADC_ScanDirection_Upward;
ADC_Init(ADC1, &ADC_InitStructure);
/* Convert the ADC1 Channel 0 with 239.5 Cycles as sampling time */
ADC_ChannelConfig(ADC1, P_VR2_Channel , ADC_SampleTime_28_5Cycles);
/* ADC Calibration */
ADC_GetCalibrationFactor(ADC1);
/* Enable the auto delay feature */
ADC_WaitModeCmd(ADC1, ENABLE);
/* Enable the Auto power off mode */
ADC_AutoPowerOffCmd(ADC1, ENABLE);
/* Enable ADCperipheral[PerIdx] */
ADC_Cmd(ADC1, ENABLE);
/* Wait the ADCEN falg */
while(!ADC_GetFlagStatus(ADC1, ADC_FLAG_ADEN));
/* TIM2 enable counter */
TIM_Cmd(TIM3, ENABLE);
/* ADC1 regular Software Start Conv */
ADC_StartOfConversion(ADC1);
}
示例12: main
int main(void){
int i = 0;
//Score set
score = 0;
PLL_Init();
//Sound init
DAC_Init();
Timer0A_Init(Sound_Update, 1000000/11025);
// Timer0B_Init(updateXAxis, 1000000/11025);
// Timer1B_Init(updateYAxis, 1000000/11025);
//Input
ADC_Init();
portD_Init();
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
GPIOPinTypeGPIOInput(GPIO_PORTG_BASE,
(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7));
GPIOPinTypeGPIOOutput(GPIO_PORTG_BASE, GPIO_PIN_2);
GPIOPadConfigSet(GPIO_PORTG_BASE,
(GPIO_PIN_3 | GPIO_PIN_4 | GPIO_PIN_5 | GPIO_PIN_6 | GPIO_PIN_7),
GPIO_STRENGTH_2MA,
GPIO_PIN_TYPE_STD_WPU);
SysTick_Init(50000000/400);
Output_Init();
Output_Color(15);
SysTick_IntEnable();
EnableInterrupts();
//Set flags
gFlags = 0;
HWREGBITW(&gFlags, TITLE_SCREEN) = True;
//Math rand set seed
while(HWREGBITW(&gFlags, SELECT_DOWN) == 0 &&
((GPIO_PORTG_DATA_R & 0x80) != 0)) { }
while(HWREGBITW(&gFlags, SELECT_DOWN) == 1 ||
((GPIO_PORTG_DATA_R & 0x80) == 0)) { }
setSeed(NVIC_ST_CURRENT_R);
//Game set
setGraphics(1);//the lm3s can't handle more than 2 rocks at graphics level 3.
gameInit();
gameSet(0);
while(1) {
//Only draw to buffer when it has been output to the screen
if(HWREGBITW(&gFlags, FRAME_BUFFER_READY) == False) {
/*if(gameLevel == -2) {
drawString(myMsgs[1], makePoint(50, 40));
while ((GPIO_PORTG_DATA_R & 0x80) != 0 &&
HWREGBITW(&gFlags, SELECT_DOWN) == False) { }
while ((GPIO_PORTG_DATA_R & 0x80) == 0 &&
HWREGBITW(&gFlags, SELECT_DOWN) == True) { }
//Reset game
*/
//Check for level completion, aka all rocks and enemies are
//TODO: enemies
if(HWREGBITW(&gFlags, LEVEL_COMPLETE) == True) { gameSet(++gameLevel); }
//Redraw the screen from scratch.
clearBuffer();
//Draw the player.
if(gPlayer.status == ALIVE) {
drawPlayer(makePoint((int)gPlayer.x, (int)gPlayer.y),
gPlayer.angle, gPlayer.exhaustOn);
}
for(i = 0; i < MAX_ROCKS; i++) {
if(gRocks[i].status == ALIVE) {
drawRock(makePoint(gRocks[i].x, gRocks[i].y),
gRocks[i].rockType, gRocks[i].rockSize);
}
}
//Draw allied bullets.
for(i = 0; i < MAX_PLAYER_BULLETS; i++) {
if(gPlayerBullets[i].status == ALIVE) {
drawBullet(makePoint(gPlayerBullets[i].x, gPlayerBullets[i].y));
}
}
//Draw enemy bullets.
for(i = 0; i < MAX_ENEMY_BULLETS; i++) {
if(gEnemyBullets[i].status == ALIVE) {
drawBullet(makePoint(gEnemyBullets[i].x, gEnemyBullets[i].y));
}
}
//Draw explosions.
for(i = 0; i < MAX_EXPLOSIONS; i++) {
if(gExplosions[i].status == ALIVE) {
drawExplosion(gExplosions[i].pos, gExplosions[i].current);
}
}
//
drawNumber(score, makePoint(2,2));
drawNumber(gameLevel, makePoint(128/2-6,2));
if(HWREGBITW(&gFlags, GAME_OVER) == True) {
drawString("GAME OVER", makePoint(40, 38));
if((GPIO_PORTG_DATA_R & 0x80)) {
//reset game
}
gameUpdate();
} else if(HWREGBITW(&gFlags, TITLE_SCREEN) == True) {
drawString("ASTEROIDS", makePoint(40, 38));
gameLevel = 0;
}
updateXAxis();
//.........这里部分代码省略.........
示例13: main
int main(void)
{
/*Ждем пока все включится*/
_delay_ms(100);
/*Настраиваем порты ввода-вывода*/
DDRB = 1<<PORTB0|1<<PORTB1|1<<PORTB2|1<<PORTB3|1<<PORTB4|1<<PORTB5|1<<PORTB6|1<<PORTB7;
DDRC = 1<<PORTC0|1<<PORTC1|1<<PORTC2|0<<PORTC3|0<<PORTC4|0<<PORTC5|0<<PORTC6|0<<PORTC7;
DDRD = 0<<PORTD0|0<<PORTD1|0<<PORTD2|0<<PORTD3|1<<PORTD4|0<<PORTD5|0<<PORTD6|1<<PORTD7;
PORTB = 1;
PORTD = 1 << PORTD2;
/*Тяга двигателей на минимум*/
for(uint8_t k = 0; k < CHANNELS_COUNT; ++k)
{
counter[k] = LOW;
}
/*Настраиваем I2C*/
TWSR = 0x00;
TWBR = ((F_CPU / I2C_SPEED) - 16) / 2;
_delay_us(10);
/*Включаем Таймер0*/
TCCR0 = 1<<CS02 | 0<<CS01 | 0<<CS00;
/*Включаем Таймер1*/
OCR1A=HIGH; //TOP
TCCR1A=0<<COM1A1|0<<COM1A0|1<<COM1B1|0<<COM1B0|0<<FOC1A|0<<FOC1B|1<<WGM11|1<<WGM10;
TCCR1B=0<<ICNC1|0<<ICES1|1<<WGM13|1<<WGM12|0<<CS12|0<<CS11|1<<CS10;
TIMSK= 1<<TOIE2 | 1<<OCIE1A|1<<OCIE1B|0<<TOIE1|1<<TOIE0|0<<OCIE0;
OCR1B=LOW;
/*Включаем АЦП*/
ADC_Init();
/*Включаем прерывание INT0(высотомер)*/
INT0_Init();
/*Разрешаем работу прерываний*/
sei();
/*Настраиваем Modbus*/
eMBErrorCode eStatus = eMBInit( MB_RTU, 0x01, 0, 57600, MB_PAR_NONE );
eStatus = eMBEnable();
/*Настраиваем сенсоры*/
SensorsInit();
/*Загружаем в Holding Registers и в массив параметров значения из EEPROM*/
ModbusInitValues();
filterInit();
while(1)
{
/*Актуализируем значения Modbus-регистров в соответствии со значениями параметров*/
ModbusLoader();
/*Актуализируем значения параметров в соответствии со значениями Holding Registers*/
ModbusSaver();
/*Итерация Modbus*/
eMBPoll();
/*Ресурсоемкий расчет курса*/
Course_Calc();
}
}
示例14: main
int main(void)
{
CanMessage tmp; /* Local Variables */
#if ( TERMINAL == 1 )
UART_Init(); /* UART */
ADC_Init(); /* ADC */
#endif
GPIO_Init(); /* GPIO */
ExtINT_Init(); /* External Interrupt */
Timer_Init(); /* Timers */
SPI_Init(); /* SPI */
CanStatus res = CAN_Init(CAN_SPEED); /* Start CAN */
#if ( TERMINAL == 1 )
term_Start(res); /* Start Terminal */
#endif
Msg_Init(); /* Construct Messages to be sent */
CAN_BufInit( &RxBuffer, CAN_RX_BUFFER_SIZE ); /* Initialize Receive Buffer */
CAN_BufInit( &TxBuffer, CAN_TX_BUFFER_SIZE ); /* Initialize Transmit Buffer */
sei(); /* Enable Global Interrupts */
/* ---------------------------*/
while(1){
wdt_enable(WDTO_1S); /* Enable Watchdog Timer for 2 second */
/* ------------------------------------------ */
/* Send Messages */
// Get Data
ATOMIC_BLOCK( ATOMIC_FORCEON ){
if( CAN_BufState( &TxBuffer ) != BUFFER_EMPTY ){/* Check if empty */
CAN_BufDeq( &TxBuffer, &tmp ); /* Dequeue */
CAN_SendMsg( &tmp ); /* Send */
}
}
/* ------------------------------------------ */
/* Receive Messages */
ATOMIC_BLOCK( ATOMIC_FORCEON ){ /* Read Interrupt variables */
if( CAN_BufState( &RxBuffer ) != BUFFER_EMPTY ){/* Check if not empty */
CAN_BufDeq( &RxBuffer, &tmp ); /* Dequeue */
Msg_Chk( &tmp ); /* Check Received Message */
#if ( TERMINAL == 1 )
if( strm == MS_STREAM ) /* Enable Terminal Message Stream */
term_RxMsg( &tmp );
#endif
}
}
/* ------------------------------------------ */
#if ( TERMINAL == 1 )
term_Main(); /* TERMINAL FOR DEBUGGING */
#endif
}
wdt_reset(); /* Reset Watchdog */
wdt_disable();
return 0;
}
示例15: init
void init( void )
{
SystemInit();
// Set Systick to 1ms interval, common to all SAM3 variants
if (SysTick_Config(SystemCoreClock / 1000))
{
// Capture error
while (true);
}
/* Configure the SysTick Handler Priority: Preemption priority and subpriority */
NVIC_SetPriority(SysTick_IRQn, 15);
// Disable watchdog
//WDT_Disable(WDT);
// Initialize C library
__libc_init_array();
// default 13pin led will off.
pinMode(13,OUTPUT);
digitalWrite(13, LOW);
/*
// Enable parallel access on PIo output data registers
PIOA->PIO_OWER = 0xFFFFFFFF;
PIOB->PIO_OWER = 0xFFFFFFFF;
PIOC->PIO_OWER = 0xFFFFFFFF;
PIOD->PIO_OWER = 0xFFFFFFFF;
// Initialize Serial port U(S)Art pins
PIO_Configure(
g_APinDescription[PINS_UART].pport,
g_APinDescription[PINS_UART].ulpintype,
g_APinDescription[PINS_UART].ulpin,
g_APinDescription[PINS_UART].ulpinconfiguration);
digitalWrite(0, HIGH); // Enable pullup for rx0
PIO_Configure(
g_APinDescription[PINS_USART0].pport,
g_APinDescription[PINS_USART0].ulpintype,
g_APinDescription[PINS_USART0].ulpin,
g_APinDescription[PINS_USART0].ulpinconfiguration);
PIO_Configure(
g_APinDescription[PINS_USART1].pport,
g_APinDescription[PINS_USART1].ulpintype,
g_APinDescription[PINS_USART1].ulpin,
g_APinDescription[PINS_USART1].ulpinconfiguration);
PIO_Configure(
g_APinDescription[PINS_USART3].pport,
g_APinDescription[PINS_USART3].ulpintype,
g_APinDescription[PINS_USART3].ulpin,
g_APinDescription[PINS_USART3].ulpinconfiguration);
// Initialize USB pins
PIO_Configure(
g_APinDescription[PINS_USB].pport,
g_APinDescription[PINS_USB].ulpintype,
g_APinDescription[PINS_USB].ulpin,
g_APinDescription[PINS_USB].ulpinconfiguration);
// Initialize CAN pins
PIO_Configure(
g_APinDescription[PINS_CAN0].pport,
g_APinDescription[PINS_CAN0].ulpintype,
g_APinDescription[PINS_CAN0].ulpin,
g_APinDescription[PINS_CAN0].ulpinconfiguration);
PIO_Configure(
g_APinDescription[PINS_CAN1].pport,
g_APinDescription[PINS_CAN1].ulpintype,
g_APinDescription[PINS_CAN1].ulPin,
g_APinDescription[PINS_CAN1].ulPinConfiguration);
*/
//disable JTAG-DP,release pin 29(PB3),30(PB4),23(PA15)
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
//GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE);
////remap Timer4
//GPIO_PinRemapConfig(GPIO_Remap_TIM4,ENABLE);
////remap USART3
//GPIO_PinRemapConfig(GPIO_FullRemap_USART3,ENABLE);
////remap USART2
//GPIO_PinRemapConfig(GPIO_Remap_USART2,ENABLE);
////remap CAN1,to PD0,PD1
//GPIO_PinRemapConfig(GPIO_Remap2_CAN1,ENABLE);
// Initialize Analog Controller
ADC_InitTypeDef ADC_InitStructure;
ADC_CommonInitTypeDef ADC_CommonInitStructure;
//RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOC, ENABLE);
// Enable ADC1 clock
RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1, ENABLE);
ADC_DeInit();
ADC_CommonInitStructure.ADC_Mode = ADC_Mode_Independent;
ADC_CommonInitStructure.ADC_TwoSamplingDelay = ADC_TwoSamplingDelay_6Cycles;
ADC_CommonInitStructure.ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
//.........这里部分代码省略.........