Exemple #1
0
void can_r_rxbuf(uint8_t bufid, void *buf, uint8_t len)
{
	uint16_t i;
	uint8_t *sbuf = (uint8_t *)buf;

	CAN_CS_LOW;
	SPI_receiveData(MCP2515_SPI_READ_RXBUF | (bufid & 0x06));
	for (i=0; i < len; i++) {
		sbuf[i] = SPI_receiveData(0xFF);
	}
	CAN_CS_HIGH;
}
Exemple #2
0
void can_r_reg(uint8_t addr, void *buf, uint8_t len)
{
	uint16_t i;
	uint8_t *sbuf = (uint8_t *)buf;

	CAN_CS_LOW;
	SPI_receiveData(MCP2515_SPI_READ);
	SPI_receiveData(addr);
	for (i=0; i < len; i++) {
		sbuf[i] = spi_transfer(0xFF);
	}
	CAN_CS_HIGH;
}
__interrupt void USCI_A0_ISR (void)
{
    switch (__even_in_range(UCA0IV,4)){
        //Vector 2 - RXIFG
        case 2:
            //USCI_A0 TX buffer ready?
            while (!SPI_getInterruptStatus(__MSP430_BASEADDRESS_USCI_A0__,
                       SPI_TRANSMIT_INTERRUPT
                       )) ;

            //Transmit data to master
            SPI_transmitData(__MSP430_BASEADDRESS_USCI_A0__,
            transmitData
            );

            //Receive data from master
            receiveData = SPI_receiveData(__MSP430_BASEADDRESS_USCI_A0__);

            //Increment data to be transmitted
            transmitData++;

            break;

        default: break;
    }
}
Exemple #4
0
uint8_t can_spi_query(uint32_t moduleInstance)
{
	uint8_t ret;

	CAN_CS_LOW;
	SPI_transmitData(moduleInstance, 0xFF);
	ret = SPI_receiveData(moduleInstance);
	CAN_CS_HIGH;
	return ret;
}