Main Page | Modules | Data Structures | File List | Data Fields | Globals

sim.h File Reference

SIM functions. More...

#include <68332/types.h>

Go to the source code of this file.

Defines

#define FCRYSTAL   32768L
#define CLOCK8MHZ   0x3f00
#define CLOCK16MHZ   0x7f00
#define CLOCK25MHZ   0xd700

Enumerations

enum  reset_state_t {
  RESET_EXT, RESET_POW, RESET_SW, RESET_HLT,
  RESET_SYS, RESET_TST
}

Functions

int set_sim_iarb (int iarb)
int set_processor_speed (int speed)
uint32 get_processor_freq (void)
reset_state_t get_reset_state (void)
uint8 read_porte (void)
void write_porte (uint8 val)
int set_porte_data_direction (uint8 direction_mask)
int set_porte_pin_assignment (uint8 pin_assignment)
uint8 read_portf (void)
void write_portf (uint8 val)
int set_portf_data_direction (uint8 direction_mask)
int set_portf_pin_assignment (uint8 pin_assignment)
int set_watchdog (int enable, int prescale, int timeout)
void reset_watchdog (void)
int periodic_interrupt_setup (void(*function)(), int level, int vector, int prescale, uint8 timer)
void barrier_read_uint16 (uint16 val)
void barrier (void)


Detailed Description

This file contains the global function prototypes and data structures for SIM support in libsim.

To use the functions defined in this file, include <68332/sim.h> and link libsim.a.


Define Documentation

#define FCRYSTAL   32768L
 

#define CLOCK8MHZ   0x3f00
 

8.389 Mhz

#define CLOCK16MHZ   0x7f00
 

16.778 Mhz

#define CLOCK25MHZ   0xd700
 

25.166 Mhz


Enumeration Type Documentation

enum reset_state_t
 

Possible reset states.

Enumeration values:
RESET_EXT  reset via the RESET pin
RESET_POW  reset via power on
RESET_SW  software watchdog reset
RESET_HLT  halt monitor reset
RESET_SYS  reset via RESET instruction
RESET_TST  reset via test module


Function Documentation

int set_sim_iarb int  iarb  ) 
 

Set the interrupt arbitration ID for the SIM.

Parameters:
iarb Valid iarb levels are 0x0 - 0xf.
Returns:
0 on success, nonzero on failure.

int set_processor_speed int  speed  ) 
 

Set processor speed.

This function will not return until the SLOCK bit shows the synthesizer is locked in on the set speed.

Parameters:
speed It is suggested the constants CLOCK8MHZ, CLOCK16MHZ and CLOCK25MHZ are used. The upper 8-bits of this value are placed into the upper 8-bits of the clock synthesizer control register. This
Returns:
0 on success, nonzero on failure.

uint32 get_processor_freq void   ) 
 

Get processor speed.

This function returns the current CPU frequency (measured in cycles per second) based on the settings of the SYNCR register.

reset_state_t get_reset_state void   ) 
 

Query how the processor was reset.

Returns:
One of the enumerated types of reset_state_t. A negative return value indicates an error.

uint8 read_porte void   ) 
 

Reads IO port E.

Returns:
The current 8-bit value of the PORTE data register.

void write_porte uint8  val  ) 
 

Writes IO port E.

int set_porte_data_direction uint8  direction_mask  ) 
 

Sets the data direction register for IO port E.

Set the pins on port E to input or output.

Parameters:
direction_mask An 8-bit value with each bit corresponding to a pin on port E. Setting a bit to 1 makes the pin an output. Setting a bit to 0 makes the pin an input.
Returns:
0 on success, nonzero on error.

int set_porte_pin_assignment uint8  pin_assignment  ) 
 

Sets the pin assignment for IO port E.

Sets pins in port E to either standard I/O, or a control bus signal. See section D.2.8 of the 68332 users guide for details.

Parameters:
pin_assignment An 8-bit value with each bit corresponding to a pin on port E. Setting a bit to 1 sets it to a control signal (as in section D.2.8). Setting a bit to 0 sets it to a port E pin.
Returns:
0 on success, nonzero on error.

uint8 read_portf void   ) 
 

Reads IO port F.

Returns:
The current 8-bit value of the PORTF data register.

void write_portf uint8  val  ) 
 

Writes IO port F.

int set_portf_data_direction uint8  direction_mask  ) 
 

Sets the data direction register for IO port F.

Set the pins on port F to input or output.

Parameters:
direction_mask An 8-bit value with each bit corresponding to a pin on port F. Setting a bit to 1 makes the pin an output. Setting a bit to 0 makes the pin an input.
Returns:
0 on success, nonzero on error.

int set_portf_pin_assignment uint8  pin_assignment  ) 
 

Set the pin assignment for IO port F.

Sets pins in port F to either standard I/O, or a control bus signal. See section D.2.11 of the 68332 users guide for details.

Parameters:
pin_assignment An 8-bit value with each bit corresponding to a pin on port F. Setting a bit to 1 sets it to a control signal (as in section D.2.11). Setting a bit to 0 sets it to a port F pin.
Returns:
0 on success, nonzero on error.

int set_watchdog int  enable,
int  prescale,
int  timeout
 

Control the system watchdog.

Turns on/off the system watchdog. This can be used to reset the system if the watchdog timer is not reset (see reset_watchdog()).

Parameters:
enable 0 = watchdog disable. 1 = watchdog enable.
prescale 0 = watchdog clock not prescaled. 1 = watchdog clock prescaled by 512.
timeout 0 = watchdog timeout after 2^9 ticks. 1 = watchdog timeout after 2^11 ticks. 2 = watchdog timeout after 2^13 ticks. 3 = watchdog timeout after 2^15 ticks.
Returns:
0 on success, nonzero on error.

void reset_watchdog void   ) 
 

Resets the watchdog timer.

Must be called before the watchdog timer times out to prevent the system from resetting.

int periodic_interrupt_setup void(*  function)(),
int  level,
int  vector,
int  prescale,
uint8  timer
 

Set up a periodic timer interrupt function.

Parameters:
function C function to be called on interrupt.
level Interrupt request level.
vector Interrupt request vector.
prescale 0 = periodic timer not prescaled. 1 = periodic timer prescaled by 512.
timer Clock ticks to run before interrupt is triggered (8-bits).
Returns:
0 on success, nonzero on failure.

void barrier_read_uint16 uint16  val  ) 
 

No-op routine that allows a parameter to be passed. Used to prevent instruction reordering by the compiler.

Parameters:
val Allows a uint16 to be read as part of this call

void barrier void   ) 
 

No-op routine used to prevent instruction reordering by the compiler.


Generated on Wed Sep 6 03:02:22 2006 for MotoRobots by doxygen 1.3.6