예제 #1
0
void HAL_CAN_ErrorCallback(CAN_HandleTypeDef *hcan) {
	if (hcan) {
		EventQueue_Push(
				EVENT_CAN,
				newEvent(CAN_EVENT_ERROR, NULL, HAL_CAN_GetError(hcan)),
				onEventDispose);
	}
}
예제 #2
0
파일: util.c 프로젝트: oggger/tinymp3box
int Thread_Stop(Thread *t) {
  void *pret;
  t->stop = 1;
  EventQueue_Push(t->eventq, Event_Create(ADMIN_THREAD_STOP, NULL, 0));
  pthread_join(t->thread, &pret);
  EventQueue_Free(t->eventq);
  t->stop = 0;
  t->isStarted = 0;
  return 0;
}
예제 #3
0
void HAL_CAN_TxCpltCallback(CAN_HandleTypeDef* hcan) {
	if (hcan && hcan->pTxMsg) {
		CanMsg_t mgs = {
				hcan->pTxMsg->IDE == CAN_ID_STD ? hcan->pTxMsg->StdId : hcan->pTxMsg->ExtId,
		};
		hcan->pTxMsg = NULL;
		EventQueue_Push(
				EVENT_CAN,
				newEvent(CAN_EVENT_TX, &mgs, HAL_CAN_GetError(hcan)),
				onEventDispose);
	}
}
예제 #4
0
void HAL_CAN_RxCpltCallback(CAN_HandleTypeDef* hcan) {
	if (hcan && hcan->pRxMsg) {

		CanMsg_t mgs = {
				hcan->pRxMsg->IDE == CAN_ID_STD ? hcan->pTxMsg->StdId : hcan->pTxMsg->ExtId,
				hcan->pRxMsg->IDE == CAN_ID_EXT,
				hcan->pTxMsg->RTR == CAN_RTR_REMOTE,
				hcan->pTxMsg->RTR == CAN_RTR_DATA ? hcan->pTxMsg->DLC : 0,
		};
		memcpy(mgs.buff, hcan->pTxMsg->Data, mgs.size);
		EventQueue_Push(
				EVENT_CAN,
				newEvent(CAN_EVENT_RX, &mgs, HAL_CAN_GetError(hcan)),
				onEventDispose);
		HAL_CAN_Receive_IT(hcan, CAN_FIFO0);
	}
}