src/extio.c File Reference

More...

#include "extio.h"
#include "tll_common.h"
#include "tll_config.h"
#include "queue.h"
#include "isrDisp.h"
#include <fpga_loader.h>
#include <eventManager.h>

Include dependency graph for extio.c:


Defines

#define OUTPUT_BITS   (0xFF)
 LEDs are mapped to lower 8 bits of the register, push bottons and switches are mapped to higher 8 bits of the register.
#define INPUT_BITS   (0xFF00)
#define MAP_LED_TO_BIT(LED)   (0x1<<LED)
 convert from LED number to bit in the bit pattern
#define MAP_INPUT_TO_BIT(INP)   (0x1 << 8) << ((INP - 1) >> 1)
 convert from Input Event number to bit mask
#define BIT_CLEAR(REGISER, MASK)   REGISTER = REGISTER & ~(MASK)
 clear bit(s) defined by mask
#define BIT_SET(REGISER, MASK)   REGISTER = REGISTER | MASK
 set bit(s) defined by mask

Functions

int extio_eventPut (extio_input event)
 Put an external io event to a queue
  • Put an external io event to a queue.

void extio_isr (void)
 extio isr (to be called from dispatcher)
int extio_init (isrDisp_t *pIsrDisp)
 Initialize external i/o
  • initialize GPIO port F.

int extio_startup (void)
 startup external i/o
  • startup GPIO port F

int extio_ledConfig (extio_output iotype)
 Configure LED as an output.
int extio_swConfig (extio_input itype)
 Configure switch as an input.
int extio_ledOn (extio_output led)
 Turn on one led
  • Turn on one led according to input parameter.

int extio_ledOff (extio_output led)
 Turn off one led
  • Turn off one led according to input parameter.

int extio_ledToggle (extio_output led)
 Toggle one led
  • Toggle one led according to input parameter.

iostatus extio_ledStatus (extio_output led)
 Check led status
  • Check led status.

int extio_ledGroupOn (unsigned char ledMask)
 Turn on group of leds
  • Turn on group of leds according to ledMask.

int extio_ledGroupOff (unsigned char ledMask)
 Turn off group of leds
  • Turn off group of leds according to ledMask.

int extio_ledGroupToggle (unsigned char ledMask)
 Toggle group of leds
  • Toggle group of leds according to ledMask.

unsigned char extio_ledGroupStatus (unsigned char ledMask)
 Check the status of a group of leds
  • Check the status of a group of leds.

unsigned char extio_switchGroupStatusGet (unsigned char switchMask)
 Query the current status of switch.
int extio_eventSubscribe (extio_input IOInput)
 Subscribe an external io event to the callback table
  • Subscribe an external io event to the callback table.

int extio_eventUnsubscribe (extio_input IOInput)
 Unsubscribe an external io event to the callback table
  • Unsubscribe an external io event to the callback table.

int extio_callbackRegister (extio_input IOInput, tFuncPtr pFunc, void *pArg)
 Register call back function to the callback table
  • Register call back function to the callback table.

int extio_callbackUnregister (extio_input IOInput, tFuncPtr pFunc, void *pArg)
 Unregister call back function to the callback table
  • Unregister call back function to the callback table.

int extio_eventGet (extio_input *pEvent)
 Get an external io event from a queue
  • Get an external io event from a queue.

iostatus extio_switchStatusGet (extio_input IOInput)
 Query the current status of a switch.

Variables

extio_t extio_global
 extio global variable, EXTIO is a singleton only a single instance hence using a global one global variable is sufficient

Detailed Description

Target TLL6527v1-0 Compiler: VDSP++ Output format: VDSP++ "*.dxe"

Author:
Enqiang Sun
Date:
April 6th, 2010
LastChange:
Id
extio.c 967 2012-04-10 20:29:10Z rkangralkar

Define Documentation

#define BIT_CLEAR ( REGISER,
MASK   )     REGISTER = REGISTER & ~(MASK)

clear bit(s) defined by mask

#define BIT_SET ( REGISER,
MASK   )     REGISTER = REGISTER | MASK

set bit(s) defined by mask

#define INPUT_BITS   (0xFF00)

#define MAP_INPUT_TO_BIT ( INP   )     (0x1 << 8) << ((INP - 1) >> 1)

convert from Input Event number to bit mask

#define MAP_LED_TO_BIT ( LED   )     (0x1<<LED)

convert from LED number to bit in the bit pattern

#define OUTPUT_BITS   (0xFF)

LEDs are mapped to lower 8 bits of the register, push bottons and switches are mapped to higher 8 bits of the register.


Function Documentation

int extio_callbackRegister ( extio_input  IOInput,
tFuncPtr  pFunc,
void *  pArg 
)

