Skip to content

Commit

Permalink
Error demo
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKK committed Apr 21, 2014
1 parent dfe0152 commit b70ed8f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CORTEX_M4F_STM32_DISCOVERY/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
#define configUSE_IDLE_HOOK 0
#define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( SystemCoreClock )
#define configTICK_RATE_HZ ( ( TickType_t ) 100000 )
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
#define configMAX_PRIORITIES ( 5 )
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 130 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 75 * 1024 ) )
Expand Down
58 changes: 57 additions & 1 deletion CORTEX_M4F_STM32_DISCOVERY/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,65 @@
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private function prototypes ------ -----------------------------------------*/

void EXTILine0_Config(void)
{
EXTI_InitTypeDef EXTI_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
NVIC_InitTypeDef NVIC_InitStructure;

/* Enable GPIOA clock */
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOG, ENABLE);
/* Enable SYSCFG clock */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

/* Configure PA0 pin as input floating */
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;
GPIO_Init(GPIOA, &GPIO_InitStructure);

/* Connect EXTI Line0 to PA0 pin */
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOG, EXTI_PinSource13);

/* Configure EXTI Line0 */
EXTI_InitStructure.EXTI_Line = EXTI_Line0;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_Init(&EXTI_InitStructure);

/* Enable and set EXTI Line0 Interrupt to the lowest priority */
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x0F;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}

void Init(void)
{
STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_GPIO);
STM_EVAL_LEDInit(LED3);
STM_EVAL_LEDInit(LED4);

EXTILine0_Config();
}

static void SignalTask(void* pvParameters)
{
while (1){
STM_EVAL_LEDOn(LED3);
}
}

/* Main Function -------------------------------------------------------------*/
int main( void )
{
Init();

xTaskCreate(SignalTask, (signed char*)"SignalTask", 128, NULL, tskIDLE_PRIORITY + 1, NULL);

vTaskStartScheduler();
}
14 changes: 4 additions & 10 deletions CORTEX_M4F_STM32_DISCOVERY/stm32f4xx_it.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,11 @@ extern uint32_t i;

void EXTI0_IRQHandler(void)
{
if( EXTI_GetITStatus( EXTI_Line0 ) != RESET ){
STM_EVAL_LEDToggle( LED4 );

int j,k;
for(j=0;j<10000;j++){
for(k=0;k<1000;k++){}
}

// itoa( i, 10 );
if (EXTI_GetITStatus(EXTI_Line0) != RESET){
STM_EVAL_LEDOff(LED3);
}
EXTI_ClearITPendingBit( EXTI_Line0 );

EXTI_ClearITPendingBit(EXTI_Line0);
}
/******************************************************************************/
/* STM32F4xx Peripherals Interrupt Handlers */
Expand Down

0 comments on commit b70ed8f

Please sign in to comment.