Exemplo n.º 1
0
/**
* @brief  This function handles CAN request.
* @param  None
* @retval None
*/
void CEC_CAN_IRQHandler(void)
{
  if (CAN_MessagePending(CANx, CAN_FIFO0) != 0) 
  {
    /* Set the LCD Back Color */
    LCD_SetBackColor(Green);
    /* Set the LCD Text Color */
    LCD_SetTextColor(Black);
    /* Displays MESSAGE1 on line 1 */
    LCD_DisplayStringLine(LINE(6), (uint8_t *)MESSAGE1);
    
    CAN_Receive(CANx, CAN_FIFO0, &RxMessage);
    LED_Display(RxMessage.Data[0]);
    KeyNumber = RxMessage.Data[0];
  }
  
  if (CAN_MessagePending(CANx, CAN_FIFO1) != 0) 
  {
    /* Set the LCD Back Color */
    LCD_SetBackColor(Cyan);
    
    /* Set the LCD Text Color */
    LCD_SetTextColor(Black);
    
    /* Displays MESSAGE1 on line 1 */
    LCD_DisplayStringLine(LINE(6), (uint8_t *)MESSAGE2);
    CAN_Receive(CANx, CAN_FIFO1, &RxMessage1);
    LED_Display(RxMessage1.Data[0]);
    KeyNumber = RxMessage1.Data[0];
  }

}
Exemplo n.º 2
0
void CAN2_RX0_IRQHandler(void)
{
  CAN_Receive(CAN2, CAN_FIFO0, &RxMessage);

  if ((RxMessage.StdId == 0x321)&&(RxMessage.IDE == CAN_ID_STD)&&(RxMessage.DLC == 1)&&(RxMessage.Data[0] == 0x55))
  {
    /* Turn On LED4 */
    LED_Display(0x04); /* OK */
  }
  else
  {
    /* Turn Off LED4 */
    LED_Display(0x06); /* Error */
  }
}
Exemplo n.º 3
0
void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
{
unsigned portCHAR ucBit;

	if( uxLED >= partstMAX_OUTPUT_LED )
	{
		return;
	}

	ucBit = ( ( unsigned portCHAR ) 1 ) << uxLED;

	vTaskSuspendAll();
	{
		if( xValue == pdTRUE )
		{
		  ucCurrentOutputValue |= ucBit;
		}
		else
		{
		  ucCurrentOutputValue &= ~ucBit;
		}

		LED_Display(ucCurrentOutputValue);
	}
	xTaskResumeAll();
}
Exemplo n.º 4
0
/**
  * @brief  This function handles CAN1 RX0 request.
  * @param  None
  * @retval None
  */
void CAN1_RX0_IRQHandler(void)
{
  CAN_Receive(CAN1, CAN_FIFO0, &RxMessage);
  
  if ((RxMessage.StdId == 0x321)&&(RxMessage.IDE == CAN_ID_STD) && (RxMessage.DLC == 1))
  {
    LED_Display(RxMessage.Data[0]);
    ubKeyNumber = RxMessage.Data[0];
  }
}
Exemplo n.º 5
0
/**
  * @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_stm32f10x_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f10x.c file
     */     
       
  /* NVIC configuration */
  NVIC_Config();

  /* Configures LED 1..4 */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);
  
  /* Configure Push button key */
  STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO); 
   
  /* CAN configuration */
  CAN_Config();
  
  CAN_ITConfig(CANx, CAN_IT_FMP0, ENABLE);

  /* turn off all leds*/
  STM_EVAL_LEDOff(LED1);
  STM_EVAL_LEDOff(LED2);
  STM_EVAL_LEDOff(LED3);
  STM_EVAL_LEDOff(LED4);
 
  /* Infinite loop */
  while(1)
  {
    while(STM_EVAL_PBGetState(BUTTON_KEY) == KEY_PRESSED)
    {
      if(KeyNumber == 0x4) 
      {
        KeyNumber = 0x00;
      }
      else
      {
        LED_Display(++KeyNumber);
        TxMessage.Data[0] = KeyNumber;
        CAN_Transmit(CANx, &TxMessage);
        Delay();
        
        while(STM_EVAL_PBGetState(BUTTON_KEY) != KEY_NOT_PRESSED)
        {
        }
      }
    }
  }
}
Exemplo n.º 6
0
/**
  * @brief  Main program
  * @param  None
  * @retval : None
  */
