Пример #1
0
/**************************************************************************//**
\brief Startup initialization.
******************************************************************************/
void hwInitUsbFifo(void)
{
  // init decoder input pins
  GPIO_PD6_make_out();
  GPIO_PD7_make_out();
  // set pins to zero to select usb FIFO
  GPIO_PD6_clr();
  GPIO_PD7_clr();

  // setup default value
  GPIO_RD_set();
  GPIO_WR_set();
  // init R\W pins
  GPIO_RD_make_out();
  GPIO_WR_make_out();

  // init message pins
  GPIO_TXE_make_in();
  GPIO_RXF_make_in();

  USB_DATA_DDR = 0;
  //to avoid IAR warnings
  (void)GPIO_PD6_set;
  (void)GPIO_PD6_read;
  (void)GPIO_PD7_set;
  (void)GPIO_PD7_read;
  (void)GPIO_RD_read;
  (void)GPIO_WR_read;
  (void)GPIO_TXE_set;
  (void)GPIO_TXE_clr;
  (void)GPIO_TXE_make_out;
  (void)GPIO_RXF_set;
  (void)GPIO_RXF_clr;
  (void)GPIO_RXF_make_out;
}
Пример #2
0
/**************************************************************************//**
\brief Transmit byte to usb FIFO.

\param[in]
  len - number of bytes to transmit;
\param[in]
  p - pointer to byte memory;
******************************************************************************/
void setByteUsbFifo(uint16_t len, uint8_t *p)
{
  wdt_reset();

  // set PORTA as output
  USB_DATA_DDR = 0xFF;

  while (len--)
  {
    while (GPIO_TXE_read());
    USB_DATA_PORT = *p++; // prepare transmission
    GPIO_WR_clr();
    GPIO_WR_set();
  }

  // set PORTA as input
  USB_DATA_DDR = 0;
}
Пример #3
0
/**************************************************************************//**
\brief Startup initialization.
******************************************************************************/
void hwInitUsbFifo(void)
{
  // init decoder input pins
  GPIO_PD6_make_out();
  GPIO_PD7_make_out();
  // set pins to zero to select usb FIFO
  GPIO_PD6_clr();
  GPIO_PD7_clr();

  // setup default value
  GPIO_RD_set();
  GPIO_WR_set();
  // init R\W pins
  GPIO_RD_make_out();
  GPIO_WR_make_out();

  // init message pins
  GPIO_TXE_make_in();
  GPIO_RXF_make_in();

  USB_DATA_DDR = 0;
}
Пример #4
0
/**************************************************************************//**
\brief Startup initialization.
******************************************************************************/
void usbfifoInit(void)
{
  // init decoder input pins
  GPIO_PC6_make_out();
  GPIO_PC7_make_out();
  // set pins to zero to select usb FIFO
  GPIO_PC6_clr();
  GPIO_PC7_clr();

  // setup default value
  GPIO_RD_set();
  GPIO_WR_set();
  // init R\W pins
  GPIO_RD_make_out();
  GPIO_WR_make_out();

  // register RXF interrupt
  HAL_RegisterIrq(IRQ_7, IRQ_LOW_LEVEL, usbfifoRxBufferFiller);
  // register TXE interrupt
  HAL_RegisterIrq(IRQ_6, IRQ_LOW_LEVEL, usbfifoTxBufferCleaner);

  USB_DATA_DDR = 0;
}
Пример #5
0
/**************************************************************************//**
\brief Reads byte from tx buffer and sends it to fifo.
******************************************************************************/
static void usbfifoTxBufferCleaner(void)
{
  HalUsartService_t *control;
  uint16_t           poW;
  uint16_t           poR;

  if (!usbfifoPointDescrip)
  { // unregistered intrrupt is occurred
    HAL_DisableIrq(IRQ_6);
    return;
  }

  control = &usbfifoPointDescrip->service;
  poW = control->txPointOfWrite;
  poR = control->txPointOfRead;

  if (poW != poR)
  {
    // set port as output
    USB_DATA_DDR = 0xFF;
    NOP;
    USB_DATA_PORT = usbfifoPointDescrip->txBuffer[poR++];
    GPIO_WR_clr();
    GPIO_WR_set();
    USB_DATA_DDR = 0;

    if (poR == usbfifoPointDescrip->txBufferLength)
      poR = 0;

    control->txPointOfRead = poR;
  }
  else
  { // tx buffer is empty
    HAL_DisableIrq(IRQ_6);
    usbfifoPostTask(USB_FIFO_TASK_TX);
  }
}