KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
lm32.h File Reference

Low level routines for LM32, including interrupt handling. More...

#include <stdio.h>
#include <stdbool.h>
#include <stdint.h>
#include "util/macro.h"

Go to the source code of this file.

Macros

#define _IRQ_HANDLER(IRQ)   irq ## IRQ ## Handler()
 
#define IRQ_HANDLER(IRQ)   _IRQ_HANDLER(IRQ)
 Defines an IRQ handler. More...
 
#define PSTATE_R1   0
 register 1
 
#define PSTATE_R2   1
 register 2
 
#define PSTATE_R3   2
 register 3
 
#define PSTATE_R4   3
 register 4
 
#define PSTATE_R5   4
 register 5
 
#define PSTATE_R6   5
 register 6
 
#define PSTATE_R7   6
 register 7
 
#define PSTATE_R8   7
 register 8
 
#define PSTATE_R9   8
 register 9
 
#define PSTATE_R10   9
 register 10
 
#define PSTATE_RA   10
 return address (from IRQ = PC at the moment or interrupt)
 
#define PSTATE_EA   11
 exception address
 
#define PSTATE_BA   12
 break pointer address
 

Functions

static void __irqDisable ()
 Disables IRQ's on a global level. More...
 
static void __irqEnable ()
 Enabled IRQ's on a global level. More...
 
static bool __isIrqEnable ()
 
static void __nop ()
 No-operation.
 
void irqMaskSet (int irq, bool set)
 Set/clear the interrupt mask for the specified IRQ. More...
 
bool irqMaskGet (int irq)
 Returns the current IRQ mask for the specified IRQ. More...
 
static uint32_t cycCount ()
 Returns the value of the cycle counter.
 
void reboot ()
 Soft reboot the LM32.
 
static uint32_t ramSize ()
 Get the of the RAM. More...
 
static uint32_t ramUsed ()
 Get the RAM used by variables (excluding stack). More...
 
static uint32_t romSize ()
 Get the of the ROM. More...
 
static uint32_t romUsed ()
 Get the ROM used by code, variables and constants. More...
 

Variables

uint32_t * pState
 Program state before IRQ. More...
 
volatile bool inIrqContext
 Returns whether or not we're in an IRQ context. More...
 
uint32_t _end
 
const uint8_t _ram_offset
 
const uint8_t _ram_size
 
const uint8_t _rom_offset
 
const uint8_t _rom_end
 
const uint8_t _rom_size
 

Detailed Description

Low level routines for LM32, including interrupt handling.

Definition in file lm32.h.

Macro Definition Documentation

#define IRQ_HANDLER (   IRQ)    _IRQ_HANDLER(IRQ)

Defines an IRQ handler.

Should be used by the driver to capture IRQ's.

void IRQ_HANDLER(UART_IRQ) {
// get character
}
Parameters
IRQThe IRQ number.

Definition at line 47 of file lm32.h.

Function Documentation

static void __irqDisable ( )
inlinestatic

Disables IRQ's on a global level.

It does not clear the interrupt masks, so when re-enabled all previously enabled IRQs will be handled.

Definition at line 62 of file lm32.h.

static void __irqEnable ( )
inlinestatic

Enabled IRQ's on a global level.

Pending IRQs will be handled.

Definition at line 75 of file lm32.h.

bool irqMaskGet ( int  irq)

Returns the current IRQ mask for the specified IRQ.

Parameters
irqThe IRQ to check.

Definition at line 105 of file lm32.c.

void irqMaskSet ( int  irq,
bool  set 
)

Set/clear the interrupt mask for the specified IRQ.

Parameters
irqThe IRQ to set or clear.
setWhen 0, clears the IRQ, when 1 sets it.

Note that when enabling IRQ's, any pending IRQs may be activated.

Definition at line 77 of file lm32.c.

static uint32_t ramSize ( )
inlinestatic

Get the of the RAM.

Returns
Size of RAM in bytes.

Definition at line 184 of file lm32.h.

static uint32_t ramUsed ( )
inlinestatic

Get the RAM used by variables (excluding stack).

Returns
Used RAM in bytes.

Definition at line 194 of file lm32.h.

static uint32_t romSize ( )
inlinestatic

Get the of the ROM.

Returns
Size of ROM in bytes.

Definition at line 207 of file lm32.h.

static uint32_t romUsed ( )
inlinestatic

Get the ROM used by code, variables and constants.

Returns
Used ROM in bytes.

Definition at line 218 of file lm32.h.

Variable Documentation

volatile bool inIrqContext

Returns whether or not we're in an IRQ context.

Do not write this value!

Definition at line 30 of file lm32.c.

uint32_t* pState

Program state before IRQ.

For example, to get the program counter at interrupt, use this in an interrupt routine: uint32_t pcAtIrq = pState[PSTATE_RA];

Definition at line 28 of file lm32.c.