CLEON  Version 1
Cloud-Offloaded GPS Receiver
sys_usb.c File Reference

USB related functions. More...

#include "cleon_conf.h"
#include "app_define.h"
#include "sys_define.h"
#include "hal_define.h"
#include "fs_define.h"
Include dependency graph for sys_usb.c:

Go to the source code of this file.

Functions

void SYS_USB_Init ()
 Initializing USB.
 
void SYS_USB_SendACK (unsigned char ucCommand)
 Sending USB frame ACK.
 
int SYS_USB_Printf (char *format,...)
 Mimic the standard 'printf' with USB as output device.
 
void SYS_USB_TransmitSingleByte (unsigned char ucData)
 Transmit a byte vis USB.
 
void SYS_USB_ReceiveFrame (unsigned char ucData)
 Receiving a bayte and test whether correct frame has been received.
 
unsigned char SYS_USB_BuildCRC (usb_frame_u *uniUSBFrame)
 Building CRC out of USB frame.
 

Variables

cleon_header_u uniCLEONHeader
 
cleon_gps_data_u uniCLEONGPSData
 
cleon_sensor_data_u uniCLEONSensorData
 
bool bFLAG_USBFrameReceived = _CLEAR_
 
bool bFLAG_USBConnected = _CLEAR_
 
usb_frame_u uniUSBRecvFrame = {0}
 
usb_frame_u uniUSBSendFrame = {0}
 
unsigned char ucUSBFrameByteCount = 0
 

Detailed Description

USB related functions.

Definition in file sys_usb.c.

Function Documentation

unsigned char SYS_USB_BuildCRC ( usb_frame_u uniUSBFrame)

Building CRC out of USB frame.

Returns
ucCheckOctet - generated CRC
Parameters
void

Definition at line 215 of file sys_usb.c.

{
unsigned char ucCheckOctet = 0;
for ( int i = 3 ; i < (USB_FRAME_LENGTH - 3) ; i++ ){
if( i == 0 ){
ucCheckOctet = (*uniUSBFrame).ucSingleByte[i];
}
if (i >= 1)
{
ucCheckOctet ^= (*uniUSBFrame).ucSingleByte[i];
}
}
ucCheckOctet = ~ucCheckOctet;
return ucCheckOctet;
}

Here is the caller graph for this function:

void SYS_USB_Init ( void  )

Initializing USB.

Returns
void
Parameters
void

Definition at line 37 of file sys_usb.c.

Here is the caller graph for this function:

int SYS_USB_Printf ( char *  format,
  ... 
)

Mimic the standard 'printf' with USB as output device.

      - Sending a byte (stream) to USB
Returns
index - number of bytes sent
Parameters
data- a byte to be sent to USB

Definition at line 91 of file sys_usb.c.

{
// Maximum length of data is 255
char buff[250];
int index = 0;
unsigned char data = 0;
va_list argptr; // Argument list
buff[0] = 0x00;
va_start( argptr,format); // Initializing the function
vsprintf(buff,format,argptr ); // Copying buffer
va_end( argptr ); // Finalizing the function
data = buff[index++]; // Loading data
while(data != 0x00){
//USCI_A1 TX buffer ready?
while (!(UCA1IFG&UCTXIFG)); // USCI_A1 TX buffer ready?
UCA1TXBUF = data;
data = buff[index++];
}
return(index);
}

Here is the caller graph for this function:

void SYS_USB_ReceiveFrame ( unsigned char  ucData)

Receiving a bayte and test whether correct frame has been received.

Returns
void
Parameters
ucData- recived single byte from USB

Definition at line 138 of file sys_usb.c.

{
case 0: case 1:
if(ucData == USB_FRAME_HEADER){
}else{
// request retransmission
}
break;
case 2:
(ucData > 0) && (ucData < USB_FRAME_COMMAND_AND_DATA_FIELD_LENGTH)){
}else{
// request retransmission
}
break;
case 3:
break;
case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13:
case 14: case 15: case 16: case 17: case 18: case 19: case 20: case 21: case 22: case 23:
case 24: case 25: case 26: case 27: case 28: case 29: case 30: case 31: case 32:
break;
case 33:
}else{
// request retransmission
}
break;
case 34:
if(ucData == USB_FRAME_FOOTER){
}else{
// request retransmission
}
break;
case 35:
if(ucData == USB_FRAME_FOOTER){
}else{
// request retransmission
}
break;
default:
// request retransmission
break;
}
}
}

Here is the call graph for this function:

Here is the caller graph for this function:

void SYS_USB_SendACK ( unsigned char  ucCommand)

Sending USB frame ACK.

Returns
void
Parameters
ucCommand- command to be sent

Definition at line 59 of file sys_usb.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void SYS_USB_TransmitSingleByte ( unsigned char  ucData)

Transmit a byte vis USB.

Returns
void
Parameters
ucData- data to be transmitted

Definition at line 123 of file sys_usb.c.

{
//USCI_A1 TX buffer ready?
while (!(UCA1IFG&UCTXIFG)); // USCI_A1 TX buffer ready?
UCA1TXBUF = ucData;
}

Here is the caller graph for this function:

Variable Documentation

bool bFLAG_USBConnected = _CLEAR_

Definition at line 20 of file sys_usb.c.

bool bFLAG_USBFrameReceived = _CLEAR_

Definition at line 19 of file sys_usb.c.

unsigned char ucUSBFrameByteCount = 0

Definition at line 27 of file sys_usb.c.

cleon_gps_data_u uniCLEONGPSData

Definition at line 14 of file sys_init.c.

cleon_header_u uniCLEONHeader

Definition at line 13 of file sys_init.c.

cleon_sensor_data_u uniCLEONSensorData

Definition at line 15 of file sys_init.c.

usb_frame_u uniUSBRecvFrame = {0}

Definition at line 23 of file sys_usb.c.

usb_frame_u uniUSBSendFrame = {0}

Definition at line 24 of file sys_usb.c.