/******************************************************************************/
/* */
/* Technical Innovations N Solution (TINS) Design Unit */
/* */
/******************************************************************************/
/* */
/* All Rights Reserved Copyright (C) 2010, Technical Innovations N Solutions. */
/* */
/* Redistribution and use in source and binary forms, with or without */
/* modification, are not permitted in any case */
/* */
/* TINS's name may not be used to endorse or promote products derived from */
/* this software without specific prior written permission. */
/* */
/******************************************************************************/
/******************************************************************************/
/* All Rights Reserved Copyright (C) 2010, Technical Innovations N Solutions. */
/* */
/* \File Name : IRDA.c */
/* \Author : SAIKANTH */
/* \Version : IRDA_IRDA */
/* \Date : 20/04/2011 */
/* */
/* FLL_Driver Software Framework */
/******************************************************************************/
/******************************************************************************/
/* System Header files */
/******************************************************************************/
#include <msp430x47x3.h>
/******************************************************************************/
/* User Header Files Section */
/******************************************************************************/
#if 0
#include "IRDA.h"
#include "IRDA_Priv.h"
INT8U u8_gRec0Byte = 0;
INT8U u8_gIRDAFlag =0;
INT8U u8_gIRDABuff[30];
INT8U u8_gIndex = 0;
INT8U u8_gIRDATxRxBuffer[48] = {0, };
INT8U *p_gIRDATxRxBufferPtr;
/******************************************************************************/
/* Function Name: __interrupt void USCIAB0RX_ISR(void) */
/* */
/* Description : ISR of USCIAB0 both A0 and B0 register of USCI */
/* */
/* Parameter : void */
/* */
/* Return Value : void */
/* */
/* Remarks : None */
/******************************************************************************/
#pragma vector = USCIAB0RX_VECTOR
__interrupt void USCIAB0RX_ISR(void)
{
while(!(IFG2 & UCA0RXIFG));
/* Get the Receive Byte */
u8_gRec0Byte = UCA0RXBUF;
if(u8_gRec0Byte == '@')
{
u8_gIndex = 0;
}
else if(u8_gRec0Byte == '#')
{
u8_gIRDAFlag = 1;
u8_gIRDABuff[u8_gIndex] = '\0';
}
else
{
u8_gIRDABuff[u8_gIndex] = u8_gRec0Byte;
u8_gIndex = u8_gIndex + 1;
}
}
/******************************************************************************/
/* Function Name: __interrupt void USCIAB0RX_ISR(void) */
/* */
/* Description : ISR of USCIAB0 both A0 and B0 register of USCI */
/* */
/* Parameter : void */
/* */
/* Return Value : void */
/* */
/* Remarks : None */
/******************************************************************************/
#pragma vector = USCIAB0TX_VECTOR
__interrupt void USCIAB0TX_ISR(void)
{
if(*p_gIRDATxRxBufferPtr != 0x00)
{
/* Load New Data */
UCA0TXBUF = *p_gIRDATxRxBufferPtr;
/* Increament Tx Buffer Ptr */
p_gIRDATxRxBufferPtr = p_gIRDATxRxBufferPtr + 1;
}
else
{
/* Disable the Tx Interrupt */
IE2 &= ~UCA0TXIE;
/* Enable the Rx Interrupt */
IE2 |= UCA0RXIE;
}
}
/******************************************************************************/
/* Function Name: void USCIA_IRDAInit(INT8U u8_fRegSel, ST_IRDA_CONFIG_PARAMS*/
/* *st_pIRDAParams)*/
/* */
/* Description : IRDA Initialization */
/* */
/* Parameter : U8_fIRDARegSel: */
/* u8_fIRDAModeSel: */
/* */
/* Return Value : void */
/* */
/* Remarks : None */
/******************************************************************************/
void USCIA_IRDAInit(INT8U u8_fDeviceSel)
{
switch(u8_fDeviceSel)
{
case IRDA_USCIA0:
{
/* set the Software Reset */
UCA0CTL1 |= UCSWRST;
/* Selecting the sub Master Clock */
UCA0CTL1 |= UCSSEL_2 + UCSWRST;
/* Set 1st Stage Modulator to 1, 16-times Oversampling mode Enable */
UCA0MCTL = UCBRF_1 + UCOS16;
/* Calculating Baud rate at 115200 * 16 = 153.8 KHZ */
UCA0BR0 = 5;
/* Calculating Baud rate at 1MHZ*/
UCA0BR1 = 0;
/* Pulse length = 5 half clock cyc, Enable BITCLK16, IrDA enc/dec */
UCA0IRTCTL |= (30 << 2) + UCIREN;
/* Configuring the port pins as Peripheral */
P2SEL |= BIT4 + BIT5;
/* Clear the Software Reset */
UCA0CTL1 &= ~UCSWRST;
/* Enter LPM0 w/ interrupts */
__bis_SR_register(GIE);
/* Enable RX Interrupt */
IE2 = UCA0RXIE;
}
break;
case IRDA_USCIA1:
{
/* set the Software Reset */
UCA1CTL1 = UCSWRST;
/* Selecting the sub Master Clock */
UCA1CTL1 |= UCSSEL_2 + UCSWRST;
/* Calculating Baud rate 9600 * 16 = 153600, 8MHz/