Example #1
0
void SendCC(uint8_t no, uint8_t v) {
    while (Busy2USART());
    Write2USART(0xB0|CHANNEL);
    while (Busy2USART());
    Write2USART(no);
    while (Busy2USART());
    Write2USART(v);
    __delay_ms(1);
}
Example #2
0
void SendNoteOff(uint8_t no) {
    while (Busy2USART());
    Write2USART(0x80|CHANNEL);
    while (Busy2USART());
    Write2USART(no);
    while (Busy2USART());
    Write2USART(VELOCITY);
    clrbit(leds,no-octave*12);
    __delay_ms(1);
}
Example #3
0
SendNoteOn(uint8_t no) {
    while (Busy2USART());
    Write2USART(0x90|CHANNEL);
    while (Busy2USART());
    Write2USART(no);
    while (Busy2USART());
    Write2USART(VELOCITY);
    setbit(leds,no-octave*12);
    __delay_ms(1);
}
Example #4
0
/*Bluetooth UART Functions*/
void UART2_Write_Char(char data)
{
    while ( Busy2USART() );
    Write2USART(data);
/*
    while (!TXSTA2bits.TRMT);       //wait until transmit shift register is empty
    TXREG2 = data;                  //write character to TXREG and start transmission
*/
}
Example #5
0
// USB/USART combined put char (handles printf)
void _user_putc(unsigned char c)
{
#ifdef USE_USART
    putc1USART(c);
    while(Busy1USART()); 
#endif
#if defined(DEBUG_USART2_TX) || defined(UART2_DATA_OUTPUT)
    Write2USART(c);
    while(Busy2USART()); 
#endif
    usb_putchar(c);
}
Example #6
0
// http://microchip.wikidot.com/faq:29
void putch(char c)
{
#ifdef DEBUG
#ifdef WITH_HOS
    while (Busy2USART())
        CLRWDT();
    Write2USART(c);
    while (Busy2USART())
        CLRWDT();
#else
    while (Busy1USART())
        ;
    Write1USART(c);
    while (Busy1USART())
        ;
#endif
#endif
}
Example #7
0
void XBAPI_Tx(unsigned char Data[], unsigned char Length, unsigned char FrameID,unsigned char FrameOp,unsigned char GB_ID, unsigned char AdrsAdressat[], unsigned char AdrsHerkunft[], unsigned char AdrsReiseziel[])
{
    unsigned char   BufferTxXBAPI[XBAPI_BuffLen];

    Length+=17; //Ajuste de longitud por direcciones y Glaube Options

    BufferTxXBAPI[0]=0x7E;
    BufferTxXBAPI[1]=0x00;          // La longitud no supera 255 bytes
    BufferTxXBAPI[2]=Length+11;     //Longitud de los datos Data Length+11 (Address Length + API ID Len+FrameID Len+ Option Len)
    BufferTxXBAPI[3]=0x00;          //Identificador de envio para direccion de 64 Bits... Pag 61.
    BufferTxXBAPI[4]=FrameID;
    BufferTxXBAPI[13]=FrameOp;      //Options
    BufferTxXBAPI[30]=GB_ID;

    for(unsigned char i=0;i<=7;i++)
    {
        BufferTxXBAPI[i+5]=AdrsAdressat[i];        //Direccion destino inmediato
        BufferTxXBAPI[i+14]=AdrsHerkunft[i];       //Direccion de origen
        BufferTxXBAPI[i+22]=AdrsReiseziel[i];      //Direccion de destino final
    }

    for(unsigned char i=0;i<=Length;i++)
    {
        //BufferTxXBAPI[i+30]=Data[i];
        BufferTxXBAPI[i+31]=Data[i];
    }

    //CheckSum
    //BufferTxXBAPI[26]=0xF2;
    BufferTxXBAPI[Length+14]=ChecksumGen(BufferTxXBAPI);

    for(unsigned char i=0;i<=Length+14;i++)
    {
        while(!TXSTA2bits.TRMT);
        //Write1USART(BufferTx[i]);
        Write2USART(BufferTxXBAPI[i]);
    }

}
Example #8
0
void XBAPI_ATtx(unsigned char Length, unsigned char FrID, unsigned char AT1,unsigned char AT2,unsigned char Parameter[])
{
    unsigned char   BufferTxXBAPI[40];

    BufferTxXBAPI[0]=0x7E;
    BufferTxXBAPI[1]=0x00;
    BufferTxXBAPI[2]=Length;
    BufferTxXBAPI[3]=0x08;
    BufferTxXBAPI[4]=FrID;
    BufferTxXBAPI[5]=AT1;
    BufferTxXBAPI[6]=AT2;

    for(unsigned char i=0;i<Length-4;i++)
        BufferTxXBAPI[7+i]=Parameter[i];

    BufferTxXBAPI[Length+3]=ChecksumGen(BufferTxXBAPI);

    for(unsigned char i=0;i<=Length+3;i++)
    {
        while(!TXSTA2bits.TRMT);
        Write2USART(BufferTxXBAPI[i]);
    }
}