Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 months ago
1.2 kB
3
Indexable
Never
	if( am_hal_iom_enable(g_iomHandle) == AM_HAL_STATUS_SUCCESS)
	{
		am_util_stdio_printf("\nWE UZ OPERATIONALS BABEH!!!! (We = IoM)\n");
	}

	//Requesting WHOAMI
	uint64_t PRESSURE_SENSOR_WHO_AM_I_REG = 0x0F;
	uint64_t READ_SPI_MASK = 0x80;
	uint64_t instruction = PRESSURE_SENSOR_WHO_AM_I_REG|READ_SPI_MASK;
	int result_buffer_len = 8;
	uint32_t result_buffer;


	am_hal_iom_transfer_t Transaction;

    // Setup the SPI transaction
    Transaction.ui32InstrLen = 2; // Length of instruction in bytes
    Transaction.ui64Instr = instruction; // Instruction itself
    Transaction.eDirection = AM_HAL_IOM_RX;
	Transaction.ui32NumBytes = 0;
    Transaction.pui32RxBuffer = &result_buffer;
    Transaction.uPeerInfo.ui32SpiChipSelect = 38;
    Transaction.bContinue = 0;
    Transaction.ui8Priority = 1;

    uint32_t error_code = am_hal_iom_blocking_transfer(g_iomHandle,&Transaction);
    am_util_stdio_printf("\n Error code for transfer: %x \t Error code for INT_SWERR: %x \t Error code for INT_INTERR: %x \t Error code for NAK: %x \n",error_code,AM_HAL_IOM_INT_SWERR,AM_HAL_IOM_INT_INTERR, AM_HAL_IOM_INT_NAK);

    am_util_stdio_printf("\n%x",result_buffer);

Leave a Comment