int main(void)
{
 uint32_t i=0;
  
  /* System clocks configuration ---------------------------------------------*/
  RCC_Configuration();

  /* NVIC configuration ------------------------------------------------------*/
  NVIC_Configuration();

  /* GPIO configuration ------------------------------------------------------*/
  GPIO_Configuration();

  /* CAN configuration */
  CAN_Config();

  CAN_ITConfig(CAN1, CAN_IT_FMP0, ENABLE);

  /* turn off all leds*/
  LED_Display(5);

  /* Infinite loop*/
  while(1)
  {
    while(Key_Status()== Key_Pressed)
     {
	if(Key_Pressed_Number==0x4) 
        {
	   Key_Pressed_Number = 0x00;
        }
	else
        {
       	  LED_Display(++Key_Pressed_Number);
          TxMessage.Data[0] = Key_Pressed_Number;
          CAN_Transmit(CAN1, &TxMessage);
	  for(i=0;i<0xFFFF;i++);
          while(Key_Status()!= Key_NoPressed);
        }
     }
  }
}
Exemplo n.º 7
0
/**
  * @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. 
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f4xx.c file
     */     
       
  /* NVIC configuration */
  NVIC_Config();

   /* Initialize LEDs mounted on EVAL board */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);
  
  /* Initialize Key Button mounted on EVAL board */
  STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO); 
   
  /* CAN configuration */
  CAN_Config();
  
  while(1)
  {
    while(STM_EVAL_PBGetState(BUTTON_KEY) == KEY_PRESSED)
    {
      if(ubKeyNumber == 0x4) 
      {
        ubKeyNumber = 0x00;
      }
      else
      {
        LED_Display(++ubKeyNumber);
        TxMessage.Data[0] = ubKeyNumber;
        CAN_Transmit(CANx, &TxMessage);
        /* Wait until one of the mailboxes is empty */
        while((CAN_GetFlagStatus(CANx, CAN_FLAG_RQCP0) !=RESET) || \
              (CAN_GetFlagStatus(CANx, CAN_FLAG_RQCP1) !=RESET) || \
              (CAN_GetFlagStatus(CANx, CAN_FLAG_RQCP2) !=RESET));
        
        while(STM_EVAL_PBGetState(BUTTON_KEY) != KEY_NOT_PRESSED)
        {
        }
      }
    }
  }
}
Exemplo n.º 8
0
/**
  * @brief  Transmission  complete callback in non blocking mode
  * @param  CanHandle: pointer to a CAN_HandleTypeDef structure that contains
  *         the configuration information for the specified CAN.
  * @retval None
  */
void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef *CanHandle)
{
  if ((CanHandle->pRxMsg->StdId == 0x321) && (CanHandle->pRxMsg->IDE == CAN_ID_STD) && (CanHandle->pRxMsg->DLC == 2))
  {
    LED_Display(CanHandle->pRxMsg->Data[0]);
    ubKeyNumber = CanHandle->pRxMsg->Data[0];
  }

  /* Receive */
  if (HAL_CAN_Receive_IT(CanHandle, CAN_FIFO0) != HAL_OK)
  {
    /* Reception Error */
    Error_Handler();
  }
}
Exemplo n.º 9
0
void vParTestToggleLED( unsigned portBASE_TYPE uxLED )
{
	unsigned portCHAR ucBit;

	if( uxLED >= partstMAX_OUTPUT_LED )
	{
		return;
	}

	ucBit = ( ( unsigned portCHAR ) 1 ) << uxLED;

	vTaskSuspendAll();
	{
		ucCurrentOutputValue ^= ucBit;
		LED_Display(ucCurrentOutputValue);
	}
	xTaskResumeAll();
}
Exemplo n.º 10
0
void RFAPI_TestMode(void)
{
         
    if(ucTest_Mode == 0)
    {

        return;                                                                 //normal mode
    }
    else if(ucTest_Mode == TEST_CARRIER_MODE)
    {
             RF_Carrier(DEFAULT_CHANNEL);   
             LED_ChangeFont(DEFAULT_CHANNEL,LED_FUNCTION_MODE);   

         while(1)
        {    
             Key_Scan(); 
            if(DATA_READY)                                                                //if Key Event
            {
              DATA_READY = FALSE;
             if(ucKey_RD == KEY3)                                                        //if press Key1 button down
                {
                if((Channel_Index == 0)||(Channel_Index >= sizeof(CHANNEL_TABLE_CARRIER)))
                  {
                  Channel_Index = sizeof(CHANNEL_TABLE_CARRIER)-1;
                  }
                 else
                  {
                   Channel_Index--;
                   }
                       
               RF_Carrier( CHANNEL_TABLE_CARRIER[Channel_Index]);                                //set RF into carry mode
               LED_ChangeFont(CHANNEL_TABLE_CARRIER[Channel_Index],LED_FUNCTION_MODE);   
                }                                                  
                                                     
              }
              LED_Display(); 
          }
    
    }else
      {
        ucTest_Mode = 0;                                                        //normal mode
    
      }
}
Exemplo n.º 11
0
/**
  * @brief  This function handles EXTI 10 to 15 request.
  * @param  None
  * @retval None
  */
