static void task_led(void *pvParameters) { UNUSED(pvParameters); // timeout = ((uint32_t)sys_now()) + (2000); for (;;) { // if(sys_now() >= timeout) { // printf("timeout\r\n"); // timeout = ((uint32_t)sys_now()) + (2000); // } // pio_toggle_pin(MDM_ONOFF_IDX); // pio_toggle_pin(MDM_ENABLE_IDX); // pio_toggle_pin(MDM_RESET_IDX); pio_toggle_pin(PIN_LED_0_IDX); pio_toggle_pin(PIN_LED1); pio_toggle_pin(PIN_LED2); vTaskDelay(500); } }
/** * \brief Responds to he command from CAN0 and sends to CAN1 **/ void command_in(void) { pio_toggle_pin(LED0_GPIO); can_disable_interrupt(CAN0, CAN_IER_MB0); NVIC_DisableIRQ(CAN0_IRQn); can_reset_all_mailbox(CAN0); can_reset_all_mailbox(CAN1); /* Init CAN1 Mailbox 0 to Reception Mailbox. */ reset_mailbox_conf(&can0_mailbox); can1_mailbox.ul_mb_idx = 1; can1_mailbox.uc_obj_type = CAN_MB_RX_MODE; can1_mailbox.ul_id_msk = CAN_MAM_MIDvA_Msk | CAN_MAM_MIDvB_Msk; can1_mailbox.ul_id = CAN_MID_MIDvA(7); can_mailbox_init(CAN1, &can1_mailbox); /* Init CAN0 Mailbox 0 to Transmit Mailbox. */ reset_mailbox_conf(&can0_mailbox); can0_mailbox.ul_mb_idx = 1; can0_mailbox.uc_obj_type = CAN_MB_TX_MODE; can0_mailbox.uc_tx_prio = 15; can0_mailbox.uc_id_ver = 0; can0_mailbox.ul_id_msk = 0; can_mailbox_init(CAN0, &can0_mailbox); /* Write transmit information into mailbox. */ can0_mailbox.ul_id = CAN_MID_MIDvA(7); can0_mailbox.ul_datal = COMMAND_OUT; can0_mailbox.ul_datah = CAN_MSG_DUMMY_DATA; can0_mailbox.uc_length = MAX_CAN_FRAME_DATA_LEN; can_mailbox_write(CAN0, &can0_mailbox); /* Enable CAN1 mailbox 0 interrupt. */ can_enable_interrupt(CAN1, CAN_IER_MB1); /* Send out the information in the mailbox. */ can_global_send_transfer_cmd(CAN0, CAN_TCR_MB1); /* potentially @non-terminating@ */ while (!g_ul_recv_status) { } }
/** * \brief Decodes the CAN message and performs a prescribed action depending on * the message received. * @param *controller: CAN sending controller * @param *p_mailbox: CAN mailbox structure of sending controller */ void decode_can_msg(can_mb_conf_t *p_mailbox, Can* controller) { //assert(g_ul_recv_status); // Only decode if a message was received. ***Asserts here. //assert(controller); // CAN0 or CAN1 are nonzero. uint32_t ul_data_incom = p_mailbox->ul_datal; if(controller == CAN0) pio_toggle_pin(LED0_GPIO); if(controller == CAN1) pio_toggle_pin(LED1_GPIO); if (ul_data_incom == COMMAND_OUT) pio_toggle_pin(LED0_GPIO); if (ul_data_incom == COMMAND_IN) pio_toggle_pin(LED1_GPIO); if (ul_data_incom == DUMMY_COMMAND) pio_toggle_pin(LED1_GPIO); if (ul_data_incom == MSG_ACK) pio_toggle_pin(LED1_GPIO); if ((ul_data_incom == COMMAND_IN) & (controller == CAN0)) { // Command has been received, respond. pio_toggle_pin(LED0_GPIO); command_in(); } if ((ul_data_incom == COMMAND_OUT) & (controller == CAN1)) { pio_toggle_pin(LED2_GPIO); // LED2 indicates the response to the command } // has been received. if ((ul_data_incom == HK_TRANSMIT) & (controller == CAN1)) { pio_toggle_pin(LED3_GPIO); // LED3 indicates housekeeping has been received. } if ((ul_data_incom == DUMMY_COMMAND) & (controller == CAN1)) { pio_toggle_pin(LED3_GPIO); // LED3 indicates housekeeping has been received. } if ((ul_data_incom == MSG_ACK) & (controller == CAN1)) { pio_toggle_pin(LED3_GPIO); // LED3 indicates the reception of a return message. } if ((ul_data_incom == HK_RETURNED) & (controller == CAN0)) { pio_toggle_pin(LED2_GPIO); // LED3 indicates the reception of housekeeping. } return; }
void process_deca_irq(uint32_t id, uint32_t mask) { pio_toggle_pin(LED_STATUS1_IDX); // instance_process_irq(0); irq_set = 0x01; }