コード例 #1
0
ファイル: mcp2515.c プロジェクト: FaSTDa/Measurement-Unit-FW
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;
}
コード例 #2
0
ファイル: mcp2515.c プロジェクト: FaSTDa/Measurement-Unit-FW
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;
}
コード例 #3
0
ファイル: spi_slave.c プロジェクト: TECHNOTICSROBOTICS/mspdev
__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;
    }
}
コード例 #4
0
ファイル: mcp2515.c プロジェクト: FaSTDa/Measurement-Unit-FW
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;
}