void EXTI0_1_IRQHandler(void)
{
  if(KeyNumber == 0x4) 
  {
    KeyNumber = 0x00;
  }
  LED_Display(++KeyNumber);
  TxMessage1.Data[0] = KeyNumber;
  CAN_Transmit(CANx, &TxMessage1);
  
  /* Set the LCD Back Color */
  LCD_SetBackColor(Cyan);
  
  /* Set the LCD Text Color */
  LCD_SetTextColor(Black);
  
  /* Displays MESSAGE1 on line 6 */
  LCD_DisplayStringLine(LINE(6), (uint8_t *)MESSAGE2);
   
  /* Clear the EXTI line 13 pending bit */
  EXTI_ClearITPendingBit(EXTI_Line0);
  
}
Exemplo n.º 12
0
/**
  * @brief  This function handles EXTI 6 request.
  * @param  None
  * @retval None
  */
void EXTI4_15_IRQHandler(void)
{ 
 if(KeyNumber < 0x2) 

  {
    KeyNumber = 0x05;
  }
  LED_Display(--KeyNumber);

  TxMessage.Data[0] = KeyNumber;

  CAN_Transmit(CANx, &TxMessage);
  
  /* Set the LCD Back Color */
  LCD_SetBackColor(Green);
  /* Set the LCD Text Color */
  LCD_SetTextColor(Black);
  /* Displays MESSAGE1 on line 6 */
  LCD_DisplayStringLine(LINE(6), (uint8_t *)MESSAGE1);
   
  /* Clear the EXTI line 6 pending bit */
  EXTI_ClearITPendingBit(EXTI_Line13);
}
Exemplo n.º 13
0
/**
  * @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_stm32f10x_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f10x.c file
     */
        
  /* NVIC configuration */
  NVIC_Config();

  /* Configures LED 1..4 */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);

  /* LCD Initialization */
  STM3210C_LCD_Init();
  LCD_Clear(LCD_COLOR_WHITE);

  /* Set the LCD Back Color */
  LCD_SetBackColor(LCD_COLOR_RED);
  /* Set the LCD Text Color */
  LCD_SetTextColor(LCD_COLOR_GREEN);
  
  LCD_DisplayStringLine(LCD_LINE_0, "   STM3210C-EVAL    ");
  LCD_DisplayStringLine(LCD_LINE_1, " STM32F10x Dual CAN ");
  LCD_DisplayStringLine(LCD_LINE_2, "To start Press on:  ");
  LCD_DisplayStringLine(LCD_LINE_3, "Key or Tamper Button");

  /* Set the LCD Back Color */
  LCD_SetBackColor(LCD_COLOR_BLUE);

#if CAN_BAUDRATE == 1000 /* 1MBps */
  LCD_DisplayStringLine(LCD_LINE_4, " BAUDRATE = 1MBps   ");
#elif CAN_BAUDRATE == 500 /* 500KBps */
  LCD_DisplayStringLine(LCD_LINE_4, " BAUDRATE = 500kBps   ");
#elif CAN_BAUDRATE == 250 /* 250KBps */
  LCD_DisplayStringLine(LCD_LINE_4, " BAUDRATE = 250kBps   ");
#elif CAN_BAUDRATE == 125 /* 125KBps */
  LCD_DisplayStringLine(LCD_LINE_4, " BAUDRATE = 125kBps   ");
