void IRSendRev::Send(unsigned char *idata, unsigned char ifreq) { int i, j; int len = idata[0]; unsigned char c; unsigned char start_high = idata[1]; unsigned char start_low = idata[2]; unsigned char nshort = idata[3]; unsigned char nlong = idata[4]; unsigned char datalen = idata[5]; uint32_t bytecount; unsigned char *pClockData; bytecount = start_high * ifreq / 100; pClockData = (unsigned char *) malloc (bytecount); for (i=0; i<bytecount; i++) { pClockData[i] = 0x55; } serial_baud((serial_t *)pUART, ifreq*1000*2); serial_send_blocked((serial_t *)pUART, (char *)pClockData, bytecount, 10); HalDelayUs(start_low * 50); bytecount = nshort * ifreq / 100; for (i=0; i<datalen; i++) { c = idata[i+6]; for (j=0; j<8; j++) { serial_send_blocked((serial_t *)pUART, (char *)pClockData, bytecount, 1); if (c & (0x01 << (7-j))) { HalDelayUs(nlong * 50); } else { HalDelayUs(nshort * 50); } } } serial_send_blocked((serial_t *)pUART, (char *)pClockData, bytecount, 1); free(pClockData); }
/** * @brief system software reset * * @return None * */ void sys_reset(void) { // Set processor clock to default before system reset HAL_WRITE32(SYSTEM_CTRL_BASE, 0x14, 0x00000021); HalDelayUs(100*1000); // Cortex-M3 SCB->AIRCR HAL_WRITE32(0xE000ED00, 0x0C, (0x5FA << 16) | // VECTKEY (HAL_READ32(0xE000ED00, 0x0C) & (7 << 8)) | // PRIGROUP (1 << 2)); // SYSRESETREQ }
//--------------------------------------------------------------------------------------------// void SPI_PL7223_DELY(int dely_cnt) // MCUCLK 4MHz, Delay-Time 9usec/clock { HalDelayUs(dely_cnt*20); }