/*==================================================================================================================================
** mcu.h
**==================================================================================================================================
** Microntroler hardware dependents export functions
**==================================================================================================================================
** Date Author Comment
** 28-08-2008 Diogenes Initial Version
**================================================================================================================================*/
#ifndef __MCU_H
#define __MCU_H
/* Include Area */
#include "types.h"
/* Types Area */
/* Supporteds SCI baud rates */
typedef enum
{
baud_1200,
baud_2400,
baud_4800,
baud_9600,
baud_19200,
baud_38400,
baud_57600,
baud_115200
}tBaudRate;
/* SPI transfer rate */
typedef enum
{
SPI_SlowClock, /* 300 KHz Standart mode */
SPI_FastClock /* 5 MHz Fast clock mode */
}tSPIClock;
/* Timer events */
typedef struct
{
dword Start;
dword Expiration;
}tTimerTime;
/* Led manage */
typedef enum
{
led_on,
led_off,
led_blink
}tLedType;
/* Init the MCU */
void MCU_Init( void );
/* Reset watch dog */
void WatchDog_Clear( void );
/* Software delay per miliseconds units */
void Delay( word MiliSeconds );
/* Manage the Led */
void SetLed( tLedType LedType );
/* Open SCI */
void SCI_Open( tBaudRate BaudRate );
/* Get chars in SCI input buffer */
byte SCI_GetAvailablesChars( void );
/* SCI Receive block */
void SCI_ReceiveBlock( byte *Ptr, byte Size, byte *Received );
/* SCI clear receive buffer */
void SCI_ClearRxBuf( void );
/* SPI init */
void SPI_Init( tSPIClock SPIClock );
/* Change SPI Clock */
void SPI_ChangeClock( tSPIClock SPIClock );
/* Send a byte to SPI */
void SPI_SendByte( byte Data );
/* Receive a byte from SPI */
byte SPI_ReceiveByte( void );
/* SS to low state */
void SPI_CSAssert( void );
/* SS to high state */
void SPI_CSDeassert( void );
/* Set time out timer event */
void SetTimerEvent( tTimerTime *Event, dword MiliSeconds );
/* Check if timer event has expired */
bool TimerHasExpired( tTimerTime *Event );
#endif