示例#1
0
void midiSetChannelVolume(uint8_t chan, uint8_t vol) {
	if (chan > 15) return;
	if (vol > 127) return;

	ROM_UARTCharPutNonBlocking(UART1_BASE, MIDI_CHAN_MSG | chan);
	ROM_UARTCharPutNonBlocking(UART1_BASE, MIDI_CHAN_VOLUME);
	ROM_UARTCharPutNonBlocking(UART1_BASE, vol);
}
示例#2
0
void midiSetChannelBank(uint8_t chan, uint8_t bank) {
	if (chan > 15) return;
	if (bank > 127) return;

	ROM_UARTCharPutNonBlocking(UART1_BASE, MIDI_CHAN_MSG | chan);
	ROM_UARTCharPutNonBlocking(UART1_BASE, MIDI_CHAN_BANK);
	ROM_UARTCharPutNonBlocking(UART1_BASE, bank);
}
示例#3
0
//*****************************************************************************
// MIDI method for VS1053 Chip
//*****************************************************************************
void midiSetInstrument(uint8_t chan, uint8_t inst){
	if (chan > 15) return;
	inst --;
	if (inst > 127) return;

	ROM_UARTCharPutNonBlocking(UART1_BASE, MIDI_CHAN_PROGRAM | chan);
	ROM_UARTCharPutNonBlocking(UART1_BASE, inst);
}
示例#4
0
void midiNoteOn(uint8_t chan, uint8_t n, uint8_t vel) {
	if (chan > 15) return;
	if (n > 127) return;
	if (vel > 127) return;

	ROM_UARTCharPutNonBlocking(UART1_BASE, MIDI_NOTE_ON | chan);
	ROM_UARTCharPutNonBlocking(UART1_BASE, n);
	ROM_UARTCharPutNonBlocking(UART1_BASE, vel);
}
示例#5
0
文件: morse.c 项目: black13/io
void send_dash (void)          /* Send a dash and a space.  */
{
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_PIN_1);
	//SysCtlDelay(SysCtlClockGet() / (1000 * 3));
	SysCtlDelay(1000000);
	GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0);
	SysCtlDelay(500000);
	//note_on (FREQUENCY) ;
	//pause (UNIT_TIME * 3) ;
	//note_off () ;
	ROM_UARTCharPutNonBlocking(UART0_BASE,'_');
	ROM_UARTCharPutNonBlocking(UART0_BASE,' ');
	pause (UNIT_TIME) ;
}
示例#6
0
void
HardwareSerial::primeTransmit(unsigned long ulBase)
{
    //
    // Do we have any data to transmit?
    //
    if(!TX_BUFFER_EMPTY)
    {
        //
        // Disable the UART interrupt. If we don't do this there is a race
        // condition which can cause the read index to be corrupted.
        //
        ROM_IntDisable(g_ulUARTInt[uartModule]);
        //
        // Yes - take some characters out of the transmit buffer and feed
        // them to the UART transmit FIFO.
        //
        while(!TX_BUFFER_EMPTY)
        {
            while(ROM_UARTSpaceAvail(ulBase) && !TX_BUFFER_EMPTY) {
                ROM_UARTCharPutNonBlocking(ulBase,
                                           txBuffer[txReadIndex]);

                txReadIndex = (txReadIndex + 1) % SERIAL_BUFFER_SIZE;
            }
        }

        //
        // Reenable the UART interrupt.
        //
        ROM_IntEnable(g_ulUARTInt[uartModule]);
    }
}
示例#7
0
//*****************************************************************************
//
// The UART interrupt handler.
//
//*****************************************************************************
void
UARTIntHandler(void)
{
    uint32_t ui32Status;

    //
    // Get the interrrupt status.
    //
    ui32Status = ROM_UARTIntStatus(UART0_BASE, true);

    //
    // Clear the asserted interrupts.
    //
    ROM_UARTIntClear(UART0_BASE, ui32Status);

    //
    // Loop while there are characters in the receive FIFO.
    //
    while(ROM_UARTCharsAvail(UART0_BASE))
    {
        //
        // Read the next character from the UART and write it back to the UART.
        //
        ROM_UARTCharPutNonBlocking(UART0_BASE,
                                   ROM_UARTCharGetNonBlocking(UART0_BASE));
    }
}
示例#8
0
void UART1IntHandler(void)
{
    uint32_t 	ui32Status;
    //
    // Get the interrrupt status.
    //
    ui32Status = ROM_UARTIntStatus(UART1_BASE, true);

    //
    // Clear the asserted interrupts.
    //
    ROM_UARTIntClear(UART1_BASE, ui32Status);
    PRINTF("INT:\n");
    //
    // Loop while there are characters in the receive FIFO.
    //
    while(ROM_UARTCharsAvail(UART1_BASE)) {
        //
        // Read the next character from the UART and write it back to the UART.
        //
        uart1buffer[RX_PTR1]=ROM_UARTCharGetNonBlocking(UART1_BASE);
        /// echo
        ROM_UARTCharPutNonBlocking(UART0_BASE, uart1buffer[RX_PTR1]);
        RX_PTR1++;
        RX_PTR1 &= DIM_READ_BUFF - 1;
        //UARTCharPutNonBlocking(UART1_BASE,
        //		dato);
    }
}
示例#9
0
文件: project.c 项目: zbanks/aurora
void UARTSend(uint32_t uBase, const uint8_t *pui8Buffer, uint32_t ui32Count) {
    // Loop while there are more characters to send.
    while(ui32Count--)
    {
        // Write the next character to the UART.
        ROM_UARTCharPutNonBlocking(uBase, *pui8Buffer++);
    }
}
示例#10
0
//*****************************************************************************
//
// Send a string to the UART.
//
//*****************************************************************************
static void
UARTSend(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
    while(ui32Count--)
    {
        ROM_UARTCharPutNonBlocking(UART7_BASE, *pui8Buffer++);
		UARTLed(LED2);
    }
}
示例#11
0
void
UARTIntHandler(void) //This is triggered when the pc sends data - it is the virtual serial port interrupt.
{
    ROM_UARTIntClear(UART0_BASE, ROM_UARTIntStatus(UART0_BASE, true));

    while(ROM_UARTCharsAvail(UART0_BASE))
    {
        ROM_UARTCharPutNonBlocking(UART3_BASE,ROM_UARTCharGetNonBlocking(UART0_BASE));
    }
}
示例#12
0
void UARTIntHandler(void){
    uint32_t ui32Status;
    ui32Status = ROM_UARTIntStatus(UART0_BASE, true);
    ROM_UARTIntClear(UART0_BASE, ui32Status);
    while(ROM_UARTCharsAvail(UART0_BASE)){
        ROM_UARTCharPutNonBlocking(UART0_BASE, ROM_UARTCharGetNonBlocking(UART0_BASE));
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);
        SysCtlDelay(SysCtlClockGet() / (1000 * 3));
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);
    }
}
示例#13
0
//*****************************************************************************
// UART interrupt handler.
//*****************************************************************************
void UART0_IntHandler(void)
{
    uint32_t status = ROM_UARTIntStatus(UART0_BASE, true);
    ROM_UARTIntClear(UART0_BASE, status);
    
    // drain rx FIFO
    while(ROM_UARTCharsAvail(UART0_BASE))
    {
        char ch = ROM_UARTCharGetNonBlocking(UART0_BASE);
        
        if(inputRB.nbytes < DBG_IN_BUFFER_SIZE)
        {
            RB_Push(dbg_inputBuffer, inputRB, ch, DBG_IN_BUFFER_SIZE);
            if(ch == '\r')
                ++newlines;
        }
        else
        {
            // Attempt to report overflow and clear buffer
            // Must do this to avoid condition where buffer is full and code
            // is waiting for a newline that can not fit in the buffer.
            dbg_putstr_nb("\rRXOVF\r\n");
            RB_Clear(inputRB);
            newlines = 0;
        }
    }
    
    // feed tx FIFO
    // Echo received characters
    while(ROM_UARTSpaceAvail(UART0_BASE) && echoPtr != inputRB.wp)
    {
        ROM_UARTCharPutNonBlocking(UART0_BASE, dbg_inputBuffer[echoPtr]);
        echoPtr = (echoPtr + 1) % DBG_IN_BUFFER_SIZE;
    }
    // Write pending characters
    while(ROM_UARTSpaceAvail(UART0_BASE) && outputRB.nbytes > 0)
    {
        ROM_UARTCharPutNonBlocking(UART0_BASE, RB_Front(dbg_outputBuffer, outputRB));
        RB_Pop(outputRB, DBG_OUT_BUFFER_SIZE);
    }
} // UART0_IntHandler()
示例#14
0
int dbg_putc_nb(char ch, void * userdata)
{
    if(ROM_UARTSpaceAvail(UART0_BASE) && outputRB.nbytes == 0)
    {
        ROM_UARTCharPutNonBlocking(UART0_BASE, ch);
    }
    else
    {
        if(!RB_Full(outputRB, DBG_OUT_BUFFER_SIZE))
            RB_Push(dbg_outputBuffer, outputRB, ch, DBG_OUT_BUFFER_SIZE);
    }
    return 0;
}
示例#15
0
//*****************************************************************************
//
// Send a string to the UART.
//
//*****************************************************************************
void
UART0Send(const uint8_t *pui8Buffer, uint32_t ui32Count)
{
    //
    // Loop while there are more characters to send.
    //
    while(ui32Count--)
    {
        //
        // Write the next character to the UART.
        //
        ROM_UARTCharPutNonBlocking(UART0_BASE, *pui8Buffer++);
    }
}
示例#16
0
//*****************************************************************************
//
// Take as many bytes from the transmit buffer as we have space for and move
// them into the USB UART's transmit FIFO.
//
//*****************************************************************************
static void
USBUARTPrimeTransmit(uint32_t ui32Base)
{
    uint32_t ui32Read;
    uint8_t ui8Char;

    //
    // If we are currently sending a break condition, don't receive any
    // more data. We will resume transmission once the break is turned off.
    //
    if(g_bSendingBreak)
    {
        return;
    }

    //
    // If there is space in the UART FIFO, try to read some characters
    // from the receive buffer to fill it again.
    //
    while(ROM_UARTSpaceAvail(ui32Base))
    {
        //
        // Get a character from the buffer.
        //
        ui32Read = USBBufferRead((tUSBBuffer *)&g_sRxBuffer, &ui8Char, 1);

        //
        // Did we get a character?
        //
        if(ui32Read)
        {
            //
            // Place the character in the UART transmit FIFO.
            //
            ROM_UARTCharPutNonBlocking(ui32Base, ui8Char);

            //
            // Update our count of bytes transmitted via the UART.
            //
            g_ui32UARTTxCount++;
        }
        else
        {
            //
            // We ran out of characters so exit the function.
            //
            return;
        }
    }
}
//*****************************************************************************
//
// Send a string to the UART.
//
//*****************************************************************************
void
UARTSend(const unsigned char *pucBuffer, unsigned long ulCount)
{
    //
    // Loop while there are more characters to send.
    //
    while(ulCount--)
    {
        //
        // Write the next character to the UART.
        //
        ROM_UARTCharPutNonBlocking(UART0_BASE, *pucBuffer++);
    }
}
示例#18
0
void
UART3IntHandler(void) //This is triggered when the UART3 gets data - PC6/7
{
    unsigned long ulStatus;
    char character;

    ulStatus = ROM_UARTIntStatus(UART3_BASE, true);

    ROM_UARTIntClear(UART3_BASE, ulStatus);

    while(ROM_UARTCharsAvail(UART3_BASE))
    {
        ROM_UARTCharPutNonBlocking(UART0_BASE,ROM_UARTCharGetNonBlocking(UART3_BASE));
    }
}
示例#19
0
文件: morse.c 项目: black13/io
void morse (unsigned char ch)
{  /*--- MORSE CODE FUNCTION ---*/

      unsigned int c ;
      static unsigned int codes [64] = {
            SPACE_MASK,                      /* Entry 0 = space (0x20)  */
            0, 0, 0, 0, 0, 0, 0, 0,          /* ! " # $  % & " (  */
            0, 0, 0, 115, 49, 106, 41,       /* ) * + , - . /     */
            63, 62, 60, 56, 48, 32, 33, 35,  /* 0 1 2 3 4 5 6 7   */
            39, 47, 0, 0, 0, 0, 0, 76,       /* 8 9 : ; < = > ?   */
            0, 6, 17, 21, 9, 2, 20, 11,      /* @ A B C D E F G   */
            16, 4, 30, 13, 18, 7, 5, 15,     /* H I J K L M N O   */
            22, 27, 10, 8, 3, 12, 24, 14,    /* P Q R S T U V W   */
            25, 29, 19                       /* X Y Z  */
            } ;

      pause (0) ;                  /* Calibrate pause() function.  */

      c = toupper (ch) ;          /* No lower-case Morse characters.  */
      ROM_UARTCharPutNonBlocking(UART0_BASE,c);
      c -= ' ' ;                 /* Adjust for zero-based table.  */

      if (c > 58)       /* If out of range, ignore it.  */
         return;

      c = codes[c] ;             /* Look up Morse pattern from table. */

      if (c & SPACE_MASK)        /* If the space bit is set..  */
      {                          /* ..send a word space and go on.  */
    	  word_space () ;
    	  	  return;
      }

      while (c & BIT_MASK)       /* Transmit one character.  */
      {  /*--- TRANSMIT EACH BIT ---*/
    	  if (c & 1)
    		  send_dash () ;
          else
        	  send_dot () ;

                  c >>= 1 ;
      }  /*--- TRANSMIT EACH BIT ---*/

      ltr_space () ;             /* Send a space following character. */

     /*--- TRANSMIT COMPLETE STRING ---*/

}  /*--- MORSE CODE FUNCTION ---*/
//*****************************************************************************
//
// Take as many bytes from the transmit buffer as there is space for and move
// them into the USB UART's transmit FIFO.
//
//*****************************************************************************
static void
USBUARTPrimeTransmit(void)
{
    unsigned long ulRead;
    unsigned char ucChar;

    //
    // If a break condition is currently being sent, don't receive any more
    // data.  Transmission will resume once the break is turned off.
    //
    if(g_bSendingBreak)
    {
        return;
    }

    //
    // If there is space in the UART FIFO, try to read some characters
    // from the receive buffer to fill it again.
    //
    while(ROM_UARTSpaceAvail(UART0_BASE))
    {
        //
        // Get a character from the buffer.
        //
        ulRead = USBBufferRead(&g_sRxBuffer, &ucChar, 1);

        //
        // Was a character read?
        //
        if(ulRead)
        {
            //
            // Place the character in the UART transmit FIFO.
            //
            ROM_UARTCharPutNonBlocking(UART0_BASE, ucChar);
        }
        else
        {
            //
            // There are no more characters so exit the function.
            //
            return;
        }
    }
}
示例#21
0
/*
 * This is the UART3RX interrupt handler for the Optode
 * The handler simply writes characters out to the desktop.
 */