Register call back function to the callback table

Parameters:

Parameters:
IOInput the event id
pFunc callback function pointer
pArg callback function parameter
Returns:
Zero on success. Negative value on failure.

return error if GPIO is used in a different function

register only if nothing is registered yet

int extio_callbackUnregister ( extio_input  IOInput,
tFuncPtr  pFunc,
void *  pArg 
)

Unregister call back function to the callback table

Parameters:

Parameters:
IOInput the event id
pFunc callback function pointer
pArg callback function parameter
Returns:
Zero on success. Negative value on failure.

int extio_eventGet ( extio_input pEvent  ) 

Get an external io event from a queue

Parameters:

Parameters:
pEvent the pointer to the io event
Returns:
the pointer to the external io event

int extio_eventPut ( extio_input  event  ) 

Put an external io event to a queue

Parameters:

Parameters:
event the event id
Returns:
Zero on success. Negative value on failure.

int extio_eventSubscribe ( extio_input  IOInput  ) 

Subscribe an external io event to the callback table

Parameters:

Parameters:
IOInput the event id
Returns:
Zero on success. Negative value on failure.

register event put as a call back, it will place the according event in queue

int extio_eventUnsubscribe ( extio_input  IOInput  ) 

Unsubscribe an external io event to the callback table

Parameters:

Parameters:
IOInput the event id
Returns:
Zero on success. Negative value on failure.

int extio_init ( isrDisp_t pIsrDisp  ) 

Initialize external i/o

Parameters:

Parameters:
pIsrDisp pointer to ISR Dispatcher
Returns:
Zero on success. Negative value on failure.

initialize event queue

register own ISR with isr dispatcher

initialize the event table

return error if GPIO is used in a different function

Default initialization Set 0-7 as OUTPUT 8-15 as input

void extio_isr ( void   ) 

extio isr (to be called from dispatcher)

Parameters:

Parameters:
pThis pointer to own object
Returns:
None

lowest button input

int extio_ledConfig ( extio_output  iotype  ) 

Configure LED as an output.

Parameters:

Parameters:
iotype LED to configure

return error if GPIO is used in a different function

int extio_ledGroupOff ( unsigned char  ledMask  ) 

Turn off group of leds

Parameters:

Parameters:
ledMask led mask
Returns:
Zero on success. Negative value on failure.

int extio_ledGroupOn ( unsigned char  ledMask  ) 

Turn on group of leds

Parameters:

Parameters:
ledMask led mask
Returns:
Zero on success. Negative value on failure.

unsigned char extio_ledGroupStatus ( unsigned char  ledMask  ) 

Check the status of a group of leds

Parameters:

Parameters:
ledMask led mask
Returns:
an unsigned char indicating the leds status.

int extio_ledGroupToggle ( unsigned char  ledMask  ) 

Toggle group of leds

Parameters:

Parameters:
ledMask led mask
Returns:
Zero on success. Negative value on failure.

int extio_ledOff ( extio_output  led  ) 

Turn off one led

Parameters:

Parameters:
iotype led number
Returns:
Zero on success. Negative value on failure.

int extio_ledOn ( extio_output  led  ) 

Turn on one led

Parameters:

Parameters:
iotype led number
Returns:
Zero on success. Negative value on failure.

iostatus extio_ledStatus ( extio_output  led  ) 

Check led status

Parameters:

Parameters:
iotype led number
Returns:
iostatus of the led

int extio_ledToggle ( extio_output  led  ) 

Toggle one led

Parameters:

Parameters:
iotype led number
Returns:
Zero on success. Negative value on failure.

int extio_startup ( void   ) 

startup external i/o

Parameters:

Returns:
Zero on success. Negative value on failure.

int extio_swConfig ( extio_input  itype  ) 

Configure switch as an input.

Parameters:

Parameters:
iotype switch to configure

return error if GPIO is used in a different function

unsigned char extio_switchGroupStatusGet ( unsigned char  switchMask  ) 

Query the current status of switch.

Parameters:

Parameters:
IOInput switch to query (could be pushed or released)
Returns:
status of the switch EXTIO_SWITCH_ON if pushed / switched on EXTIO_SWITCH_OFF if not pushed / switched off

iostatus extio_switchStatusGet ( extio_input  IOInput  ) 

Query the current status of a switch.

Parameters:

Parameters:
IOInput switch to query (could be pushed or released)
Returns:
status of the switch EXTIO_SWITCH_ON if pushed / switched on EXTIO_SWITCH_OFF if not pushed / switched off


Variable Documentation

extio_t extio_global

extio global variable, EXTIO is a singleton only a single instance hence using a global one global variable is sufficient


Generated on 3 Mar 2014 for PAL bare-c Library by  doxygen 1.4.7