hsk_libs-dev  163:b63ae088cc97
High Speed Karlsruhe XC878 library collection
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
hsk_ex.c File Reference

HSK External Interrupt Routing implementation. More...

#include <Infineon/XC878.h>
#include "hsk_ex.h"
#include "../hsk_isr/hsk_isr.h"
Include dependency graph for hsk_ex.c:

Macros

#define CNT_EXINT   2
 EXICON0/1 External Interrupt Trigger Select bit count. More...
 
#define BIT_EXINT0   0
 EXICON0 External Interrupt 0 Trigger Select bits. More...
 
#define BIT_EXINT1   2
 EXICON0 External Interrupt 1 Trigger Select bits. More...
 
#define BIT_EXINT2   4
 EXICON0 External Interrupt 2 Trigger Select bits. More...
 
#define BIT_EXINT3   6
 EXICON0 External Interrupt 3 Trigger Select bits. More...
 
#define BIT_EXINT4   0
 EXICON1 External Interrupt 4 Trigger Select bits. More...
 
#define BIT_EXINT5   2
 EXICON1 External Interrupt 5 Trigger Select bits. More...
 
#define BIT_EXINT6   4
 EXICON1 External Interrupt 6 Trigger Select bits. More...
 
#define BIT_IMODE   4
 SYSCON0 Interrupt Structure 2 Mode Select bit. More...
 
#define EX_EDGE_DISABLE   3
 Deactivate external interrupt. More...
 

Functions

void hsk_ex_channel_enable (const hsk_ex_channel channel, const ubyte edge, const void(*const callback)(void))
 Enable an external interrupt channel. More...
 
void hsk_ex_channel_disable (const hsk_ex_channel channel)
 Disables an external interrupt channel. More...
 
void hsk_ex_port_open (const hsk_ex_port port)
 Opens an input port for an external interrupt. More...
 
void hsk_ex_port_close (const hsk_ex_port port)
 Disconnects an input port from an external interrupt. More...
 

Variables

struct {
   ubyte   modpiselBit
 The MODPISEL[n] bit(s) to select. More...
 
   ubyte   modpiselSel
 The MODPISEL value. More...
 
   ubyte   portBit
 The port bit. More...
 
   ubyte   portAltsel
 The port ALTSEL (alternative select) setting. More...
 
hsk_ex_ports []
 External input configuration structure. More...
 

Detailed Description

HSK External Interrupt Routing implementation.

This file implements the methods necessary to route µC pins to external interrupts.

Author
kami

Macro Definition Documentation

#define BIT_EXINT0   0

EXICON0 External Interrupt 0 Trigger Select bits.

#define BIT_EXINT1   2

EXICON0 External Interrupt 1 Trigger Select bits.

#define BIT_EXINT2   4

EXICON0 External Interrupt 2 Trigger Select bits.

#define BIT_EXINT3   6

EXICON0 External Interrupt 3 Trigger Select bits.

#define BIT_EXINT4   0

EXICON1 External Interrupt 4 Trigger Select bits.

#define BIT_EXINT5   2

EXICON1 External Interrupt 5 Trigger Select bits.

#define BIT_EXINT6   4

EXICON1 External Interrupt 6 Trigger Select bits.

#define BIT_IMODE   4

SYSCON0 Interrupt Structure 2 Mode Select bit.

#define CNT_EXINT   2

EXICON0/1 External Interrupt Trigger Select bit count.

Function Documentation

void hsk_ex_channel_disable ( const hsk_ex_channel  channel)

Disables an external interrupt channel.

Parameters
channelThe channel to disable, one of External Interrupt Channels
void hsk_ex_channel_enable ( const hsk_ex_channel  channel,
const ubyte  edge,
const void(*)(void)  callback 
)

Enable an external interrupt channel.

It is good practice to enable a port for the channel first, because port changes on an active interrupt may cause an undesired interrupt.

The callback function can be set to 0 if a change of the function is not desired. For channels EXINT0 and EXINT1 the callback is ignored, implement interrupts 0 and 2 instead.

Parameters
channelThe channel to activate, one of External Interrupt Channels
edgeThe triggering edge, one of External Interrupt Triggers
callbackThe callback function for an interrupt event

Setting up EXINT0/1 is somewhat confusing. Refer to UM 1.1 section 5.6.2 to make sense of this.

void hsk_ex_port_close ( const hsk_ex_port  port)

Disconnects an input port from an external interrupt.

Parameters
portThe port to close, one of External Interrupt Input Ports
void hsk_ex_port_open ( const hsk_ex_port  port)

Opens an input port for an external interrupt.

Parameters
portThe port to open, one of External Interrupt Input Ports

Variable Documentation

hsk_ex_ports
Initial value:
= {
{1, 0, 5, 2},
{0, 0, 1, 2},
{1, 1, 4, 2},
{4, 0, 5, 2},
{5, 0, 6, 3},
{0, 2, 0, 3},
{2, 2, 2, 5},
{4, 2, 3, 1},
{5, 3, 4, 4},
{2, 0, 7, 2},
{0, 1, 0, 4},
{2, 2, 1, 1},
{5, 1, 2, 2},
{4, 1, 4, 3},
{5, 2, 5, 3},
{2, 1, 0, 2},
{3, 1, 1, 2},
{4, 3, 2, 2},
{2, 0, 3, 2},
{3, 0, 4, 2},
{0, 3, 5, 2},
{2, 3, 6, 2},
{5, 4, 7, 3}
}

External input configuration structure.

ubyte modpiselBit

The MODPISEL[n] bit(s) to select.

ubyte modpiselSel

The MODPISEL value.

ubyte portAltsel

The port ALTSEL (alternative select) setting.

ubyte portBit

The port bit.