void UART3IntHandler(void)
{
	unsigned long ulStatus;

	// Get the interrupt status.
	ulStatus = ROM_UARTIntStatus(UART3_BASE, true);

	// Clear the asserted interrupts.
	ROM_UARTIntClear(UART3_BASE, ulStatus);


	// Loop while there are characters in the receive FIFO
	while(ROM_UARTCharsAvail(UART3_BASE))
	{
		// Read the next character from the UART and write it to desktop.
		ROM_UARTCharPutNonBlocking(UART1_BASE, ROM_UARTCharGetNonBlocking(UART3_BASE));
	}
}
//*****************************************************************************
//
// The UART interrupt handler.
//
//*****************************************************************************
void
UARTIntHandler(void)
{
    uint32_t ui32Status;

    //
    // Get the interrrupt status.
    //
    ui32Status = ROM_UARTIntStatus(UART0_BASE, true);

    //
    // Clear the asserted interrupts.
    //
    ROM_UARTIntClear(UART0_BASE, ui32Status);

    //
    // Loop while there are characters in the receive FIFO.
    //
    while(ROM_UARTCharsAvail(UART0_BASE))
    {
        //
        // Read the next character from the UART and write it back to the UART.
        //
        ROM_UARTCharPutNonBlocking(UART0_BASE,
                                   ROM_UARTCharGetNonBlocking(UART0_BASE));

        //
        // Blink the LED to show a character transfer is occuring.
        //
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2);

        //
        // Delay for 1 millisecond.  Each SysCtlDelay is about 3 clocks.
        //
        SysCtlDelay(SysCtlClockGet() / (1000 * 3));

        //
        // Turn off the LED
        //
        GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0);

    }
}
示例#23
0
//*****************************************************************************
//
// The UART1 interrupt handler.
// Get response from XBee (UART1), print to terminal (UART0)
//
//*****************************************************************************
void
UART1IntHandler(void)
{
	unsigned char x;
    uint32_t ui32Status;

    //
    // Get the interrrupt status.
    //
    ui32Status = ROM_UARTIntStatus(UART1_BASE, true);

    //
    // Clear the asserted interrupts.
    //
    ROM_UARTIntClear(UART1_BASE, ui32Status);

	  UARTprintf("Response:'");
    //
    // Loop while there are characters in the receive FIFO.
    //
    while(ROM_UARTCharsAvail(UART1_BASE))
    {
        //
        // Read the next character from the UART and write it back to the UART.
        // if special character print out the integer for it
			  //
				x=ROM_UARTCharGetNonBlocking(UART1_BASE);
				if(x<' ' | x>'~')
				{
					UARTprintf("/%d",(int)x);
					//ROM_UARTCharPutNonBlocking(UART0_BASE,x);
				}
				else
				{
					ROM_UARTCharPutNonBlocking(UART0_BASE,x);
				}
					
    }
		UARTprintf("'\n");
}
示例#24
0
void
UARTBridge(uint32_t SOURCE, uint32_t DESTINATION)
{
	//
	// Loop while there are characters in the receive FIFO.
	//
	while(ROM_UARTCharsAvail(SOURCE))
	{
		//
		// Read the next character from the UART and write it back to the UART.
		//
		ROM_UARTCharPutNonBlocking(DESTINATION,
				ROM_UARTCharGetNonBlocking(SOURCE));
	}
	//
	// Blink the LED to show a character transfer is occuring.
	//
	if (SOURCE == UART0_BASE) 
		GPIOPinWrite(GPIO_PORTF_BASE, LED_BLUE, LED_BLUE);
	else 
		GPIOPinWrite(GPIO_PORTF_BASE, LED_GREEN, LED_GREEN);
	GPIOPinWrite(GPIO_PORTF_BASE, LED_BLUE|LED_GREEN, 0);
}
示例#25
0
文件: morse.c 项目: black13/io
void ltr_space (void)          /* Produce a letter space.  */
{
	ROM_UARTCharPutNonBlocking(UART0_BASE,0x0A);
	ROM_UARTCharPutNonBlocking(UART0_BASE,0x0D);
    pause (UNIT_TIME * 2) ;
}
示例#26
0
文件: uart.c 项目: daniel-k/RIOT
int uart_write(uart_t uart, char data)
{
    int ret=ROM_UARTCharPutNonBlocking(UART0_BASE, data);
    return ret;
}