/** * @brief Main program. * @param None * @retval None */ int main(void) { /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32f072xb.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32f0xx.c file */ ConfigureTIM16_17ForIRTIM(); while (1) { frame = 0x3000 | (RC5_addr << 6) | RC5_innstruction; /* Prepare the frame to send */ ManchesterCodedMsg = RC5_ManchesterConvert(frame); /* Code the message with Manchester code */ SendOperationReady = 1; /* set the ready bit */ /* Enable and reset TIM_ENV */ /* (1) Force update generation (UG = 1) */ /* (2) Enable counter (CEN = 1) */ TIM_ENV->EGR |= TIM_EGR_UG; /* (1) */ TIM_ENV->CR1 |= TIM_CR1_CEN; /* (2) */ while (!SendOperationCompleted) /* wait for the sending completion */ { __WFI(); } TIM_ENV->CR1 &= (uint16_t)(~TIM_CR1_CEN); /* Disable IRQ on TIM_ENV */ } }
/** * @brief Generate and Send the RC5 frame. * @param RC5_Address : the RC5 Device destination * @param RC5_Instruction : the RC5 command instruction * @param RC5_Ctrl : the RC5 Control bit. * @retval None */ void RC5_Encode_SendFrame(uint8_t RC5_Address, uint8_t RC5_Instruction, RC5_Ctrl_TypeDef RC5_Ctrl) { /* Generate a binary format of the Frame */ RC5_FrameBinaryFormat = RC5_BinFrameGeneration(RC5_Address, RC5_Instruction, RC5_Ctrl); /* Generate a Manchester format of the Frame */ RC5_FrameManchestarFormat = RC5_ManchesterConvert(RC5_FrameBinaryFormat); /* Set the Send operation Ready flag to indicate that the frame is ready to be sent */ Send_Operation_Ready = 1; TPM_DRV_CounterStart(tpmTmr2_IDX, kTpmCountingUp, 44450U,true); // /* TIM IT Enable */ // TIM_ITConfig(TIM16, TIM_IT_Update, ENABLE); // /* Enable all Interrupt */ // TIM_Cmd(TIM16, ENABLE); }