int main(void) { delay_init(); //延时函数初始化 uart_init(9600); //串口初始化为9600 LED_Init(); //初始化与LED连接的硬件接口 LED0=1; LED1=1; LED2=1; USB_Cable_Config (ENABLE); delay_ms(500); USB_Port_Set(0); delay_ms(500); USB_Port_Set(1); Set_USBClock(); USB_Interrupts_Config(); USB_Init(); SPI_IO_Init(); DMA_configuration(); spi_conf(SPI_DEFAULT_SPEED); LED1=0; LED2=0; while(1) { /* Get command */ serprog_handle_command(usb_getc()); /* Flush output via USB */ usb_sync(); } }
void A7201_init(void) { SPI_IO_Init(); SPI_CE_L(); //pCE = 0; //pTX_RX = 0; //SPI_S_H(); //pSPIS = 1; // SPI mode SPI_STB_L(); SPI_CLK_L(); Reg1_H = 0x77; Reg1_L = 0xA9; // RX, FSK, HiBand, Clock out disable, Up side band, TX power max, AGC enable Reg1_L &= (~BAND_L); //HI_BAND // HI_BAND = 434MHz band, LO_BAND = 315MHz band Reg1_L |= FASK_L; //FSK //1:FSK or 0 ASK Reg1_L |= IFB0_L; //IF filter bandwidth selection[mid. (ASK = 250KHz, FSK = 150KHz)] Reg1_H |= IFB1_H; SpiWrite ( 0xFA, 0x32 ); // For Power On(Initial) // initUart1(); // 8M/12/32 = 20.8K bps /* while(1) { ReceiveData(); } */ }