//MSP430G2553 SPI w5500 functions //-Function--------------------------------------------------------------------- // SPI init for MSP430G2553 void spi_init(void) { BCSCTL1 = CALBC1_1MHZ; DCOCTL = CALDCO_1MHZ; P1SEL |= BIT5 + BIT6 + BIT7; P1SEL2 |= BIT5 + BIT6 + BIT7; UCB0CTL1 = UCSWRST; UCB0CTL0 = UCCKPH | UCMSB | UCMST | UCSYNC; UCB0CTL1 = UCSSEL_2 | UCSWRST; UCB0BR0 = 2; UCB0BR1 = 0; UCB0CTL1 &= ~UCSWRST; } //-END-------------------------------------------------------------------------- //-Function--------------------------------------------------------------------- //w5500 Chip Select void w5500_CS(int w5500_transfer) { if(w5500_transfer==1) P1OUT &= ~BIT1; else P1OUT |= BIT1; } //-END-------------------------------------------------------------------------- //-Function--------------------------------------------------------------------- //w5500_write void w5500_write(uint16_t offset_addr, uint8_t control_phase){ while(!(IFG2 & UCB0TXIFG)); UCB0TXBUF = (offset_addr>>8)&0xFF; while(!(IFG2 & UCB0RXIFG)); UCB0RXBUF; while(!(IFG2 & UCB0TXIFG)); UCB0TXBUF = (offset_addr)&0xFF; while(!(IFG2 & UCB0RXIFG)); UCB0RXBUF; //while(!(IFG2 & UCB0TXIFG)); UCB0TXBUF = control_phase; while(!(IFG2 & UCB0RXIFG)); UCB0RXBUF; } //-END-------------------------------------------------------------------------- //-Function--------------------------------------------------------------------- //w5500_read void w5500_data_phase(uint8_t length, uint8_t WR_data, uint8_t *received_data, ...){ if(WR_data==0){ for(int counter=0; counter