int main (void) { TWI_init(); //TWI Bus Initialisieren TWI_59116_reset(); TWI_59116_setup(); if(CORE==Master){ DDRA=0xff; //PORTA als Ausgang DDRD|=(1<<2); // PD2 als Ausgang Interrupt_init(); sei(); SPI_MasterInit(); Ebene_ein=0; while(1) { effect_blinky2(1); //ok effect_planboing(0,AXIS_Z,20); //ok effect_planboing(1,AXIS_X,20); //ok effect_planboing(0,AXIS_Y,20); //ok effect_planboing(1,AXIS_Z,20); //ok for (uint8_t ii=0;ii<8;ii++) effect_box_shrink_grow (0,ii%4, ii & 4, 20); //ok //sendvoxels_rand_z(100,10,20); // ok effect_random_sparkle (1,3,20,10); //ok effect_box_woopwoop(1,40,1); //naja effect_rain(0,300); //ok //effect_wormsqueeze (2, AXIS_Z, 1, 100, 25); //ok for(int i=0;i<8;i++){ // Pixel durchtesten for(int j=0;j<64;j++) { LED[0][i][j/8][j%8]=0xff; _delay_us(500); } for(int j=0;j<64;j++) { LED[0][i][j/8][j%8]=0; _delay_us(500); } } } }else{ DDRA=0x00; //PORTA als Eingang DDRD&=~(1<<2); // PD2 als Eingang SPI_SlaveInit(); Ebene_ein=0; while(1) { I2C_Leds_ein(Ebene_ein%8); //Säulentreiber einschalten für nächste Ebene } } return 0; }
/** * @brief Initialises IOs, Motor driver, watchdog, UART, filtered ADC * */ void init(void) { error_reg = 0x00; //! Error Register //! Defining the Outputs DDR_DRV |= DRV_EN | DRV_MODE | DRV_PHASE | DRV_SLEEP; DDR_LIMIT_A_OUT |= LIMIT_A_OUT; DDR_LIMIT_B_OUT |= LIMIT_B_OUT; DDR_DIR_A_LED |= DIR_A_LED; DDR_DIR_B_LED |= DIR_B_LED; DDR_ERR_LED |= DIR_ERR_LED; DDR_PWR_LED |= PWR_LED; SET_PWR_LED; //! Set Power LED MOTOR_BREAK; //! Engine on brake if (MCUCSR & (1<<WDRF)) //! Checking the watchdog-flag { error_reg |= ERR_WATCHDOG; //! If a watchdog reset occurs, set the bit 6 of the error register high MCUCSR = ~(1<<WDRF); //! Delete the watchdog flag } init_uart(); //! Call the UART init ADC_init (); //! Call the ADC init pRbUFuse= &rbUFuse; pRbU24 = &rbU24; pRbIDrv = &rbIDrv; rbInit(pRbUFuse); //! Init ring buffers for median rbInit(pRbU24); rbInit(pRbIDrv); Interrupt_init(); //! Call Interrupt init WDT_init (); //! Call watchdog init return; //! Return }
void main(void) { volatile int i; //Disable watchdog WDTCTL = WDTPW + WDTHOLD; //set the clock BCSCTL1=CALBC1_1MHZ; DCOCTL=CALDCO_1MHZ; BCSCTL3 |= LFXT1S_2; /* Initializing SPI interface for communication with RF module */ /* P1.5 : SCK */ /* P1.6 : MOSI */ /* P1.6 : MISO */ /* Additionaly two more I/O pins are required for CSN and CE on*/ /* the module. These are connected as follows: */ /* P1.3 : CE */ /* P1.4 : CSN */ P1DIR |=CE+CSN; //P1.5 is SCLK, P1.6 = SDO, P1.7 = SDI, P1.6=CS, P1.0 = LED SPI_Init(); /* Initialize RF module */ BK2421_Initialize(); /* Triac control and zero crossing detection is on port 2 */ /* P2.6 : Triac control output */ /* P2.7 : Zero crossing detector */ P2SEL &=~(TRIAC+ZEROCROSS); //sets I/O function to P2.6 and P2.7 P2OUT &=~TRIAC; P2DIR |=TRIAC; P2DIR &=~ZEROCROSS; /* Will be using interrupts. Here we initialize them */ Interrupt_init(); legacy_receiver(); //never returns! /* endless loop, just in case */ while(1){ //for(i=1;i<1;i++); //P2OUT ^=TRIAC; //P2OUT=(P2OUT & ~TRIAC) | (P2IN&ZEROCROSS)>>1 ; } }