void main(void) { uint8_t error_flag; LED3=0; UART_Init(); LCD_Init(); SPI_master_init(400000); // Set clock rate to that speed in Hz error_flag = SDcard_init(); while(1) { LED1 = 0; LED4 = 0; if(error_flag != NO_ERRORS) { LED4 = 0; } else { LED4 = 1; } delay_ms(1000); LED1 = 1; LED4 = 1; LCD_Write(COMMAND, LINE1); LCD_Print(16, "Coltons and Matt"); LCD_Write(COMMAND, LINE2); LCD_Print(15, "hews LCD Works!"); delay_ms(3000); LCD_Clear(); } }
//call this routine to initialize all peripherals void init_devices(void) { //stop errant interrupts until set up cli(); //disable all interrupts SPI_master_init(); Port_init(); MCUCR = (1<<ISC01); // int0 external interrupt on falling edge of int0 GICR = (1<<INT0); // enable the external interrupt int0 sei(); //re-enable interrupts //all peripherals are now initialized }
//system initialize function void sys_init(void) { TRISB&=0xE7; //ss & ce are output, RB2 is input ss=1; ce=1; TRISA=0xFF; //RA0 is analog input TRISC=0xF8; //lcd control pins buzzer=0; //fire alarm buzzer TRISD=0x00; //lcd data bus lcd_init(); //initialize LCD adc_init(); //initialize ADC interrupt_init(); //initialize interrupts SPI_master_init(0x00, SLOW); //initialize MSSP module for SPI communication nrf24_init(); //initialize nRF24L01+ }
void ant_v2x_init( void ) { SPI_master_init(); /* set sync as ouptut */ SetBit(ANT_V2X_DDR, ANT_V2X_PIN); /* pull it down */ SetBit(ANT_V2X_PORT, ANT_V2X_PIN); ant_v2x_data_available = FALSE; ant_v2x_com_status = MAG_CS_IDLE; ant_v2x_data.heading = 0.; ant_v2x_reset(); }
void ISD_Init() //初始化 { SPI_master_init(); ISD_Reset(); ISD_Reset(); ISD_Reset(); /*do { ISD_PU(); _delay_ms(10); RdStatus(); _delay_ms(10); }while(((SR0_L&0x01)!=0)||((SR1&0x01)==0));*/ ISD_PU(); ISD_PU(); ISD_PU(); ClrInt(); ISD_WR_APC2(); Rd_APC(); }