本文整理汇总了C++中STM_EVAL_LEDInit函数的典型用法代码示例。如果您正苦于以下问题:C++ STM_EVAL_LEDInit函数的具体用法?C++ STM_EVAL_LEDInit怎么用?C++ STM_EVAL_LEDInit使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了STM_EVAL_LEDInit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
/**
* @brief Main program.
* @param None
* @retval None
*/
void main(void)
{
#ifdef USART_IrDA_TRANSMIT
JOYState_TypeDef Key = (JOYState_TypeDef)0;
#else /* USART_IrDA_RECEIVE */
uint8_t ReceivedData = 0;
#endif /*USART_IrDA_TRANSMIT*/
/* USART configuration -------------------------------------------*/
USART_Config();
#ifdef USART_IrDA_TRANSMIT
while (1)
{
/* Read Key */
while (Key == JOY_NONE)
{
Key = ReadJoystick();
}
switch (Key)
{
case JOY_UP:
USART_SendData8(EVAL_COM1, JOY_UP);
while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET)
{}
Key = JOY_NONE;
break;
case JOY_DOWN:
USART_SendData8(EVAL_COM1, JOY_DOWN);
while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET)
{}
Key = JOY_NONE;
break;
case JOY_LEFT:
USART_SendData8(EVAL_COM1, JOY_LEFT);
while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET)
{}
Key = JOY_NONE;
break;
case JOY_RIGHT:
USART_SendData8(EVAL_COM1, JOY_RIGHT);
while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET)
{}
Key = JOY_NONE;
break;
case JOY_SEL:
USART_SendData8(EVAL_COM1, JOY_SEL);
while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET)
{}
Key = JOY_NONE;
break;
default:
break;
}
}
#else /* USART_IrDA_RECEIVE */
/* Initialize I/Os in Output Mode for LEDs */
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDInit(LED2);
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED4);
/* Turn on LEDs */
STM_EVAL_LEDOn(LED1);
STM_EVAL_LEDOn(LED2);
STM_EVAL_LEDOn(LED3);
STM_EVAL_LEDOn(LED4);
while (1)
{
/* Wait until a byte is received */
while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_RXNE) == RESET)
{}
/* Read the received byte */
ReceivedData = USART_ReceiveData8(EVAL_COM1);
switch (ReceivedData)
{
/* LED4 toggle */
case JOY_UP:
STM_EVAL_LEDToggle(LED4);
break;
/* LED3 toggle */
case JOY_DOWN:
STM_EVAL_LEDToggle(LED3);
break;
/* LED2 toggle */
case JOY_LEFT:
STM_EVAL_LEDToggle(LED2);
break;
/* LED1 toggle */
case JOY_RIGHT:
STM_EVAL_LEDToggle(LED1);
break;
//.........这里部分代码省略.........
示例2: main
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
RCC_ClocksTypeDef RCC_Clocks;
/* Initialize LEDs and User_Button on STM32F4-Discovery --------------------*/
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);
STM_EVAL_LEDInit(LED4);
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED5);
STM_EVAL_LEDInit(LED6);
/* SysTick end of count event each 10ms */
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
if (STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET)
{
/* Turn on LEDs available on STM32F4-Discovery ---------------------------*/
STM_EVAL_LEDOn(LED4);
STM_EVAL_LEDOn(LED3);
STM_EVAL_LEDOn(LED5);
STM_EVAL_LEDOn(LED6);
if ((*(__IO uint32_t*) TESTRESULT_ADDRESS) == ALLTEST_PASS)
{
TimingDelay = 300;
/* Waiting User Button is pressed or Test Program condition verified */
while ((STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET)&&(TimingDelay != 0x00))
{}
}
else
{
/* Waiting User Button is Released or TimeOut*/
TimingDelay = 300;
while ((STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET)&&(TimingDelay != 0x00))
{}
if (STM_EVAL_PBGetState(BUTTON_USER) == Bit_RESET)
{
TimingDelay = 0x00;
}
}
if (TimingDelay == 0x00)
{
/* Turn off LEDs available on STM32F4-Discovery ------------------------*/
STM_EVAL_LEDOff(LED4);
STM_EVAL_LEDOff(LED3);
STM_EVAL_LEDOff(LED5);
STM_EVAL_LEDOff(LED6);
/* Waiting User Button is released */
while (STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET)
{}
/* Unlocks the FLASH control register access */
FLASH_Unlock();
/* Move discovery kit to detect negative and positive acceleration values
on X, Y and Z axis */
Accelerometer_MEMS_Test();
/* USB Hardware connection */
USB_Test();
/* Audio Hardware connection */
Audio_Test();
/* Microphone MEMS Hardware connection */
Microphone_MEMS_Test();
/* Write PASS code at last word in the flash memory */
FLASH_ProgramWord(TESTRESULT_ADDRESS, ALLTEST_PASS);
while(1)
{
/* Toggle Green LED: signaling the End of the Test program */
STM_EVAL_LEDToggle(LED4);
Delay(10);
}
}
else
{
Demo_Exec();
}
}
else
{
Demo_Exec();
}
}
示例3: HwInit
// ----------------------------------------------------------------------------
void HwInit( void ) {
SystemCoreClockUpdate( );
// Make sure SysTick is running at a 1ms rate.
if ( SysTick_Config( SystemCoreClock / 1000 ) ) {
/* Capture error */
while ( 1 );
}
// SysTick_CLKSourceConfig( SysTick_CLKSource_HCLK_Div8 );
/* Initialize Leds mounted on STM32F4-Discovery board */
STM_EVAL_LEDInit(LED4);
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED5);
STM_EVAL_LEDInit(LED6);
return;
/* Turn on LED4 and LED5 */
STM_EVAL_LEDOn(LED4);
STM_EVAL_LEDOn(LED5);
/* TIM Configuration */
TIM3_Config();
TIM4_Config();
/* -----------------------------------------------------------------------
TIM3 Configuration: generate 4 PWM signals with 4 different duty cycles.
In this example TIM3 input clock (TIM3CLK) is set to 2 * APB1 clock (PCLK1),
since APB1 prescaler is different from 1.
TIM3CLK = 2 * PCLK1
PCLK1 = HCLK / 4
=> TIM3CLK = HCLK / 2 = SystemCoreClock /2
To get TIM3 counter clock at 28 MHz, the prescaler is computed as follows:
Prescaler = (TIM3CLK / TIM3 counter clock) - 1
Prescaler = ((SystemCoreClock /2) /28 MHz) - 1
To get TIM3 output clock at 30 KHz, the period (ARR)) is computed as follows:
ARR = (TIM3 counter clock / TIM3 output clock) - 1
= 665
TIM3 Channel1 duty cycle = (TIM3_CCR1/ TIM3_ARR)* 100 = 50%
TIM3 Channel2 duty cycle = (TIM3_CCR2/ TIM3_ARR)* 100 = 37.5%
TIM3 Channel3 duty cycle = (TIM3_CCR3/ TIM3_ARR)* 100 = 25%
TIM3 Channel4 duty cycle = (TIM3_CCR4/ TIM3_ARR)* 100 = 12.5%
Note:
SystemCoreClock variable holds HCLK frequency and is defined in system_stm32f4xx.c file.
Each time the core clock (HCLK) changes, user had to call SystemCoreClockUpdate()
function to update SystemCoreClock variable value. Otherwise, any configuration
based on this variable will be incorrect.
----------------------------------------------------------------------- */
/* Compute the prescaler value */
PrescalerValue = (uint16_t) ((SystemCoreClock /2) / 28000000) - 1;
/* Time base configuration */
TIM_TimeBaseStructure.TIM_Period = 665;
TIM_TimeBaseStructure.TIM_Prescaler = PrescalerValue;
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseInit( TIM3, &TIM_TimeBaseStructure );
TIM_TimeBaseInit( TIM4, &TIM_TimeBaseStructure );
/* PWM1 Mode configuration: Channel1 */
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1;
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = CCR1_Val;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
TIM_OC1Init( TIM3, &TIM_OCInitStructure );
TIM_OC1Init( TIM4, &TIM_OCInitStructure );
TIM_OC1PreloadConfig( TIM3, TIM_OCPreload_Enable );
TIM_OC1PreloadConfig( TIM4, TIM_OCPreload_Enable );
/* PWM1 Mode configuration: Channel2 */
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = CCR2_Val;
TIM_OC2Init( TIM3, &TIM_OCInitStructure );
TIM_OC2Init( TIM4, &TIM_OCInitStructure );
TIM_OC2PreloadConfig( TIM3, TIM_OCPreload_Enable );
TIM_OC2PreloadConfig( TIM4, TIM_OCPreload_Enable );
/* PWM1 Mode configuration: Channel3 */
TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
TIM_OCInitStructure.TIM_Pulse = CCR3_Val;
TIM_OC3Init( TIM3, &TIM_OCInitStructure );
TIM_OC3Init( TIM4, &TIM_OCInitStructure );
TIM_OC3PreloadConfig( TIM3, TIM_OCPreload_Enable );
TIM_OC3PreloadConfig( TIM4, TIM_OCPreload_Enable );
/* PWM1 Mode configuration: Channel4 */
//.........这里部分代码省略.........
示例4: main
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
uint32_t guessIdx = 0;
int running = 0;
int delay = 0;
RCC_ClocksTypeDef RCC_Clocks;
/* Initialize LEDs and User_Button on STM32F4-Discovery --------------------*/
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI);
STM_EVAL_LEDInit(LED4);
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED5);
STM_EVAL_LEDInit(LED6);
/* SysTick end of count event each 10ms */
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
STM_EVAL_LEDOff(LED4);
STM_EVAL_LEDOn(LED3);
STM_EVAL_LEDOff(LED5);
STM_EVAL_LEDOff(LED6);
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
keyboardInit(&USB_OTG_dev);
Demo_USBConfig();
char guess[7];
strcpy(guess, "400000");
Delay(2000);
while (1) {
if (STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET) {
//crappy debounce routine
TimingDelay = 10;
while ((STM_EVAL_PBGetState(BUTTON_USER) == Bit_SET)&&(TimingDelay != 0x00));
//now change start or stop password attempts
if (running == 0) {
STM_EVAL_LEDOn(LED4);
running = 1;
} else {
STM_EVAL_LEDOff(LED4);
running = 0;
}
}
//mostly non blocking delay to allow stopping with button
if (delay > 0) {
Delay(1000);
delay--;
}
if (running != 0 && delay == 0) {
Delay(200);
keyboardWrite(KEY_BACKSPACE);
keyboardWrite(KEY_BACKSPACE);
keyboardWrite(KEY_BACKSPACE);
keyboardWrite(KEY_BACKSPACE);
STM_EVAL_LEDToggle(LED6);
keyboardPutString(guess);
keyboardWrite(KEY_RETURN);
Delay(200);
keyboardWrite(KEY_RETURN);
nextPermutation(guess, "123", 1);
if ((++guessIdx % 5) == 0) {
//try to email every 5 guesses
keyboardReleaseAll();
keyboardPress(KEY_LEFT_GUI);
keyboardPress('g');
Delay(50);
keyboardReleaseAll();
keyboardPutString("[email protected]"); //leave the preceding 'c' that is the gmail compose shortcut
keyboardWrite(KEY_TAB);
keyboardPutString(guess);
keyboardWrite(KEY_TAB);
keyboardPutString(guess);
keyboardWrite(KEY_TAB);
keyboardWrite(KEY_TAB);
keyboardWrite(KEY_RETURN);
STM_EVAL_LEDOff(LED5);
delay = 30;
}
}
}
}
示例5: StopMode_Measure
//.........这里部分代码省略.........
/* Wait till LSI is ready */
while(RCC_GetFlagStatus(RCC_FLAG_LSIRDY) == RESET)
{
}
/* Select the RTC Clock Source */
RCC_RTCCLKConfig(RCC_RTCCLKSource_LSI);
/* Enable the RTC Clock */
RCC_RTCCLKCmd(ENABLE);
/* Wait for RTC APB registers synchronisation */
RTC_WaitForSynchro();
/* Configure all GPIO as analog to reduce current consumption on non used IOs */
/* Enable GPIOs clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC |
RCC_AHBPeriph_GPIOD | RCC_AHBPeriph_GPIOF , ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_Init(GPIOB, &GPIO_InitStructure);
/* Disable GPIOs clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA |RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC |
RCC_AHBPeriph_GPIOD | RCC_AHBPeriph_GPIOF, DISABLE);
RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
RTC_InitStructure.RTC_AsynchPrediv = 0x7F;
RTC_InitStructure.RTC_SynchPrediv = 0x0138;
if (RTC_Init(&RTC_InitStructure) == ERROR)
{
while(1);
}
/* EXTI configuration */
EXTI_ClearITPendingBit(EXTI_Line17);
EXTI_InitStructure.EXTI_Line = EXTI_Line17;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);
/* NVIC configuration */
NVIC_InitStructure.NVIC_IRQChannel = RTC_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Set the alarm X+5s */
RTC_AlarmStructure.RTC_AlarmTime.RTC_H12 = RTC_H12_AM;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Hours = 0x01;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Minutes = 0x00;
RTC_AlarmStructure.RTC_AlarmTime.RTC_Seconds = 0x05;
RTC_AlarmStructure.RTC_AlarmDateWeekDay = 0x31;
RTC_AlarmStructure.RTC_AlarmDateWeekDaySel = RTC_AlarmDateWeekDaySel_Date;
RTC_AlarmStructure.RTC_AlarmMask = RTC_AlarmMask_DateWeekDay;
RTC_SetAlarm(RTC_Format_BCD, RTC_Alarm_A, &RTC_AlarmStructure);
/* Enable the alarm */
RTC_AlarmCmd(RTC_Alarm_A, ENABLE);
/* Enable the RTC Alarm A interrupt */
RTC_ITConfig(RTC_IT_ALRA, ENABLE);
/* Set the time to 01h 00mn 00s AM */
RTC_TimeStructure.RTC_H12 = RTC_H12_AM;
RTC_TimeStructure.RTC_Hours = 0x01;
RTC_TimeStructure.RTC_Minutes = 0x00;
RTC_TimeStructure.RTC_Seconds = 0x00;
RTC_SetTime(RTC_Format_BCD, &RTC_TimeStructure);
/* Clear the Alarm A Pending Bit */
RTC_ClearITPendingBit(RTC_IT_ALRA);
/* Enter Stop Mode */
PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
/* Initialize LED4 on STM320518-EVAL board */
STM_EVAL_LEDInit(LED4);
/* Infinite loop */
while (1)
{
/* Toggle The LED4 */
STM_EVAL_LEDToggle(LED4);
/* Inserted Delay */
for(index = 0; index < 0x5FFFF; index++);
}
}
示例6: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
files (startup_stm32f40xx.s/startup_stm32f427x.s) before to branch to
application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f4xx.c file
*/
/* Configure the external interrupt "WAKEUP" and "TAMPER" buttons */
STM_EVAL_PBInit(BUTTON_TAMPER , BUTTON_MODE_EXTI);
STM_EVAL_PBInit(BUTTON_WAKEUP , BUTTON_MODE_EXTI);
/* Initialize LEDs and LCD available on EVAL board */
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDInit(LED2);
/* Initialize the LCD */
LCD_Init();
LCD_Clear(LCD_COLOR_WHITE);
/* Set the Back Color */
LCD_SetBackColor(LCD_COLOR_BLUE);
/* Set the Text Color */
LCD_SetTextColor(LCD_COLOR_WHITE);
LCD_DisplayStringLine(LCD_LINE_0,(uint8_t *) " TimeStamp Example " );
LCD_SetFont(&Font12x12);
if (RTC_ReadBackupRegister(RTC_BKP_DR0) != 0x32F2)
{
/* RTC configuration */
RTC_Config();
/* Configure the time&date register */
RTC_TimeRegulate();
/* Display the Date and Time */
RTC_DateShow();
RTC_TimeShow();
}
else
{
/* Check if the Power On Reset flag is set */
if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET)
{
/* Set the Back Color */
LCD_SetBackColor(LCD_COLOR_WHITE);
/* Set the Text Color */
LCD_SetTextColor(LCD_COLOR_GREEN);
LCD_DisplayStringLine(LCD_LINE_2,(uint8_t *) "Power On Reset occurred " );
}
/* Check if the Pin Reset flag is set */
else if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET)
{
/* Set the Back Color */
LCD_SetBackColor(LCD_COLOR_WHITE);
/* Set the Text Color */
LCD_SetTextColor(LCD_COLOR_GREEN);
LCD_DisplayStringLine(LCD_LINE_2,(uint8_t *) "External Reset occurred " );
}
/* Set the Back Color */
LCD_SetBackColor(LCD_COLOR_WHITE);
/* Set the Text Color */
LCD_SetTextColor(LCD_COLOR_GREEN);
LCD_DisplayStringLine(LCD_LINE_3,(uint8_t *) "No need to configure RTC " );
/* Enable the PWR clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
/* Allow access to RTC */
PWR_BackupAccessCmd(ENABLE);
/* Wait for RTC APB registers synchronisation */
RTC_WaitForSynchro();
/* Clear the RTC Alarm Flag */
RTC_ClearFlag(RTC_FLAG_ALRAF);
/* Clear the EXTI Line 17 Pending bit (Connected internally to RTC Alarm) */
EXTI_ClearITPendingBit(EXTI_Line17);
/* Display the RTC Time/Date and TimeStamp Time/Date */
RTC_DateShow();
RTC_TimeShow();
}
//.........这里部分代码省略.........
示例7: main
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f2xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f2xx.c file
*/
/* Initialize LEDs and Key Button mounted on STM322xG-EVAL board */
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDInit(LED2);
STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO);
/* Test if Key push-button on STM322xG-EVAL board is pressed */
if (STM_EVAL_PBGetState(BUTTON_KEY) == 0x00)
{ /* Key is pressed */
/* Enable GPIOA and GPIOB clocks */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB , ENABLE);
/* Turn on LED1 */
STM_EVAL_LEDOn(LED1);
/* Configure PA.13 (JTMS/SWDIO), PA.14 (JTCK/SWCLK) and PA.15 (JTDI) as
output push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure PB.03 (JTDO) and PB.04 (JTRST) as output push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3 | GPIO_Pin_4;
GPIO_Init(GPIOB, &GPIO_InitStructure);
while (1)
{
/* Toggle JTMS/SWDAT pin */
GPIO_WriteBit(GPIOA, GPIO_Pin_13, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_13)));
/* Insert delay */
Delay(0x5FFFF);
/* Toggle JTCK/SWCLK pin */
GPIO_WriteBit(GPIOA, GPIO_Pin_14, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_14)));
/* Insert delay */
Delay(0x5FFFF);
/* Toggle JTDI pin */
GPIO_WriteBit(GPIOA, GPIO_Pin_15, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_15)));
/* Insert delay */
Delay(0x5FFFF);
/* Toggle JTDO pin */
GPIO_WriteBit(GPIOB, GPIO_Pin_3, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOB, GPIO_Pin_3)));
/* Insert delay */
Delay(0x5FFFF);
/* Toggle JTRST pin */
GPIO_WriteBit(GPIOB, GPIO_Pin_4, (BitAction)(1 - GPIO_ReadOutputDataBit(GPIOB, GPIO_Pin_4)));
/* Insert delay */
Delay(0x5FFFF);
}
}
else
{
/* Turn on LED2 */
STM_EVAL_LEDOn(LED2);
while (1)
{
}
}
}
示例8: STM_EVAL_LEDInit
Led::Led(void)
{
STM_EVAL_LEDInit(LED3);
}
示例9: init_hw
/*
* init_hw
* Initialises hardware; pins, LEDs, sensors, etc.
*/
void init_hw(void)
{
/* Vars */
GPIO_InitTypeDef GPIO_Init_PD8, GPIO_Init_PD9;
USART_InitTypeDef USART3_Init;
int i = 0;
/* Configure ticks to equal milliseconds (for delays) */
if (SysTick_Config(SystemCoreClock / 1000)) {
/* Catch errors using infinite loop */
while (1);
}
/* Easy stuff first; enable LEDs */
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED4);
STM_EVAL_LEDInit(LED5);
STM_EVAL_LEDInit(LED6);
STM_EVAL_LEDInit(LED7);
STM_EVAL_LEDInit(LED8);
STM_EVAL_LEDInit(LED9);
STM_EVAL_LEDInit(LED10);
/* Enable USART3 clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
/* Enable clock on GPIOD pins (for USART3) */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOD, ENABLE);
/* Configure PD8's alternate function.
* GPIO_AF_7 represents function USART3. */
GPIO_PinAFConfig(GPIOD, GPIO_PinSource8, GPIO_AF_7);
/* Enable USART3 transmit on pin PD8 */
GPIO_Init_PD8.GPIO_Pin = GPIO_Pin_8;
GPIO_Init_PD8.GPIO_Mode = GPIO_Mode_AF;
GPIO_Init_PD8.GPIO_OType = GPIO_OType_PP;
GPIO_Init_PD8.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init_PD8.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOD, &GPIO_Init_PD8);
/* Configure PD9's alternate function.
* GPIO_AF_7 represents function USART3. */
GPIO_PinAFConfig(GPIOD, GPIO_PinSource9, GPIO_AF_7);
/* Enable USART3 receive on pin PD9 */
GPIO_Init_PD9.GPIO_Pin = GPIO_Pin_9;
GPIO_Init_PD9.GPIO_Mode = GPIO_Mode_AF;
GPIO_Init_PD9.GPIO_OType = GPIO_OType_PP;
GPIO_Init_PD9.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init_PD9.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_Init(GPIOD, &GPIO_Init_PD9);
/* Configure USART3 */
USART3_Init.USART_BaudRate = 1000000; // this is auto'd later
USART3_Init.USART_WordLength = USART_WordLength_8b;
USART3_Init.USART_StopBits = USART_StopBits_1;
USART3_Init.USART_Parity = USART_Parity_No;
USART3_Init.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
USART3_Init.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
/* Initialise and enable USART3 */
USART_Init(USART3, &USART3_Init);
USART_Cmd(USART3, ENABLE);
/* Enable and configure automatic baud rate */
USART_AutoBaudRateCmd(USART3, ENABLE);
USART_AutoBaudRateConfig(USART3, USART_AutoBaudRate_FallingEdge);
/* Enable user button */
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
/* Turn the LEDs on */
STM_EVAL_LEDOn(LED3);
STM_EVAL_LEDOn(LED4);
STM_EVAL_LEDOn(LED5);
STM_EVAL_LEDOn(LED6);
STM_EVAL_LEDOn(LED7);
STM_EVAL_LEDOn(LED8);
STM_EVAL_LEDOn(LED9);
STM_EVAL_LEDOn(LED10);
/* Flash 'em a bit, shows something's happening */
for (i = 0; i < 3; i++) {
wait(500);
STM_EVAL_LEDToggle(LED3);
STM_EVAL_LEDToggle(LED4);
STM_EVAL_LEDToggle(LED5);
STM_EVAL_LEDToggle(LED6);
STM_EVAL_LEDToggle(LED7);
STM_EVAL_LEDToggle(LED8);
STM_EVAL_LEDToggle(LED9);
STM_EVAL_LEDToggle(LED10);
}
}
示例10: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32l1xx_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32l1xx.c file
*/
/* Initialize the LCD */
STM32L152D_LCD_Init();
/* Initialize LEDs available on STM32L15X-EVAL board ************************/
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDInit(LED2);
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED4);
/* Enable AES AHB clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_AES, ENABLE);
/*============================================================================
Encryption mode
===========================================================================*/
#if defined AES_ECB
AES_ECB_Encrypt(EncryptionKey, PlainText, AES_TEXT_SIZE, CipherText);
#elif defined AES_CBC
AES_CBC_Encrypt(EncryptionKey, InitVector, PlainText, AES_TEXT_SIZE, CipherText);
#else /* CTR Mode */
AES_CTR_Encrypt(EncryptionKey, InitVector, PlainText, AES_TEXT_SIZE, CipherText);
#endif
/* Clear the LCD */
LCD_Clear(LCD_COLOR_WHITE);
/* Set the Back Color */
LCD_SetBackColor(LCD_COLOR_BLUE);
/* Read the CipherText and check content correctness */
#if defined AES_ECB
if(Buffercmp(ExpectedCipherText, CipherText, AES_TEXT_SIZE) != ERROR)
#elif defined AES_CBC
if(Buffercmp(ExpectedCipherText_CBC, CipherText, AES_TEXT_SIZE) != ERROR)
#else /* CTR */
if(Buffercmp(ExpectedCipherText_CTR, CipherText, AES_TEXT_SIZE) != ERROR)
#endif
{
/* OK */
/* Turn on LED1 */
STM_EVAL_LEDOn(LED1);
/* Set the Text Color */
LCD_SetTextColor(LCD_COLOR_GREEN);
LCD_DisplayStringLine(LCD_LINE_2, " Success ");
}
else
{
/* KO */
/* Turn on LED2 */
STM_EVAL_LEDOn(LED2);
/* Set the Text Color */
LCD_SetTextColor(LCD_COLOR_RED);
LCD_DisplayStringLine(LCD_LINE_2, " Failed ");
}
LCD_DisplayStringLine(LCD_LINE_1, " Encryption ");
#if defined AES_ECB
LCD_DisplayStringLine(LCD_LINE_0, " ECB Mode ");
#elif defined AES_CBC
LCD_DisplayStringLine(LCD_LINE_0, " CBC Mode ");
#else /* CTR */
LCD_DisplayStringLine(LCD_LINE_0, " CTR Mode ");
#endif
/*============================================================================
Decryption mode
===========================================================================*/
#if defined AES_ECB
AES_ECB_Decrypt(EncryptionKey, CipherText, AES_TEXT_SIZE, ComputedPlainText);
#elif defined AES_CBC
AES_CBC_Decrypt(EncryptionKey, InitVector, CipherText, AES_TEXT_SIZE, ComputedPlainText);
#else /* CTR Mode */
AES_CTR_Decrypt(EncryptionKey, InitVector, CipherText, AES_TEXT_SIZE, ComputedPlainText);
#endif
/* Read the ComputedPlainText and check content correctness */
if(Buffercmp(PlainText, ComputedPlainText, AES_TEXT_SIZE) != ERROR)
{
/* OK */
/* Turn on LED3 */
STM_EVAL_LEDOn(LED3);
/* Set the Text Color */
LCD_SetTextColor(LCD_COLOR_GREEN);
LCD_DisplayStringLine(LCD_LINE_6, " Success ");
}
//.........这里部分代码省略.........
示例11: main
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32f0xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32f0xx.c file
*/
/* USARTx configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Hardware flow control disabled (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_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
STM_EVAL_COMInit(COM1, &USART_InitStructure);
/* GPIOC Periph clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
/* Output a message on Hyperterminal using printf function */
printf("\n\r *********************** RTC Time Stamp Example ***********************\n\r");
if (RTC_ReadBackupRegister(RTC_BKP_DR0) != 0x32F2)
{
/* RTC configuration */
RTC_Config();
/* Configure the RTC data register and RTC prescaler */
RTC_InitStructure.RTC_AsynchPrediv = AsynchPrediv;
RTC_InitStructure.RTC_SynchPrediv = SynchPrediv;
RTC_InitStructure.RTC_HourFormat = RTC_HourFormat_24;
/* Check on RTC init */
if (RTC_Init(&RTC_InitStructure) == ERROR)
{
printf("\n\r /!\\***** RTC Prescaler Config failed ********/!\\ \n\r");
}
/* Configure the time register */
RTC_TimeRegulate();
}
else
{
/* Check if the Power On Reset flag is set */
if (RCC_GetFlagStatus(RCC_FLAG_PORRST) != RESET)
{
printf("\r\n Power On Reset occurred....\n\r");
}
/* Check if the Pin Reset flag is set */
else if (RCC_GetFlagStatus(RCC_FLAG_PINRST) != RESET)
{
printf("\r\n External Reset occurred....\n\r");
}
printf("\r\n No need to configure RTC....\n\r");
/* Enable the PWR clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
/* Allow access to RTC */
PWR_BackupAccessCmd(ENABLE);
/* Wait for RTC APB registers synchronisation */
RTC_WaitForSynchro();
/* Clear the RTC Alarm Flag */
RTC_ClearFlag(RTC_FLAG_ALRAF);
/* Clear the EXTI Line 17 Pending bit (Connected internally to RTC Alarm) */
EXTI_ClearITPendingBit(EXTI_Line17);
/* Display the RTC Time/Date and TimeStamp Time/Date */
RTC_TimeShow();
RTC_DateShow();
RTC_TimeStampShow();
}
/* Configure the external interrupt "TAMPER" and "Joystick SEL" buttons */
STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE_EXTI);
STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_EXTI);
STM_EVAL_PBInit(BUTTON_SEL, BUTTON_MODE_EXTI);
/* Configure LED1 */
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDOn(LED1);
//.........这里部分代码省略.........
示例12: main
/**
* @brief Main program.
* @param None
* @retval None
*/
int main(void)
{
/* GPIOE Periph clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOE, ENABLE);
/* Configure PE8, PE9, and PE10 in input pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/*
* GPIO_Pin_8 = CW
* GPIO_Pin_9 = CCW
* GPIO_Pin_10 = Button
*/
/* Configure PE7 in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOE, &GPIO_InitStructure);
/*
* GPIO_Pin_7 = VDD
*/
//Set Pin E7 to VDD
GPIOE->BSRR = 0x0080;
/* Initialize Leds mounted on STM32F3-Discovery EVAL board */
STM_EVAL_LEDInit(LED6);
STM_EVAL_LEDInit(LED7);
/* Turn on LED3, LED4, LED5 and LED6 */
STM_EVAL_LEDOff(LED6);
STM_EVAL_LEDOff(LED7);
while (1)
{
CW = GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_8);
CCW = GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_9);
//Want to only accept data if one is zero and other goes from low to high
//Change occurs when value != old value
//Old value should be equal to 0, current value should be high ( greater than 0 )
if( CW > 0 )
{
while( CW > 0 )
{
CW = GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_8);
CCW = GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_9);
if( CCW > 0 )
{
if( RotaryPosition < 10 )
{
RotaryPosition++;
}
STM_EVAL_LEDToggle(LED7);
}
}
}
if( CCW > 0 )
{
while( CCW > 0 )
{
CW = GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_8);
CCW = GPIO_ReadInputDataBit(GPIOE, GPIO_Pin_9);
if( CW > 0 )
{
if( RotaryPosition > 0 )
{
RotaryPosition--;
//.........这里部分代码省略.........
示例13: main
int main(void)
{
//uint8_t Rx1_Buffer[BUFFER_SIZE1];
volatile uint16_t NumDataRead = 0;
volatile uint16_t symbol;
uint8_t command_buffer[10]= {0xe2,0xeb,0x81,120,0xc6,0xaf,0x88,0xb0,0x00,0x10};
uint32_t xtal_value;
/*
0: 0xe2 - 11100010 - System Reset
1: 0xeb - 11101011 - Set LCD BIAS ratio [b1:b0]
2: 0x81 - 10000001 - Set VBIAS potentiometer
3: 0x50 - 01010000 - VBIAS potentiometer value
4: 0xc6 - 11000110 - Set LCD Mapping Control [b2:b1]
5: 0xaf - 10101111 - Set display ENABLE [b0]
6: 0x89 - 10001001 - Set RAM adress Control [b2:b0]
7: 0xb0 - 10110000 - Set Page Adress [b3:b0]
8: 0x00 - 00000000 - Set Column Adress LSB [b3:b0]
9: 0x10 - 00010000 - Set Column Adress MSB [b3:b0]
*/
uint32_t decimal[8];
//uint8_t string0[]="Display Works Fine";
//uint8_t tune.tune_freq_vis[]="14000000"; /*Start Frequency*/
//uint8_t string2[]="FREQUENCY";
//uint8_t string3[]="HAM RADIO BAND";
uint8_t string4[]="20m USB 2800Hz x100";/*BAND MODE FILTER GAIN*/
//uint8_t string5[]="MODE SSB USB";
//uint8_t string6[]="GAIN 1000";
uint8_t string7[]="PRE:Off ATT:20 AGC:S";
uint8_t data_buffer[132];
uint8_t data_buffer1[132];
uint8_t data_buffer2[132];
uint8_t data_buffer3[132];
uint8_t si570_buf[11];
uint32_t bit_order;
uint8_t current_pointer;
uint8_t k, n, sp, lzs_flag, symb_width, enc1_pulse_ccw, enc1_pulse_cw,enc2_pulse_ccw, enc2_pulse_cw, show_it;
uint8_t option_select, sub_option_select;
uint8_t n1;
uint8_t hs_div_code;
uint32_t i,j/*,noise_filter_button*/;
uint8_t display_menu;
uint8_t offcet_x;
extern menu_struct_t menu[MAX_MENU_QTY];
extern band_struct_t band_menu[MAX_BAND_QTY];
extern mode_struct_t mode_menu[MAX_MODE_QTY];
extern filter_struct_t filter_menu[MAX_FILTER_QTY];
extern gain_struct_t gain_menu;
extern tune_struct_t tune;
RCC_ClocksTypeDef RCC_Clocks;
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency / 100); /* SysTick end of count event each 10ms */
//if (FLASH_OB_GetRDP()!=SET)
//{
// FLASH_OB_Unlock(); /*enable the FLASH option control register access*/
// FLASH_OB_RDPConfig(OB_RDP_Level_1); /*SET RDP=1*/
// FLASH_OB_Launch(); /*launch the Option Bytes programming process*/
// FLASH_OB_Lock(); /*disable the FLASH option control register*/
//}
/* Initialize LEDs and LCD available on STM324xG-EVAL board *****************/
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED4);
STM_EVAL_LEDInit(LED5);
STM_EVAL_LEDInit(LED6);
/* Initialize user button STM324xG-EVAL board *****************/
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
STM_EVAL_ControlInit(CODEC_RESET);
BOARD_GPIO_Init(); /*encoder input init*/
/* Turn on LEDs available on STM324xG-EVAL **********************************/
STM_EVAL_LEDOff(LED3);
STM_EVAL_LEDOff(LED4);
STM_EVAL_LEDOff(LED5);
STM_EVAL_LEDOff(LED6);
STM_EVAL_ControlOn(CODEC_RESET);
Delay (300);
STM_EVAL_ControlOff(CODEC_RESET);
xtal_value=(uint32_t)114197425;/*0x6cfd9c8*/
freq_code_old=0;
NumDataRead = 1;
/* Initialize the I2C EEPROM driver ----------------------------------------*/
sEE_Init();
/* Initialize the CODEC driver*/
EVAL_AUDIO_SetAudioInterface(AUDIO_INTERFACE_I2S);
EVAL_AUDIO_Init(OUTPUT_DEVICE_HEADPHONE, 255, I2S_AudioFreq_48k);
//.........这里部分代码省略.........
示例14: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
file (startup_stm32l1xx_xx.s) before to branch to application main.
To reconfigure the default setting of SystemInit() function, refer to
system_stm32l1xx.c file
*/
/* Set the vector table address */
#if defined(BOOT_FROM_BANK1)
/* Set the vector table to the Bank1 start address */
NVIC_SetVectorTable(NVIC_VectTab_FLASH, BANK1_START_ADDRESS);
#elif defined(BOOT_FROM_BANK2)
/* Set the vector table to the Bank1 start address */
NVIC_SetVectorTable(NVIC_VectTab_FLASH, BANK2_START_ADDRESS);
#endif /* BOOT_FROM_BANK1 */
/* Initialize LEDs, Buttons and LCD on STM32L152D-EVAL board ****************/
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDInit(LED2);
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED4);
/* Save the first BANK1 page */
FLASH_SaveBANK1();
/* Save the first BANK2 page */
FLASH_SaveBANK2();
/* SysTick end of count event each 10ms */
RCC_GetClocksFreq(&RCC_Clocks);
SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
/* Configure the Joystick buttons */
STM_EVAL_PBInit(BUTTON_UP, BUTTON_MODE_GPIO);
STM_EVAL_PBInit(BUTTON_SEL, BUTTON_MODE_GPIO);
STM_EVAL_PBInit(BUTTON_DOWN, BUTTON_MODE_GPIO);
STM_EVAL_PBInit(BUTTON_RIGHT, BUTTON_MODE_GPIO);
STM_EVAL_PBInit(BUTTON_LEFT, BUTTON_MODE_GPIO);
/* Initialize the LCD */
STM32L152D_LCD_Init();
/* Display message on STM32L152D-EVAL LCD ************************************/
/* Clear the LCD */
LCD_Clear(LCD_COLOR_WHITE);
/* Set the LCD Back Color */
#if defined(BOOT_FROM_BANK1)
LCD_SetBackColor(LCD_COLOR_BLUE);
#elif defined(BOOT_FROM_BANK2)
LCD_SetBackColor(LCD_COLOR_RED);
#endif /* BOOT_FROM_BANK1 */
/* Set the LCD Text Color */
LCD_SetTextColor(LCD_COLOR_WHITE);
LCD_DisplayStringLine(LCD_LINE_0, MESSAGE1);
LCD_DisplayStringLine(LCD_LINE_1, MESSAGE2);
LCD_DisplayStringLine(LCD_LINE_2, MESSAGE3);
LCD_DisplayStringLine(LCD_LINE_4, MESSAGE4);
LCD_SetFont(&Font12x12);
LCD_SetTextColor(LCD_COLOR_GREEN);
LCD_DisplayStringLine(LCD_LINE_10, MESSAGE5);
LCD_DisplayStringLine(LCD_LINE_11, MESSAGE6);
LCD_SetTextColor(LCD_COLOR_WHITE);
LCD_DisplayStringLine(LCD_LINE_12, MESSAGE7);
LCD_DisplayStringLine(LCD_LINE_13, MESSAGE8);
LCD_SetTextColor(LCD_COLOR_GREEN);
LCD_DisplayStringLine(LCD_LINE_14, MESSAGE9);
LCD_DisplayStringLine(LCD_LINE_15, MESSAGE10);
LCD_SetTextColor(LCD_COLOR_WHITE);
LCD_DisplayStringLine(LCD_LINE_16, MESSAGE11);
LCD_DisplayStringLine(LCD_LINE_17, MESSAGE12);
LCD_SetTextColor(LCD_COLOR_GREEN);
LCD_DisplayStringLine(LCD_LINE_18, MESSAGE13);
LCD_DisplayStringLine(LCD_LINE_19, MESSAGE14);
LCD_SetTextColor(LCD_COLOR_WHITE);
LCD_SetFont(&Font16x24);
/* Turn on leds available on STM32L152D-EVAL ************************************/
STM_EVAL_LEDOn(LED1);
STM_EVAL_LEDOn(LED2);
STM_EVAL_LEDOn(LED3);
STM_EVAL_LEDOn(LED4);
/* Infinite loop */
while (1)
{
/*--- If Joystick DOWN button is pushed, reset BFB2 bit to enable boot from Bank2
(active after next reset, w/ Boot pins set in Boot from Flash memory position ---*/
if (STM_EVAL_PBGetState(BUTTON_DOWN) == 0)
{
/* Reset BFB2 bit to enable boot from Flash Bank2 */
FLASH_Unlock();
//.........这里部分代码省略.........
示例15: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/*!< At this stage the microcontroller clock setting is already configured,
this is done through SystemInit() function which is called from startup
files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/startup_stm32f429_439xx.s)
before to branch to application main.
*/
/* Initialize LEDs mounted on EVAL board */
STM_EVAL_LEDInit(LED1);
STM_EVAL_LEDInit(LED2);
/* Initialize the SPI FLASH driver */
sFLASH_Init();
/* Get SPI Flash ID */
FlashID = sFLASH_ReadID();
/* Check the SPI Flash ID */
if (FlashID == sFLASH_M25P64_ID)
{
/* OK: Turn on LD1 */
STM_EVAL_LEDOn(LED1);
/* Perform a write in the Flash followed by a read of the written data */
/* Erase SPI FLASH Sector to write on */
sFLASH_EraseSector(FLASH_SECTOR_TO_ERASE);
/* Write Tx_Buffer data to SPI FLASH memory */
sFLASH_WriteBuffer(Tx_Buffer, FLASH_WRITE_ADDRESS, BufferSize);
/* Read data from SPI FLASH memory */
sFLASH_ReadBuffer(Rx_Buffer, FLASH_READ_ADDRESS, BufferSize);
/* Check the correctness of written dada */
TransferStatus1 = Buffercmp(Tx_Buffer, Rx_Buffer, BufferSize);
/* TransferStatus1 = PASSED, if the transmitted and received data by SPI1
are the same */
/* TransferStatus1 = FAILED, if the transmitted and received data by SPI1
are different */
/* Perform an erase in the Flash followed by a read of the written data */
/* Erase SPI FLASH Sector to write on */
sFLASH_EraseSector(FLASH_SECTOR_TO_ERASE);
/* Read data from SPI FLASH memory */
sFLASH_ReadBuffer(Rx_Buffer, FLASH_READ_ADDRESS, BufferSize);
/* Check the correctness of erasing operation dada */
for (Index = 0; Index < BufferSize; Index++)
{
if (Rx_Buffer[Index] != 0xFF)
{
TransferStatus2 = FAILED;
}
}
/* TransferStatus2 = PASSED, if the specified sector part is erased */
/* TransferStatus2 = FAILED, if the specified sector part is not well erased */
}
else
{
/* Error: Turn on LD2 */
STM_EVAL_LEDOn(LED2);
}
while (1)
{}
}