MIOS32_SYS

Defines

#define MEM32(addr)   (*((volatile u32 *)(addr)))
#define MEM16(addr)   (*((volatile u16 *)(addr)))
#define MEM8(addr)   (*((volatile u8 *)(addr)))
#define NUM_DMA_CHANNELS   8
#define MEM32(addr)   (*((volatile u32 *)(addr)))
#define MEM16(addr)   (*((volatile u16 *)(addr)))
#define MEM8(addr)   (*((volatile u8 *)(addr)))
#define EXT_CRYSTAL_FRQ   12000000
#define RTC_PREDIVIDER   (EXT_CRYSTAL_FRQ/128)
#define MEM32(addr)   (*((volatile u32 *)(addr)))
#define MEM16(addr)   (*((volatile u16 *)(addr)))
#define MEM8(addr)   (*((volatile u8 *)(addr)))
#define EXT_CRYSTAL_FRQ   8000000
#define PLL_M   8
#define PLL_N   336
#define PLL_P   2
#define PLL_Q   7

Functions

s32 MIOS32_SYS_Init (u32 mode)
s32 MIOS32_SYS_Reset (void)
u32 MIOS32_SYS_ChipIDGet (void)
u32 MIOS32_SYS_FlashSizeGet (void)
u32 MIOS32_SYS_RAMSizeGet (void)
s32 MIOS32_SYS_SerialNumberGet (char *str)
s32 MIOS32_SYS_TimeSet (mios32_sys_time_t t)
mios32_sys_time_t MIOS32_SYS_TimeGet (void)
s32 MIOS32_SYS_DMA_CallbackSet (u8 dma, u8 chn, void *callback)
void DMA_IRQHandler (void)

Variables

u32 mios32_sys_isr_vector
u32 mios32_sys_isr_vector
u32 mios32_sys_isr_vector

Detailed Description

System Initialisation for MIOS32


Define Documentation

#define EXT_CRYSTAL_FRQ   8000000
#define EXT_CRYSTAL_FRQ   12000000
#define MEM16 ( addr   )     (*((volatile u16 *)(addr)))
#define MEM16 ( addr   )     (*((volatile u16 *)(addr)))
#define MEM16 ( addr   )     (*((volatile u16 *)(addr)))
#define MEM32 ( addr   )     (*((volatile u32 *)(addr)))
#define MEM32 ( addr   )     (*((volatile u32 *)(addr)))
#define MEM32 ( addr   )     (*((volatile u32 *)(addr)))
#define MEM8 ( addr   )     (*((volatile u8 *)(addr)))
#define MEM8 ( addr   )     (*((volatile u8 *)(addr)))
#define MEM8 ( addr   )     (*((volatile u8 *)(addr)))
#define NUM_DMA_CHANNELS   8
#define PLL_M   8
#define PLL_N   336
#define PLL_P   2
#define PLL_Q   7
#define RTC_PREDIVIDER   (EXT_CRYSTAL_FRQ/128)

Function Documentation

void DMA_IRQHandler ( void   ) 
u32 MIOS32_SYS_ChipIDGet ( void   ) 

Returns the Chip ID of the core

Returns:
the chip ID
s32 MIOS32_SYS_DMA_CallbackSet ( u8  dma,
u8  chn,
void *  callback 
)

Installs a DMA callback function which is invoked on DMA interrupts
Available for LTC17xx (and not STM32) since it only provides a single DMA interrupt which is shared by all channels.

Parameters:
[in] dma the DMA number (currently always 0)
[in] chn the DMA channel (0..7)
[in] callback the callback function which will be invoked by DMA ISR
Returns:
-1 if function not implemented for this MIOS32_PROCESSOR
-2 if invalid DMA number is selected
-2 if invalid DMA channel selected
u32 MIOS32_SYS_FlashSizeGet ( void   ) 

Returns the Flash size of the core

Returns:
the Flash size in bytes
s32 MIOS32_SYS_Init ( u32  mode  ) 

Initializes the System for MIOS32:

  • enables clock for IO ports
  • configures pull-ups for all IO pins
  • initializes PLL for 72 MHz @ 12 MHz ext. clock
    (skipped if PLL already running - relevant for proper software reset, e.g. so that USB connection can survive)
  • sets base address of vector table
  • configures the suspend flags in DBGMCU_CR as specified in MIOS32_SYS_STM32_DBGMCU_CR (can be overruled in mios32_config.h) to simplify debugging via JTAG
  • enables the system realtime clock via MIOS32_SYS_Time_Init(0)
Parameters:
[in] mode currently only mode 0 supported
Returns:
< 0 if initialisation failed

Here is the call graph for this function:

u32 MIOS32_SYS_RAMSizeGet ( void   ) 

Returns the (data) RAM size of the core

Returns:
the RAM size in bytes
s32 MIOS32_SYS_Reset ( void   ) 

Shutdown MIOS32 and reset the microcontroller:

  • disable all RTOS tasks
  • print "Bootloader Mode " message if LCD enabled (since MIOS32 will enter this mode after reset)
  • wait until all MIDI OUT buffers are empty (TODO)
  • disable all interrupts
  • turn off all board LEDs
  • send all-0 to DOUT chain (TODO)
  • send all-0 to MF control chain (if enabled) (TODO)
  • reset STM32
Returns:
< 0 if reset failed

Here is the call graph for this function:

s32 MIOS32_SYS_SerialNumberGet ( char *  str  ) 

Returns the serial number as a string

Parameters:
[out] str pointer to a string which can store at least 32 digits + zero terminator! (24 digits returned for STM32)
Returns:
< 0 if feature not supported
mios32_sys_time_t MIOS32_SYS_TimeGet ( void   ) 

Returns the System Real Time (with mS accuracy)

Following example code converts the returned time into hours, minutes, seconds and milliseconds:

   mios32_sys_time_t t = MIOS32_SYS_TimeGet();
   int hours = t.seconds / 3600;
   int minutes = (t.seconds % 3600) / 60;
   int seconds = (t.seconds % 3600) % 60;
   int milliseconds = t.fraction_ms;
Returns:
the system time in a mios32_sys_time_t structure

Here is the call graph for this function:

s32 MIOS32_SYS_TimeSet ( mios32_sys_time_t  t  ) 

Initializes/Resets the System Real Time Clock, so that MIOS32_SYS_Time() can be used for microsecond accurate measurements.

The time can be re-initialized the following way:

   // set System Time to one hour and 30 minutes
   mios32_sys_time_t t = { .seconds=1*3600 + 30*60, .fraction_ms=0 };
   MIOS32_SYS_TimeSet(t);

After system reset it will always start with 0. A battery backup option is not supported by MIOS32

Parameters:
[in] t the time in seconds + fraction part (mS)
Note that this format isn't completely compatible to the NTP timestamp format, as the fraction has only mS accuracy
Returns:
< 0 if initialisation failed

Variable Documentation


Generated on 22 Jan 2016 for MIOS32 by  doxygen 1.6.1