AVR Z-LINKŪ


serialPortHAL.h

Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00024 #ifndef SERIAL_PORT_HAL_H
00025 #define SERIAL_PORT_HAL_H
00026 
00027 #define UART
00028 //#define FTDI
00029 
00030 #if defined( UART ) && defined( FTDI )
00031         #error Only able to support UART or FTDI USB phy interface.
00032 #endif
00033 
00034 /* === Includes ============================================================ */
00035 #include<stdbool.h>
00036 #include<stdint.h>
00037 
00038 #include "compiler.h"
00039 
00040 #include"chat.h"
00041 
00042 #ifdef UART
00043 #include"usart.h"
00044 #else
00045 #include"ftdi.h"
00046 #endif
00047 /* ==== Macros ============================================================= */
00048 #define RECEIVE_BUFFER_SIZE 64
00049 
00050 #ifdef UART
00051 
00052 #define RECEIVER_ON                     ENABLE_RECEIVE_COMPLETE_INTERRUPT
00053 #define RECEIVER_OFF            DISABLE_RECEIVE_COMPLETE_INTERRUPT
00054 #else
00055 
00056 #define RECEIVER_ON                     FTDI_ENABLE_RECEIVER( )
00057 #define RECEIVER_OFF            FTDI_DISABLE_RECEIVER( )
00058 #endif
00059 
00060 #define PARAMETER_DELIMITER ','
00061 #define PARAMETER_PREAMBLE_A ':'
00062 #define PARAMETER_PREAMBLE_B ' '
00063 #define EOC_DELIMITER '\r'
00064 
00065 #define NULL_PARAMETER ((unsigned char *)0)
00066 /* === Typedefs ============================================================ */
00067 
00071 typedef enum{
00072         
00073         SOC = 0x00,     //StartOfCommand.
00074         PARAM_PREAMBLE,         //": "
00075         COLLECT_PARAMETERS,
00076         EOC     //EndOfCommand.
00077 }rxState_t;
00078 
00081 typedef enum{
00082         
00083         NO_ERROR = 0x00,
00084         BUFFER_OVERFLOW,
00085         UNKNOWN_RX_STATE,
00086         UNKNOWN_SEQUENCE,
00087         UNKNOWN_EOC_SEQUENCE
00088 }rxError_t;
00089 
00092 typedef struct{
00093 
00094         #define LENGTH_OF_COMMAND 4
00095         unsigned char ATCommand[ LENGTH_OF_COMMAND + 1 ]; //+1 to store '\0' sequence.
00096         uint8_t rx_i;
00097         
00098         #define LENGTH_OF_PARAMETER_BUFFER 64
00099         #define NUMBER_OF_PARAMETERS 4
00100         unsigned char parameters[ LENGTH_OF_PARAMETER_BUFFER ];
00101         unsigned char *parameter[ NUMBER_OF_PARAMETERS ];
00102         uint8_t numberOfReceivedParameters;
00103         
00104         bool receptionComplete;
00105         rxError_t error;
00106 }rxDataBlock_t;
00107 
00110 typedef enum{
00111         PARAMETER_1     = 0x00,
00112         PARAMETER_2     = 0x01,
00113         PARAMETER_3     = 0x02
00114 }paramter_t;
00115 /* === Static Variables ==================================================== */
00116 /* === Prototypes ========================================================== */
00117 void sendString( const unsigned char *string );
00118 void sendFlashString( const unsigned char __flash *string );
00119 void sendOK( void );
00120 void sendERROR( const chatError_t err );
00121 void sendAssociationNotification( void );
00122 void sendDisAssociationNotification( void );
00123 void sendDataNotification( uint8_t length, unsigned char *data );
00124 void serialInterfaceInitialization( void );
00125 void rxReset( void );
00126 unsigned char * getATCommand( void );
00127 unsigned char * getParameterNumber( paramter_t parameterNumber );
00128 rxError_t getError( void );
00129 bool dataAvailable( void );
00130 
00131 #ifdef UART
00132         ISR( USART0_RX_vect );
00133 #else
00134         ISR( INT7_vect );
00135 #endif
00136 #endif
@DOC_TITLE@
Generated on Sat Dec 2 16:05:51 2006 for AVR414 User's Guide - ATAVRRZ502 - Accessory Kit by doxygen 1.4.7