mirror of
https://github.com/elua/elua.git
synced 2025-01-25 01:02:54 +08:00
EXTINT interrupt support for STR9 (UNTESTED)
This commit is contained in:
parent
b7c8d7dddf
commit
b0428bc3ec
201
src/platform/str9/91x_wiu.c
Normal file
201
src/platform/str9/91x_wiu.c
Normal file
@ -0,0 +1,201 @@
|
||||
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
|
||||
* File Name : 91x_wiu.c
|
||||
* Author : MCD Application Team
|
||||
* Version : V2.1
|
||||
* Date : 12/22/2008
|
||||
* Description : This file provides all the WIU firmware functions.
|
||||
**********************************************************************************
|
||||
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
|
||||
* CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
|
||||
* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
|
||||
* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*********************************************************************************/
|
||||
|
||||
/* Standard include ----------------------------------------------------------*/
|
||||
#include "91x_wiu.h"
|
||||
#include "91x_scu.h"
|
||||
|
||||
/* Include of other module interface headers ---------------------------------*/
|
||||
/* Local includes ------------------------------------------------------------*/
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
|
||||
|
||||
/* WIU Masks "used" only in this module */
|
||||
#define WIU_Enable 0x02
|
||||
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* Interface functions -------------------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/******************************************************************************
|
||||
* Function Name : WIU_Init
|
||||
* Description : Initializes the WIU unit according to the specified parameters
|
||||
* in the WIU_InitTypeDef structure.
|
||||
* Input : WIU_InitStruct: pointer to a WIU_InitTypeDef structure that
|
||||
* contains the configuration information for the WIU peripheral.
|
||||
* Output : None
|
||||
* Return : None
|
||||
******************************************************************************/
|
||||
void WIU_Init(WIU_InitTypeDef* WIU_InitStruct)
|
||||
{
|
||||
/* select the Wake-up line to be used */
|
||||
WIU->MR |= WIU_InitStruct->WIU_Line;
|
||||
|
||||
/* configure the triggering edge */
|
||||
if(WIU_InitStruct->WIU_TriggerEdge == WIU_RisingEdge)
|
||||
{
|
||||
/* trigger on rising edge */
|
||||
WIU->TR |= WIU_InitStruct->WIU_Line;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* trigger on falling edge */
|
||||
WIU->TR &= ~WIU_InitStruct->WIU_Line;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function Name : WIU_DeInit
|
||||
* Description : Deinitializes the WIU registers to their default reset values.
|
||||
* Input : None
|
||||
* Output : None
|
||||
* Return : None
|
||||
******************************************************************************/
|
||||
void WIU_DeInit(void)
|
||||
{
|
||||
/* initialize the WIU registers to their reset value */
|
||||
SCU_APBPeriphReset(__WIU, ENABLE);
|
||||
SCU_APBPeriphReset(__WIU, DISABLE);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* Function Name : WIU_StructInit
|
||||
* Description : Fills in a WIU_InitTypeDef structure with the reset value of
|
||||
* each parameter.
|
||||
* Input : WIU_InitStruct : pointer to a WIU_InitTypeDef structure
|
||||
* which will be initialized.
|
||||
* Output : None
|
||||
* Return : None
|
||||
******************************************************************************/
|
||||
void WIU_StructInit(WIU_InitTypeDef* WIU_InitStruct)
|
||||
{
|
||||
/* initialize the WIU_InitStruct fields to their reset values */
|
||||
WIU_InitStruct->WIU_Line = 0x0 ;
|
||||
WIU_InitStruct->WIU_TriggerEdge = WIU_FallingEdge ;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : WIU_Cmd
|
||||
* Description : Enables or disables the WIU peripheral.
|
||||
* Input : NewState: new state of the WIU peripheral (Newstate can be
|
||||
* ENABLE or DISABLE)
|
||||
* Output : None
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void WIU_Cmd(FunctionalState NewState )
|
||||
{
|
||||
if(NewState == ENABLE)
|
||||
{
|
||||
/* Enable the Wake-up Unit (for interrupts and wake-up from low power modes) */
|
||||
WIU->CTRL |= WIU_Enable ;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Disable the Wake-up Unit (for interrupts and wake-up from low power modes) */
|
||||
|
||||
WIU->CTRL &= ~WIU_Enable ;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : WIU_GenerateSWInterrupt
|
||||
* Description : Generates a Software interrupt.
|
||||
* Input : - WIU_Line: specifies the WIU lines to be enabled or
|
||||
* disabled. This parameter can be:
|
||||
* - WIU_Linex: External interrupt line x where x(0..31)
|
||||
* Output : None
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void WIU_GenerateSWInterrupt(u32 WIU_Line)
|
||||
{
|
||||
WIU->INTR |= WIU_Line;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : WIU_GetFlagStatus
|
||||
* Description : Checks whether the specified WIU line flag is set or not.
|
||||
* Input : - WIU_Line: specifies the WIU lines flag to check.
|
||||
* This parameter can be:
|
||||
* - WIU_Linex: External interrupt line x where x(0..31)
|
||||
* Output : None
|
||||
* Return : The new state of WIU_Line (SET or RESET).
|
||||
*******************************************************************************/
|
||||
FlagStatus WIU_GetFlagStatus(u32 WIU_Line)
|
||||
{
|
||||
if((WIU->PR & WIU_Line) != RESET)
|
||||
{
|
||||
return SET;
|
||||
}
|
||||
else
|
||||
{
|
||||
return RESET;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : WIU_ClearFlag
|
||||
* Description : Clears the WIU<EFBFBD>s line pending flags.
|
||||
* Input : - WIU_Line: specifies the WIU lines flags to clear.
|
||||
* This parameter can be:
|
||||
* - WIU_Linex: External interrupt line x where x(0..31)
|
||||
* Output : None
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void WIU_ClearFlag(u32 WIU_Line)
|
||||
{
|
||||
WIU->PR = WIU_Line;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : WIU_GetITStatus
|
||||
* Description : Checks whether the specified WIU line is asserted or not.
|
||||
* Input : - WIU_Line: specifies the WIU lines to check.
|
||||
* This parameter can be:
|
||||
* - WIU_Linex: External interrupt line x where x(0..31)
|
||||
* Output : None
|
||||
* Return : The new state of WIU_Line (SET or RESET).
|
||||
*******************************************************************************/
|
||||
ITStatus WIU_GetITStatus(u32 WIU_Line)
|
||||
{
|
||||
if(((WIU->PR & WIU_Line) != RESET)&& ((WIU->MR & WIU_Line) != RESET))
|
||||
{
|
||||
return SET;
|
||||
}
|
||||
else
|
||||
{
|
||||
return RESET;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : WIU_ClearITPendingBit
|
||||
* Description : Clears the WIU<EFBFBD>s line pending bits.
|
||||
* Input : - WIU_Line: specifies the WIU lines to clear.
|
||||
* This parameter can be:
|
||||
* - WIU_Linex: External interrupt line x where x(0..31)
|
||||
* Output : None
|
||||
* Return : None
|
||||
*******************************************************************************/
|
||||
void WIU_ClearITPendingBit(u32 WIU_Line)
|
||||
{
|
||||
WIU->PR = WIU_Line;
|
||||
}
|
||||
|
||||
|
||||
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
|
90
src/platform/str9/91x_wiu.h
Normal file
90
src/platform/str9/91x_wiu.h
Normal file
@ -0,0 +1,90 @@
|
||||
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
|
||||
* File Name : 91x_wiu.h
|
||||
* Author : MCD Application Team
|
||||
* Version : V2.1
|
||||
* Date : 12/22/2008
|
||||
* Description : This file contains all the functions prototypes for the
|
||||
* WIU firmware library.
|
||||
**********************************************************************************
|
||||
* THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS WITH
|
||||
* CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
|
||||
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT, INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE CONTENT
|
||||
* OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING INFORMATION
|
||||
* CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
|
||||
*********************************************************************************/
|
||||
|
||||
/* Define to prevent recursive inclusion ------------------------------------ */
|
||||
#ifndef __91x_WIU_H
|
||||
#define __91x_WIU_H
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "91x_map.h"
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* WIU Init structure type define */
|
||||
typedef struct
|
||||
{
|
||||
u8 WIU_TriggerEdge;
|
||||
u32 WIU_Line ;
|
||||
}WIU_InitTypeDef ;
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Wake-up line triggering edge */
|
||||
#define WIU_FallingEdge 0x00
|
||||
#define WIU_RisingEdge 0x01
|
||||
|
||||
/* Wake-up lines*/
|
||||
#define WIU_Line0 0x0001
|
||||
#define WIU_Line1 (WIU_Line0<<1)
|
||||
#define WIU_Line2 (WIU_Line1<<1)
|
||||
#define WIU_Line3 (WIU_Line2<<1)
|
||||
#define WIU_Line4 (WIU_Line3<<1)
|
||||
#define WIU_Line5 (WIU_Line4<<1)
|
||||
#define WIU_Line6 (WIU_Line5<<1)
|
||||
#define WIU_Line7 (WIU_Line6<<1)
|
||||
#define WIU_Line8 (WIU_Line7<<1)
|
||||
#define WIU_Line9 (WIU_Line8<<1)
|
||||
#define WIU_Line10 (WIU_Line9<<1)
|
||||
#define WIU_Line11 (WIU_Line10<<1)
|
||||
#define WIU_Line12 (WIU_Line11<<1)
|
||||
#define WIU_Line13 (WIU_Line12<<1)
|
||||
#define WIU_Line14 (WIU_Line13<<1)
|
||||
#define WIU_Line15 (WIU_Line14<<1)
|
||||
#define WIU_Line16 (WIU_Line15<<1)
|
||||
#define WIU_Line17 (WIU_Line16<<1)
|
||||
#define WIU_Line18 (WIU_Line17<<1)
|
||||
#define WIU_Line19 (WIU_Line18<<1)
|
||||
#define WIU_Line20 (WIU_Line19<<1)
|
||||
#define WIU_Line21 (WIU_Line20<<1)
|
||||
#define WIU_Line22 (WIU_Line21<<1)
|
||||
#define WIU_Line23 (WIU_Line22<<1)
|
||||
#define WIU_Line24 (WIU_Line23<<1)
|
||||
#define WIU_Line25 (WIU_Line24<<1)
|
||||
#define WIU_Line26 (WIU_Line25<<1)
|
||||
#define WIU_Line27 (WIU_Line26<<1)
|
||||
#define WIU_Line28 (WIU_Line27<<1)
|
||||
#define WIU_Line29 (WIU_Line28<<1)
|
||||
#define WIU_Line30 (WIU_Line29<<1)
|
||||
#define WIU_Line31 (WIU_Line30<<1)
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* Module private variables --------------------------------------------------*/
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
|
||||
void WIU_DeInit(void);
|
||||
void WIU_StructInit(WIU_InitTypeDef* WIU_InitStruct);
|
||||
void WIU_Init(WIU_InitTypeDef* WIU_InitStruct);
|
||||
void WIU_Cmd(FunctionalState NewState );
|
||||
void WIU_GenerateSWInterrupt(u32 WIU_Line);
|
||||
FlagStatus WIU_GetFlagStatus(u32 WIU_Line);
|
||||
void WIU_ClearFlag(u32 WIU_Line);
|
||||
ITStatus WIU_GetITStatus(u32 WIU_Line);
|
||||
void WIU_ClearITPendingBit(u32 WIU_Line);
|
||||
|
||||
#endif /* __91x_WIU_H */
|
||||
|
||||
/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
cpumode = ARGUMENTS.get( 'cpumode', 'arm' ).lower()
|
||||
|
||||
specific_files = "startup912.s startup_generic.s platform.c 91x_scu.c 91x_fmi.c 91x_gpio.c 91x_uart.c 91x_tim.c 91x_vic.c interrupt.c str9_pio.c 91x_i2c.c"
|
||||
specific_files = "startup912.s startup_generic.s platform.c 91x_scu.c 91x_fmi.c 91x_gpio.c 91x_uart.c 91x_tim.c 91x_vic.c interrupt.c str9_pio.c 91x_i2c.c 91x_wiu.c"
|
||||
|
||||
# Check CPU
|
||||
if comp[ 'cpu' ] == 'STR912FAW44':
|
||||
|
@ -251,30 +251,30 @@ void WIU_IRQHandler(void)
|
||||
* Function Name : EXTIT0_IRQHandler
|
||||
* Description : This function handles the EXTIT0 interrupt request
|
||||
*******************************************************************************/
|
||||
void EXTIT0_IRQHandler(void)
|
||||
/*void EXTIT0_IRQHandler(void)
|
||||
{
|
||||
}
|
||||
}*/
|
||||
/*******************************************************************************
|
||||
* Function Name : EXTIT1_IRQHandler
|
||||
* Description : This function handles the EXTIT1 interrupt request
|
||||
*******************************************************************************/
|
||||
void EXTIT1_IRQHandler(void)
|
||||
/*void EXTIT1_IRQHandler(void)
|
||||
{
|
||||
}
|
||||
}*/
|
||||
/*******************************************************************************
|
||||
* Function Name : EXTIT2_IRQHandler
|
||||
* Description : This function handles the EXTIT2 interrupt request
|
||||
*******************************************************************************/
|
||||
void EXTIT2_IRQHandler(void)
|
||||
/*void EXTIT2_IRQHandler(void)
|
||||
{
|
||||
}
|
||||
}*/
|
||||
/*******************************************************************************
|
||||
* Function Name : EXTIT3_IRQHandler
|
||||
* Description : This function handles the EXTIT3 interrupt request
|
||||
*******************************************************************************/
|
||||
void EXTIT3_IRQHandler(void)
|
||||
/*void EXTIT3_IRQHandler(void)
|
||||
{
|
||||
}
|
||||
}*/
|
||||
/*******************************************************************************
|
||||
* Function Name : USBWU_IRQHandler
|
||||
* Description : This function handles the USBWU interrupt request
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "91x_vic.h"
|
||||
#include "lrotable.h"
|
||||
#include "91x_i2c.h"
|
||||
#include "91x_wiu.h"
|
||||
|
||||
// ****************************************************************************
|
||||
// Platform initialization
|
||||
@ -62,6 +63,10 @@ static void platform_config_scu()
|
||||
// Enable the GPIO clocks
|
||||
SCU_APBPeriphClockConfig(__GPIO_ALL, ENABLE);
|
||||
|
||||
// Enable the WIU clock
|
||||
SCU_APBPeriphClockConfig(__WIU, ENABLE);
|
||||
SCU_APBPeriphReset(__WIU, DISABLE);
|
||||
|
||||
// Enable the I2C clocks
|
||||
SCU_APBPeriphClockConfig(__I2C0, ENABLE);
|
||||
SCU_APBPeriphReset(__I2C0, DISABLE);
|
||||
@ -81,6 +86,13 @@ static const GPIO_TypeDef* uart_port_data[] = { GPIO3, GPIO3 };
|
||||
static const u8 uart_pin_data[] = { GPIO_Pin_2, GPIO_Pin_3 };
|
||||
#endif
|
||||
|
||||
// Dummy interrupt handlers avoid spurious interrupts (AN2593)
|
||||
static void dummy_int_handler()
|
||||
{
|
||||
VIC0->VAR = 0xFF;
|
||||
VIC1->VAR = 0xFF;
|
||||
}
|
||||
|
||||
// Plaform specific GPIO UART setup
|
||||
static void platform_gpio_uart_setup()
|
||||
{
|
||||
@ -115,7 +127,24 @@ int platform_init()
|
||||
|
||||
// Initialize VIC
|
||||
VIC_DeInit();
|
||||
VIC0->DVAR = ( u32 )dummy_int_handler;
|
||||
VIC1->DVAR = ( u32 )dummy_int_handler;
|
||||
|
||||
// Enablue WIU
|
||||
WIU_DeInit();
|
||||
|
||||
// Initialize all external interrupts
|
||||
VIC_Config( EXTIT0_ITLine, VIC_IRQ, 1 );
|
||||
VIC_Config( EXTIT1_ITLine, VIC_IRQ, 2 );
|
||||
VIC_Config( EXTIT2_ITLine, VIC_IRQ, 3 );
|
||||
VIC_Config( EXTIT3_ITLine, VIC_IRQ, 4 );
|
||||
VIC_ITCmd( EXTIT0_ITLine, ENABLE );
|
||||
VIC_ITCmd( EXTIT1_ITLine, ENABLE );
|
||||
VIC_ITCmd( EXTIT2_ITLine, ENABLE );
|
||||
VIC_ITCmd( EXTIT3_ITLine, ENABLE );
|
||||
// Enable interrupt generation on WIU
|
||||
WIU->CTRL |= 2;
|
||||
|
||||
// UART setup
|
||||
platform_gpio_uart_setup();
|
||||
platform_uart_setup( CON_UART_ID, CON_UART_SPEED, 8, PLATFORM_UART_PARITY_NONE, PLATFORM_UART_STOPBITS_1 );
|
||||
@ -135,7 +164,7 @@ int platform_init()
|
||||
cmn_platform_init();
|
||||
|
||||
return PLATFORM_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
// PIO functions
|
||||
@ -513,6 +542,159 @@ int platform_i2c_recv_byte( unsigned id, int ack )
|
||||
return I2C_ReceiveData( pi2c );
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
// EXTINT handlers and support functions
|
||||
|
||||
static const u8 exint_group_to_gpio[] = { 3, 5, 6, 7 };
|
||||
|
||||
// Convert an EXINT source number to a GPIO ID
|
||||
static u16 exint_src_to_gpio( u32 exint )
|
||||
{
|
||||
return PLATFORM_IO_ENCODE( exint_group_to_gpio[ exint >> 3 ], exint & 0x07, 0 );
|
||||
}
|
||||
|
||||
// Convert a GPIO ID to a EXINT number
|
||||
static int exint_gpio_to_src( pio_type piodata )
|
||||
{
|
||||
u16 port = PLATFORM_IO_GET_PORT( piodata );
|
||||
u16 pin = PLATFORM_IO_GET_PIN( piodata );
|
||||
unsigned i;
|
||||
|
||||
for( i = 0; i < sizeof( exint_group_to_gpio ) / sizeof( u8 ); i ++ )
|
||||
if( exint_group_to_gpio[ i ] == port )
|
||||
break;
|
||||
// Restrictions: only the specified port(s) have interrupt capabilities
|
||||
// for port 0 (GPIO3), only pins 2..7 have interrupt capabilities
|
||||
if( ( i == sizeof( exint_group_to_gpio ) / sizeof( u8 ) ) || ( ( i == 0 ) && ( pin < 2 ) ) )
|
||||
return -1;
|
||||
return ( i << 3 ) + pin;
|
||||
}
|
||||
|
||||
// External interrupt handlers
|
||||
static void exint_irq_handler( int group )
|
||||
{
|
||||
u32 bmask;
|
||||
u32 pr = WIU->PR;
|
||||
u32 mr = WIU->MR;
|
||||
u32 tr = WIU->TR;
|
||||
u32 shift = group << 3;
|
||||
unsigned i;
|
||||
|
||||
// Check interrupt mask
|
||||
if( ( ( pr >> shift ) & 0xFF ) == 0 )
|
||||
{
|
||||
VIC1->VAR = 0xFF;
|
||||
return;
|
||||
}
|
||||
|
||||
// Iterate through all the bits in the mask, queueing interrupts as needed
|
||||
for( i = 0, bmask = 1 << shift; i < 8; i ++, bmask <<= 1 )
|
||||
if( ( pr & bmask ) && ( mr & bmask ) )
|
||||
{
|
||||
// Enqueue interrupt
|
||||
if( tr & bmask )
|
||||
elua_int_add( INT_GPIO_POSEDGE, exint_src_to_gpio( shift + i ) );
|
||||
else
|
||||
elua_int_add( INT_GPIO_NEGEDGE, exint_src_to_gpio( shift + i ) );
|
||||
// Then clear it
|
||||
WIU->PR = bmask;
|
||||
}
|
||||
|
||||
// Clear interrupt source
|
||||
VIC1->VAR = 0xFF;
|
||||
}
|
||||
|
||||
void EXTIT0_IRQHandler()
|
||||
{
|
||||
exint_irq_handler( 0 );
|
||||
}
|
||||
|
||||
void EXTIT1_IRQHandler()
|
||||
{
|
||||
exint_irq_handler( 1 );
|
||||
}
|
||||
|
||||
void EXTIT2_IRQHandler()
|
||||
{
|
||||
exint_irq_handler( 2 );
|
||||
}
|
||||
|
||||
void EXTIT3_IRQHandler()
|
||||
{
|
||||
exint_irq_handler( 3 );
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
// CPU functions
|
||||
|
||||
// Helper: return the status of a specific interrupt (enabled/disabled)
|
||||
static int platform_cpuh_get_int_status( elua_int_id id, elua_int_resnum resnum )
|
||||
{
|
||||
int temp;
|
||||
u32 mask;
|
||||
|
||||
if( id == INT_GPIO_POSEDGE || id == INT_GPIO_NEGEDGE )
|
||||
{
|
||||
if( ( temp = exint_gpio_to_src( resnum ) ) == -1 )
|
||||
{
|
||||
fprintf( stderr, "Error: not a valid source for an external interrupt\n" );
|
||||
return 0;
|
||||
}
|
||||
mask = 1 << temp;
|
||||
if( WIU->MR & mask )
|
||||
{
|
||||
if( id == INT_GPIO_POSEDGE )
|
||||
return ( WIU->TR & mask ) != 0;
|
||||
else
|
||||
return ( WIU->TR & mask ) == 0;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
fprintf( stderr, "Error: %d not a valid interrupt ID\n", id );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int platform_cpu_set_interrupt( elua_int_id id, elua_int_resnum resnum, int status )
|
||||
{
|
||||
int crt_status = platform_cpuh_get_int_status( id, resnum );
|
||||
int temp;
|
||||
u32 mask;
|
||||
|
||||
if( id == INT_GPIO_POSEDGE || id == INT_GPIO_NEGEDGE )
|
||||
{
|
||||
if( ( temp = exint_gpio_to_src( resnum ) ) == -1 )
|
||||
{
|
||||
fprintf( stderr, "Error: not a valid source for an external interrupt\n" );
|
||||
return 0;
|
||||
}
|
||||
mask = 1 << temp;
|
||||
if( status == PLATFORM_CPU_ENABLE )
|
||||
{
|
||||
// Set edge type
|
||||
if( id == INT_GPIO_POSEDGE )
|
||||
WIU->TR |= mask;
|
||||
else
|
||||
WIU->TR &= ~mask;
|
||||
// Clear interrupt flag?
|
||||
// WIU->PR = mask;
|
||||
// Enable interrupt
|
||||
WIU->MR |= mask;
|
||||
}
|
||||
else
|
||||
WIU->MR &= ~mask;
|
||||
}
|
||||
else
|
||||
fprintf( stderr, "Error: %d not a valid interrupt ID\n", id );
|
||||
return crt_status;
|
||||
}
|
||||
|
||||
int platform_cpu_get_interrupt( elua_int_id id, elua_int_resnum resnum )
|
||||
{
|
||||
return platform_cpuh_get_int_status( id, resnum );
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
// Platform specific modules go here
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "auxmods.h"
|
||||
#include "stacks.h"
|
||||
#include "type.h"
|
||||
#include "elua_int.h"
|
||||
#include "buf.h"
|
||||
|
||||
// *****************************************************************************
|
||||
// Define here what components you want for this platform
|
||||
@ -16,6 +18,7 @@
|
||||
#define BUILD_TERM
|
||||
#define BUILD_CON_GENERIC
|
||||
//#define BUILD_RPC
|
||||
#define BUILD_LUA_INT_HANDLERS
|
||||
|
||||
// *****************************************************************************
|
||||
// UART/Timer IDs configuration data (used in main.c)
|
||||
@ -53,6 +56,9 @@
|
||||
#define RPC_TIMER_ID CON_TIMER_ID
|
||||
#define RPC_UART_SPEED CON_UART_SPEED
|
||||
|
||||
// Interrupt queue configuration
|
||||
#define PLATFORM_INT_QUEUE_LOG_SIZE BUF_SIZE_32
|
||||
|
||||
// CPU frequency (needed by the CPU module, 0 if not used)
|
||||
u32 SCU_GetMCLKFreqValue();
|
||||
#define CPU_FREQUENCY ( SCU_GetMCLKFreqValue() * 1000 )
|
||||
@ -103,4 +109,17 @@ u32 SCU_GetMCLKFreqValue();
|
||||
_ROM( LUA_MATHLIBNAME, luaopen_math, math_map )\
|
||||
_ROM( PS_LIB_TABLE_NAME, luaopen_platform, platform_map )
|
||||
|
||||
// Interrupt list
|
||||
enum
|
||||
{
|
||||
// Platform interrupts
|
||||
INT_GPIO_POSEDGE = ELUA_INT_FIRST_ID,
|
||||
INT_GPIO_NEGEDGE,
|
||||
};
|
||||
|
||||
#define PLATFORM_CPU_CONSTANTS\
|
||||
_C( INT_GPIO_POSEDGE ),\
|
||||
_C( INT_GPIO_NEGEDGE )
|
||||
|
||||
#endif // #ifndef __PLATFORM_CONF_H__
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#define __STACKS_H__
|
||||
|
||||
#define STACK_SIZE_SVC 2048
|
||||
#define STACK_SIZE_IRQ 64
|
||||
#define STACK_SIZE_IRQ 96
|
||||
#define STACK_SIZE_TOTAL ( STACK_SIZE_SVC + STACK_SIZE_IRQ )
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user