#elif  CAN_BAUDRATE == 100 /* 100KBps */
  LCD_DisplayStringLine(LCD_LINE_4, " BAUDRATE = 100kBps   ");
#elif  CAN_BAUDRATE == 50 /* 50KBps */
  LCD_DisplayStringLine(LCD_LINE_4, " BAUDRATE = 50kBps   ");
#elif  CAN_BAUDRATE == 20 /* 20KBps */
  LCD_DisplayStringLine(LCD_LINE_4, " BAUDRATE = 20kBps   ");
#elif  CAN_BAUDRATE == 10 /* 10KBps */
  LCD_DisplayStringLine(LCD_LINE_4, " BAUDRATE = 10kBps   ");
#endif
  /* Set the LCD Text Color */
  LCD_SetTextColor(LCD_COLOR_WHITE);   
    
  /* Configure BUTTON_KEY */
  STM_EVAL_PBInit(BUTTON_KEY, BUTTON_MODE_GPIO); 
  
  /* Configure BUTTON_TAMPER */
  STM_EVAL_PBInit(BUTTON_TAMPER, BUTTON_MODE_GPIO); 
   
  /* CANs configuration */
  CAN_Config();

  /* IT Configuration for CAN1 */  
  CAN_ITConfig(CAN1, CAN_IT_FMP0, ENABLE);

  /* IT Configuration for CAN2 */  
  CAN_ITConfig(CAN2, CAN_IT_FMP0, ENABLE);

  /* turn off all leds*/
  STM_EVAL_LEDOff(LED1);
  STM_EVAL_LEDOff(LED2);
  STM_EVAL_LEDOff(LED3);
  STM_EVAL_LEDOff(LED4);
 
  /* Infinite loop */
  while(1)
  {
    if(STM_EVAL_PBGetState(BUTTON_KEY)== RESET)
    {
      /* Turn On LED1 */
      LED_Display(0x01);
      TxMessage.Data[0] = 0x55;
      CAN_Transmit(CAN1, &TxMessage);

      /* Loop while KEY button is pressed */
      while(STM_EVAL_PBGetState(BUTTON_KEY)== RESET)
      {
      }
    }
    if(STM_EVAL_PBGetState(BUTTON_TAMPER)== RESET)
    {
      /* Turn On LED2 */
      LED_Display(0x2);
      TxMessage.Data[0] = 0xAA;
      CAN_Transmit(CAN2, &TxMessage);

      /* Loop while TAMPER button is pressed */
      while(STM_EVAL_PBGetState(BUTTON_TAMPER)== RESET)
      {
      }
    }
  }
}
Exemplo n.º 14
0
void vParTestInitialise( void )
{
	LED_Display(partstALL_OUTPUTS_OFF); /* Start with all LEDs off. */
}
Exemplo n.º 15
0
void main(void)
{
    CAN_TxStatus_TypeDef status = CAN_TxStatus_Failed;

    /* Transmit Parameters */
    CAN_Id_TypeDef Tx_IDE = CAN_Id_Standard;
    CAN_RTR_TypeDef Tx_RTR = CAN_RTR_Data;
    uint8_t Tx_DLC = 0;
    uint8_t Tx_Data[8] = {0};
    uint32_t Tx_Id = 0;

    /* Clock configuration --------------------------------------*/
    CLK_Config();

    /* GPIO Configuration ---------------------------------------*/
    GPIO_Config();

    /* Configure LCD mounted on STM8-128 EVAL board -------------*/
    LCD_Config();

    /* CAN configuration ----------------------------------------*/
    CAN_Config();

    /* Enable Interrupts*/
    enableInterrupts();

    /* Infinite loop*/
    while(1)
    {
        while(Key_status != Key_NoPressed)
        {

            if(Key_Pressed_Number == 0x0)
            {
                Key_Pressed_Number = 0x03;
            }
            else
            {
                Key_Pressed_Number--;
            }

            /* Sender Display*/
            LED_Display(Key_Pressed_Number);
            LCD_Display(Key_Pressed_Number);
            Delay(TIME);

            /* Transmit Parameters*/
            Tx_Id = 0x321;
            Tx_IDE = CAN_Id_Standard;
            Tx_RTR = CAN_RTR_Data;
            Tx_DLC = 1;
            Tx_Data[0] = Key_Pressed_Number;

            /* Sender send Frame */
            status = CAN_Transmit(Tx_Id,Tx_IDE,Tx_RTR,Tx_DLC,Tx_Data);

            /* while key is not pressed, loop*/
            Key_status= Key_NoPressed;
        }
    }
}
Exemplo n.º 16
0
/**
  * @brief  Main program.
  * @param  None
  * @retval None
  */
