Llosa de Viango Tollos – stmSysIO.c

Introduction

Features

Getting started

Download


Libraries

  Tollos libraries

  Device libraries

    boards

    microcontrollers

    peripherals


Background

  Sample application

  Troubleshooting

stmSysIO.c – system-dependent core functions

These are processor-specific functions for Tollos.

They should not normally be used directly by applications.
Functions
 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

– compile script defines one of the STM32 devices, e.g., -DSTM32F10X_HD; this will need to change to make alternate libraries for _VL and _CL lines, and the code below also may need modification for these

– stm32f10x.h has the configurable HSE_VALUE modification (see stmf10x.txt); this is required for RCC calculations for peripherals (and SystemCoreClockUpdate) – however this does not fix SystemInit because this has hard-coded RCC_CFGR_PLLMULL9 multiplier

– speed will be set to highest of 48, 72, or 96 MHz if possible to allow setting of USB 48 MHz (STM32 devices do not currently support 96, but keeping the code the same as for LPC)

– chipMaxClock will always be at least twice the external clock

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.

For STM32 DEEPSLEEP and POWERDOWN are the same (Stop mode).

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; will be rounded up to a multiple of 4ms.

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.