This article introduces some notes of testing Anybus CompactCom 40 through Raspberry Pi platform in SPI mode.
Anybus CompactCom 40
#if( ABCC_CFG_DRV_SPI )
case ABP_OP_MODE_SPI:
/*
** Check if running as root
*/
if( geteuid() != 0 )
{
fprintf( stderr, "WARNING! To use SPI as communication interface, this program must be run as root!\n\n" );
return( FALSE );
}
if( !bcm2835_spi_begin() )
{
ABCC_PORT_DebugPrint( ( "SPI initialization failed!\n" ) );
return( FALSE );
}
else
{
bcm2835_spi_setBitOrder( BCM2835_SPI_BIT_ORDER_MSBFIRST );
bcm2835_spi_setDataMode( BCM2835_SPI_MODE0 );
bcm2835_spi_setClockDivider( BCM2835_SPI_CLOCK_DIVIDER_128 ); /* */
bcm2835_spi_chipSelect( BCM2835_SPI_CS0 );
bcm2835_spi_setChipSelectPolarity( BCM2835_SPI_CS0, LOW );
}
break;
#endif
$ ls /dev/spi*
/dev/spidev0.0 /dev/spidev0.1