Ejemplo n.º 1
0
void CHidReport::sendReport(GPIO_PinState* pButton, int16_t rx, int16_t ry, int16_t rz, int16_t x, int16_t y, int16_t z, int16_t throttle1, int16_t throttle2, int16_t dpad1, int16_t dpad2) {
  int i;
  for (i = 0; i < 64; i++)
  {
    if (*(pButton + i) == true)
    	HotasReport.buttons |= (uint64_t)1 << i;
    else
    	HotasReport.buttons &= ~((uint64_t)1 << i);
  }

  HotasReport.rxAxis = rx;
  HotasReport.ryAxis = ry;
  HotasReport.rzAxis = rz;
  HotasReport.xAxis = x;
  HotasReport.yAxis = y;
  HotasReport.zAxis = z;


  HotasReport.throttle1 = throttle1;
  HotasReport.throttle2 = throttle2;

  HotasReport.dPad1 = dpad1;
  HotasReport.dPad2 = dpad2;

  USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, (uint8_t*)&HotasReport, 87);
}
Ejemplo n.º 2
0
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
{
    if(edge == TIM_INPUTCHANNELPOLARITY_RISING) {
        edge = TIM_INPUTCHANNELPOLARITY_FALLING;
        capture_value_raising = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_1);
    }
    else if(edge == TIM_INPUTCHANNELPOLARITY_FALLING) {
        capture_value_falling = HAL_TIM_ReadCapturedValue(htim, TIM_CHANNEL_1);
        float capture_value = capture_value_falling - capture_value_raising;
        distance = ((sonic_velocity * (capture_value / tim_clock)) / 2.0) * 10000; // mm
        USBD_CUSTOM_HID_SendReport(&hUsbDeviceFS, (uint8_t*)&distance, CUSTOM_HID_EPOUT_SIZE);
    }
}
Ejemplo n.º 3
0
/**
  * @brief EXTI line detection callbacks
  * @param GPIO_Pin: Specifies the pins connected EXTI line
  * @retval None
  */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
  if(GPIO_Pin == KEY_BUTTON_PIN)
  {
    SendBuffer[0] = KEY_REPORT_ID; 
    
    if(BSP_PB_GetState(BUTTON_KEY) == GPIO_PIN_RESET)
    {
      SendBuffer[1] = 0x01;
    }
    else
    {
      SendBuffer[1] = 0x00;
    }
    USBD_CUSTOM_HID_SendReport(&hUSBDDevice, SendBuffer, 2);
  }
}
Ejemplo n.º 4
0
/* Функция записи данных в буфер отправки по USB в хост */
int8_t USBD_CUSTOM_HID_SendReport_HS(uint8_t *pData, uint8_t size)
{
	return USBD_CUSTOM_HID_SendReport(&hUsbDeviceHS, pData, size);  
}