int main(void)
{
  /* Enable the CPU Cache */
  CPU_CACHE_Enable();

  /* STM32F7xx HAL library initialization:
       - Configure the Flash ART accelerator on ITCM interface
       - Systick timer is configured by default as source of time base, but user 
         can eventually implement his proper time base source (a general purpose 
         timer for example or other time source), keeping in mind that Time base 
         duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 
         handled in milliseconds basis.
       - Set NVIC Group Priority to 4
       - Low Level Initialization
     */
  HAL_Init();


  /* Configure the system clock to 216 MHz */
  SystemClock_Config();

  /* Since MFX is used, LED init is done after clock config */
  /* Configure LED1, LED2, LED3 and LED4 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);
  
  /* Configure Tamper push-button */
  BSP_PB_Init(BUTTON_TAMPER, BUTTON_MODE_GPIO);

  /*##-1- Configure the CAN peripheral #######################################*/
  CAN_Config();

  /*##-2- Start the Reception process and enable reception interrupt #########*/
  if (HAL_CAN_Receive_IT(&CanHandle, CAN_FIFO0) != HAL_OK)
  {
    /* Reception Error */
    Error_Handler();
  }

  /* Infinite loop */
  while (1)
  {
    while (BSP_PB_GetState(BUTTON_TAMPER) == KEY_PRESSED)
    {
      if (ubKeyNumber == 0x4)
      {
        ubKeyNumber = 0x00;
      }
      else
      {
        LED_Display(++ubKeyNumber);
        
        /* Set the data to be transmitted */
        CanHandle.pTxMsg->Data[0] = ubKeyNumber;
        CanHandle.pTxMsg->Data[1] = 0xAD;
        
        /*##-3- Start the Transmission process ###############################*/
        if (HAL_CAN_Transmit(&CanHandle, 10) != HAL_OK)
        {
          /* Transmission Error */
          Error_Handler();
        }
        HAL_Delay(10);
        
        while (BSP_PB_GetState(BUTTON_TAMPER) != KEY_NOT_PRESSED)
        {
        }
      }
    }
  }
}
Exemplo n.º 17
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* STM32F4xx HAL library initialization:
       - Configure the Flash prefetch, instruction and Data caches
       - Configure the Systick to generate an interrupt each 1 msec
       - Set NVIC Group Priority to 4
       - Global MSP (MCU Support Package) initialization
     */
  HAL_Init();
  
  /* Configure the system clock to 180 MHz */
  SystemClock_Config();
  
  /* Configure LED1, LED2, LED3 and LED4 */
  BSP_LED_Init(LED1);
  BSP_LED_Init(LED2);
  BSP_LED_Init(LED3);
  BSP_LED_Init(LED4);
  
  /* Configure Key Button */ 
  BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_GPIO);
  
  /*##-1- Configure the CAN peripheral #######################################*/
  CAN_Config();
  
  /*##-2- Start the Reception process and enable reception interrupt #########*/
  if(HAL_CAN_Receive_IT(&CanHandle, CAN_FIFO0) != HAL_OK)
  {
    /* Reception Error */
    Error_Handler();
  }
  
  /* Infinite loop */
  while(1)
  {
    while(BSP_PB_GetState(BUTTON_KEY) == KEY_PRESSED)
    {
      if(ubKeyNumber == 0x4) 
      {
        ubKeyNumber = 0x00;
      }
      else
      {
        LED_Display(++ubKeyNumber);
        
        /* Set the data to be transmitted */
        CanHandle.pTxMsg->Data[0] = ubKeyNumber;
        CanHandle.pTxMsg->Data[1] = 0xAD;
        
        /*##-3- Start the Transmission process ###############################*/
        if(HAL_CAN_Transmit(&CanHandle, 10) != HAL_OK)
        {
          /* Transmition Error */
          Error_Handler();
        }
        HAL_Delay(10);
        
        while(BSP_PB_GetState(BUTTON_KEY) != KEY_NOT_PRESSED)
        {
        }
      }
    }
  } 
}