Llosa de Viango Tollos – lpcSysIO.c



Getting started



  Tollos libraries

  Device libraries





  Sample application


lpcSysIO.c – system-dependent core functions

These are processor-specific functions for Tollos.

They should not normally be used directly by applications.
 sysFeedDogIO   feed the watchdog (if started)
 sysInitProcIO   initialize processor base function [startup]
 sysIRQIO   enable or disable an interrupt
 sysPowerIO   set a power mode and wait for interrupt
 sysQueryIO   query a system item
 sysSetIO   set a system item

sysFeedDogIO – feed the watchdog (if started)

void sysFeedDogIO(void);

Once the watchdog has been started, this function is called to reset its counter and prevent a Watchdog Reset. If called before the watchdog is started it has no effect.

sysInitProcIO – initialize processor base function [startup]

int sysInitProcIO(void);

returns 0 if OK, −1 if error (but probably cannot recover)

This must be called before any other sysIO functions; it:

– initializes the processor [SystemInit or equivalent]

– sets the system core clock frequency (processor speed)

– maps the vector table to the start of RAM

Assumptions (cases catered for):

– there is either an external crystal or oscillator, so &chipCrystal will be non-zero

– speed will be set to highest of 48, 72, or 96 MHz if possible to allow setting of USB 48 MHz [in future it will make more sense to use PLL1 for USB, but needs some research to ensure this does not exclude devices; also the current approach keeps the code parallel with STM32]

– chipMaxClock will always be at least twice the external clock

– main oscillator is 2 -> 20 MHz (could be raised to 25 MHz using OSCRANGE bit)

sysIRQIO – enable or disable an interrupt

int sysIRQIO(int index, flag enable, uint level);

index – vector table index number (see sysVector; 0=WDT)

enable – 1 to enable, 0 to disable

level – priority level (if enabling) [0..15, 0=high]

returns 0 if OK, −1 if index is out of range [−14..max],

or −2 if level is too large

This function can be used to change the system vectors, such as SysTick, by using a negative index; these ‘core’ interrupts cannot be disabled.

sysPowerIO – set a power mode and wait for interrupt

void sysPowerIO(uint item);

item – a constant listed in tollosIO.h

Valid items are:

SYSTEM_DEEPPOWERDOWN – power off until Reset or RTC wake

SYSTEM_DEEPSLEEP – unclocked sleep

SYSTEM_POWERDOWN – power down (unclocked, slow start)

SYSTEM_SLEEP – idle (Wait For Interrupt)

Currently Tollos only uses SLEEP and DEEPPOWERDOWN.

sysQueryIO – query a system item

int sysQueryIO(uint item);

item – a constant listed in tollosIO.h

returns current value of the item; negative generally indicates failure

Valid items are:

SYSTEM_CLOCK – clock speed, Hz

SYSTEM_RESET – 0 if last reset was normal (POR or Reset pin), 1 if abnormal (Watchdog or Brownout)

SYSTEM_SYSTICK – SysTick interval in us

SYSTEM_WATCHDOG – Watchdog interval in us

sysSetIO – set a system item

int sysSetIO(uint item, int value);

item – a constant listed in tollosIO.h

value – value to set the item to

returns previous value of the item, or a negative number if an error or unknown

Valid items are:

SYSTEM_SYSTICK – SysTick interval in microseconds [>0, maximum depends on clock rate]

SYSTEM_WATCHDOG – Watchdog interval in microseconds [>=0, will be rounded up to 256 if less]

Tollos and these web pages were written by Mike Cowlishaw; Please send me any corrections, suggestions, etc.
All content © Mike Cowlishaw, 2010–2012, except where marked otherwise. All rights reserved. The pages here are for non-commercial use only (see the separate licence for Tollos source code). Privacy policy: the Speleotrove website records no personal information and sets no ‘cookies’. However, statistics, etc. might be recorded by the web hosting service.

This page was last updated on 2012-02-19 by c2wiki.