void main(void) { Uint16 key; ICR = 0xff2e; /* IDLE Control Register */ /* mem port, io port and cpu idle active */ /* Peripheral_Reset */ CSL_SYSCTRL_REGS->PSRCR = 0x0020; CSL_SYSCTRL_REGS->PCGCR1 = 0x0000; CSL_SYSCTRL_REGS->PCGCR2 = 0x0000; CSL_SYSCTRL_REGS->PRCR = 0x00bf; /* VERY IMPORTANT !!! */ /* PPMODE1 (SPI, GPIO, UART, and I2S2): 7 signals of the SPI module, 6 GPIO signals(GP[17:12]), 4 signals of the UART module, 4 signals of the I2S2 module SP1MODE2 (GP[11:6]). 6 GPIO signals (GP[11:6]) SP0MODE0 (MMC/SD0). All 6 signals of the MMC/SD0 */ CSL_SYSCTRL_REGS->EBSR = (CSL_SYS_EBSR_PPMODE_MODE1 << 12) |(CSL_SYS_EBSR_SP1MODE_MODE2 << 10) |(CSL_SYS_EBSR_SP0MODE_MODE0 << 8); asm(" bit(ST1, #ST1_INTM) = #1"); INTR_init(); PLL_init(160*1000000L); TIMER_init(); EZDSP5535_I2C_init(); EZDSP5535_LCD_init(); aic3204_init(2, 0); EZDSP5535_GPIO_init(); EZDSP5535_I2S_init(1); // interrupt mode EZDSP5535_SAR_init(); asm(" bit(ST1, #ST1_INTM) = #0"); displayPeriod(); while(1) { key = EZDSP5535_SAR_getKey(); if(key == SW1) { if(period > 10) period--; CSL_GPIO_REGS->IOOUTDATA2 ^= 2; displayPeriod(); } if(key == SW2) { if(period < 900) period++; CSL_GPIO_REGS->IOOUTDATA2 ^= 1; displayPeriod(); } asm(" idle"); } }
int main(void) { clock_prescale_set(clock_div_1); SYSTEM_init(); TIMER_init(); USB_init(); /* initialize with 65 keys */ LAYOUT_init(65); LAYOUT_set((struct layout*)LAYOUT_BEGIN); LAYOUT_set_callback(&HID_set_scancode_state); MATRIX_init(5, rows, 14, cols, (const uint8_t*)matrix, &on_key_press); HID_init(); HID_commit_state(); LED_init(); SYSTEM_subscribe(USB_SOF, ANY, MAIN_handle_sof); int sleep_tmr = TIMER_add(32, true); SYSTEM_subscribe(TIMER, sleep_tmr, MAIN_sleep_timer_handler); SYSTEM_add_task(main_task, 0); SYSTEM_add_task(RAWHID_PROTOCOL_task, 0); SYSTEM_main_loop(); }
int main(){ DDRC|=(1<<EmissorFrontBig)|(1<<EmissorFrontSmall); DDRB&=~((1<<SensorFrontLeft)|(1<<SensorFrontRight)); PORTC|=(1<<EmissorFrontBig)|(1<<EmissorFrontSmall); unsigned volatile short valueL,valueR; ADCInit(); TIMER_init(); USARTInit(51); //Just for testing while(1){ distanceOpponentLeft=DistancePTLeft(); USARTWriteChar(distanceOpponentLeft); //Just for testing distanceOpponentRight=DistanceRight(); USARTWriteChar(distanceOpponentRight); // Just for testing } return 0; }
void main(void) { Int16 temp_cnt; ICR = 0xff2e; /* IDLE Control Register */ /* mem port, io port and cpu idle active */ /* Peripheral_Reset */ CSL_SYSCTRL_REGS->PSRCR = 0x0020; CSL_SYSCTRL_REGS->PCGCR1 = 0x0000; CSL_SYSCTRL_REGS->PCGCR2 = 0x0000; CSL_SYSCTRL_REGS->PRCR = 0x00bf; /* VERY IMPORTANT !!! */ /* PPMODE1 (SPI, GPIO, UART, and I2S2): 7 signals of the SPI module, 6 GPIO signals(GP[17:12]), 4 signals of the UART module, 4 signals of the I2S2 module SP1MODE2 (GP[11:6]). 6 GPIO signals (GP[11:6]) SP0MODE0 (MMC/SD0). All 6 signals of the MMC/SD0 */ CSL_SYSCTRL_REGS->EBSR = (CSL_SYS_EBSR_PPMODE_MODE1 << 12) |(CSL_SYS_EBSR_SP1MODE_MODE2 << 10) |(CSL_SYS_EBSR_SP0MODE_MODE0 << 8); asm(" bit(ST1, #ST1_INTM) = #1"); INTR_init(); PLL_init(3658); // system clock set to 120MHz TIMER_init(); EZDSP5535_GPIO_init(); EZDSP5535_I2C_init(); /* Initialize I2C */ Audio_init(7); /* Initialise to bandwidth=7kHz */ EZDSP5535_LCD_init(); LCD_print("G722.1 Receiver ", 17, 0); LCD_print("16kbps ", 8, 1); EZDSP5535_SPI_init(); Si446x_Init(); EZDSP5535_SAR_init(); DiskInit(); FileInit(); AddFileDriver(SDCammand, NULL); asm(" bit(ST1, #ST1_INTM) = #0"); bApi_Set_Receive(); while(1) { if(gpioIsrStatus == 1) { temp_cnt = SPI_recvData(spibuffer); gpioIsrStatus = 0; CSL_GPIO_REGS->IOINTFLG1 = 0x0800; } if(spiIsrStatus == 1) { // SpiWriteByte(CMD_FIFO_INFO, 0); SpiWriteByte(CMD_GET_INT_STATUS, 0); bApi_Set_Receive(); if(audioProcessing()) continue; spiIsrStatus = 0; } fileProcessing(); asm(" idle"); } // RemoveFileDriver(SDCammand); }
void main(void) { Int16 *samples; HANDLE FHandle = Not_Open_FILE; Int16 *out_words = &rawOutWords[1]; Uint8 *byte16 = &RfByte[2]; Int16 mlt_coefs[DCT_LENGTH]; Int16 mag_shift[2]; Int16 old_mag_shift[2]; Uint16 number_of_bits_per_frame; Uint16 number_of_bytes_per_frame; Uint16 number_of_16bit_words_per_frame; Int16 offset; Int16 key; Uint16 chn; // left and right channel, 0 or 1 Int16 sent_buffer_cnt = 0; Uint8 *sent_buffer; ICR = 0xff2e; /* IDLE Control Register */ /* mem port, io port and cpu idle active */ DSP_zero(xmt_l, DCT_LENGTH); DSP_zero(xmt_r, DCT_LENGTH); /* Peripheral_Reset */ CSL_SYSCTRL_REGS->PSRCR = 0x0020; CSL_SYSCTRL_REGS->PCGCR1 = 0x0000; CSL_SYSCTRL_REGS->PCGCR2 = 0x0000; CSL_SYSCTRL_REGS->PRCR = 0x00bf; CSL_SYSCTRL_REGS->EBSR = (CSL_SYS_EBSR_PPMODE_MODE1 << 12) | (0 << 8) | (2 << 10);//GPIO(11-6) asm(" bit(ST1, #ST1_INTM) = #1"); number_of_bits_per_frame = (Uint16)(BITRATE * 20); // BITRATE in kbps number_of_bytes_per_frame = (Uint16)(number_of_bits_per_frame>>3); number_of_16bit_words_per_frame = (Uint16)(number_of_bits_per_frame>>4); INTR_init(); PLL_init(); TIMER_init(); EZDSP5535_GPIO_init(); DMA_audio_init(DCT_LENGTH); EZDSP5535_I2C_init(); /* Initialize I2C */ aic3204_init(6); /* Initialize codec */ EZDSP5535_LCD_init(); EZDSP5535_I2S_init(); /* Initialize I2S */ LCD_print("G722.1 Send ", 17, 0); LCD_print("16kbps ", 8, 1); EZDSP5535_SPI_init(); Si446x_Init(); EZDSP5535_SAR_init(); DiskInit(); FileInit(); AddFileDriver(SDCammand, NULL); sam2coef_init(); coef2sam_init(); rawOutWords[0] = 0x6b21; RfByte[0] = 0x21; RfByte[1] = 0x6b; // little-endian old_mag_shift[0] = 0; old_mag_shift[1] = 0; asm(" bit(ST1, #ST1_INTM) = #0"); SpiWriteByte(CMD_GET_INT_STATUS, 0); // clear interrupt pending while(1) { if(pingpong >= 0) { offset = (pingpong>>1) * DCT_LENGTH; /******************************************************************* * LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT *******************************************************************/ chn = LEFT; samples = &rcv_l[offset]; // Read frame of samples from mem. // Convert input samples to rmlt coefs mag_shift[chn] = samples_to_rmlt_coefs(samples, mlt_coefs, chn); // Encode the mlt coefs encoder(number_of_bits_per_frame, mlt_coefs, mag_shift[chn], out_words); byte16 = &RfByte[2]; byte16[-2] = 0x6b; byte16[-1] = 0x20; DSP_word2byte(byte16, out_words, number_of_16bit_words_per_frame); // process the out_words into decoder_mlt_coefs decoder(out_words, mlt_coefs, &mag_shift[chn], &old_mag_shift[chn]); samples = &xmt_l[offset]; // Write frame of output samples // convert the decoder_mlt_coefs to samples rmlt_coefs_to_samples(mlt_coefs, samples, mag_shift[chn], chn); /******************************************************************* * RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT RIGHT *******************************************************************/ chn = RIGHT; samples = &rcv_r[offset]; // Read frame of samples from mem. // Convert input samples to rmlt coefs mag_shift[chn] = samples_to_rmlt_coefs(samples, mlt_coefs, chn); // Encode the mlt coefs encoder(number_of_bits_per_frame, mlt_coefs, mag_shift[chn], out_words); byte16 = &RfByte[number_of_bytes_per_frame + 4]; byte16[-2] = 0x6b; byte16[-1] = 0x21; DSP_word2byte(byte16, out_words, number_of_16bit_words_per_frame); // process the out_words into decoder_mlt_coefs decoder(out_words, mlt_coefs, &mag_shift[chn], &old_mag_shift[chn]); samples = &xmt_r[offset]; // Write frame of output samples // convert the decoder_mlt_coefs to samples rmlt_coefs_to_samples(mlt_coefs, samples, mag_shift[chn], chn); if (FHandle != Not_Open_FILE) // Write output bitstream FileWrite(RfByte, 2*number_of_bytes_per_frame+4, FHandle); pingpong = -1; sent_buffer = RfByte; sent_buffer_cnt = 0; } if(spiIsrStatus == 1) { bApi_Set_Send(43); spiIsrStatus = 0; } if(sent_buffer_cnt < 2) { if(gpioIsrStatus == 1) { SPI_sendData(sent_buffer, number_of_bytes_per_frame+2); sent_buffer += number_of_bytes_per_frame+2; sent_buffer_cnt++; gpioIsrStatus = 0; CSL_GPIO_REGS->IOINTFLG1 = 0x0800; } } // key = EZDSP5535_SAR_getKey(); key = -1; if(key == SW1) if(FHandle == Not_Open_FILE) { LCD_print("RECORDING......", 15, 0); FHandle = FileOpen("A:\\VOICE000.TXT", FILE_FLAGS_WRITE); } if(key == SW2) if(FHandle != Not_Open_FILE) { LCD_print("SAVE VOICE000.DAT", 17, 0); FileClose(FHandle); AllCacheWriteBack(); FHandle = Not_Open_FILE; } asm(" idle"); }
void main(void) { ICR = 0xff2e; /* IDLE Control Register */ /* mem port, io port and cpu idle active */ /* Peripheral_Reset */ CSL_SYSCTRL_REGS->PSRCR = 0x0020; CSL_SYSCTRL_REGS->PRCR = 0x00bf; EZDSP5535_waitusec(5); /* Peripheral Clock Gating Configuration Register1 0: active, 1: disable SYSCLKDIS I2S2 TMR2 TMR1 X TMR0 I2S1 I2S0 MMCSD1 I2C X MMCSD0 DMA0 UART SPI I2S3 */ CSL_SYSCTRL_REGS->PCGCR1 = 0x0000; /* Peripheral Clock Gating Configuration Register2 X X X X X X X X X X ANAREG DMA3 DMA2 DMA1 USB SAR LCD */ CSL_SYSCTRL_REGS->PCGCR2 = 0x0000; /* VERY IMPORTANT !!! */ /* PPMODE1 (SPI, GPIO, UART, and I2S2): 7 signals of the SPI module, 6 GPIO signals(GP[17:12]), 4 signals of the UART module, 4 signals of the I2S2 module SP1MODE2 (GP[11:6]). 6 GPIO signals (GP[11:6]) SP0MODE0 (MMC/SD0). All 6 signals of the MMC/SD0 */ CSL_SYSCTRL_REGS->EBSR = (CSL_SYS_EBSR_PPMODE_MODE1 << 12) |(CSL_SYS_EBSR_SP1MODE_MODE2 << 10) |(CSL_SYS_EBSR_SP0MODE_MODE0 << 8); asm(" bit(ST1, #ST1_INTM) = #1"); PLL_init(200000000); /* 100MHz */ INTR_init(); /* set Interrupt vector and clean all IRs */ TIMER_init(); /* Timer interrupt */ EZDSP5535_GPIO_init(); /* Enable GPIO LED */ // RTC_reset(); EZDSP5535_I2C_init(); /* Initialize I2C */ EZDSP5535_UART_init(); /* Initialize UART */ Audio_init(7); /* Initialise set to BandWidth=7kHz */ File_init(); EZDSP5535_LCD_init(); /* Initialise LCD */ LCD_print("G722.1 recorder", 0); LCD_print("start", 1); SCHEDULE_init(); BoardUSB_init(); asm(" bit(ST1, #ST1_INTM) = #0"); while(1) { while(taskList) { audioProcessing(); uartProcessing(); alarmProcessing(); usbProcessing(); } asm(" idle"); } }