Exemplo n.º 1
0
static void utc_spi_close_p(void)
{
	int ret = iotbus_spi_close(spi);
	TC_ASSERT_EQ("iotbus_spi_close", ret, IOTBUS_ERROR_NONE);
	TC_SUCCESS_RESULT();

}
Exemplo n.º 2
0
bool iotjs_spi_close(iotjs_spi_t* spi) {
  IOTJS_VALIDATED_STRUCT_METHOD(iotjs_spi_t, spi);

  if (_this->hSpi != NULL) {
    int err = iotbus_spi_close(_this->hSpi);
    if (err != 0) {
      DDLOG("%s - close failed: %d", __func__, err);
      return false;
    }
    _this->hSpi = NULL;
  }

  return true;
}
Exemplo n.º 3
0
/******************************
     SPI TEST
 ******************************/
int systemio_test_spi(char *failstr)
{
	int result = SYSIO_RESULT_FAIL;
	int fail_flag = 0;
	int ret;
	iotbus_spi_context_h hSpi;
	unsigned int bus = 0;
	unsigned char txbuf[64] = { 0, };
	unsigned char rxbuf[64] = { 0, };;
	struct iotbus_spi_config_s config = {
		(char)8,
		0,
		0,
		12000000,
		0,
	};

	hSpi = iotbus_spi_open(bus, &config);
	if (!hSpi) {
		SYSIO_DEBUG("[IOTAPI] iotbus_spi_open() fail \n");
		REGISTER_FAIL_REASON("iotbus_spi_open() fail", &fail_flag);
		goto done;
	} else {
		SYSIO_DEBUG("[IOTAPI] iotbus_spi_open() success \n");
	}

	ret = iotbus_spi_write(hSpi, txbuf, 8);
	if (ret != 0) {
		SYSIO_DEBUG("[IOTAPI] iotbus_spi_write() fail \n");
		REGISTER_FAIL_REASON("iotbus_spi_write() fail", &fail_flag);
	} else {
		SYSIO_DEBUG("[IOTAPI] iotbus_spi_write() success \n");
	}

	ret = iotbus_spi_recv(hSpi, rxbuf, 8);
	if (ret != 0) {
		SYSIO_DEBUG("[IOTAPI] iotbus_spi_recv() fail \n");
		REGISTER_FAIL_REASON("iotbus_spi_recv() fail", &fail_flag);
	} else {
		SYSIO_DEBUG("[IOTAPI] iotbus_spi_recv() success \n");
	}

#if 0
	ret = iotbus_spi_transfer_buf(hSpi, txbuf, rxbuf, 16);
	if (ret != 0) {
		SYSIO_DEBUG("[IOTAPI] iotbus_spi_transfer_buf() fail \n");
		REGISTER_FAIL_REASON("iotbus_spi_transfer_buf() fail");
	} else {
		SYSIO_DEBUG("[IOTAPI] iotbus_spi_transfer_buf() success \n");
	}
#endif

	ret = iotbus_spi_close(hSpi);
	if (ret != 0) {
		SYSIO_DEBUG("[IOTAPI] iotbus_spi_close() fail \n");
		REGISTER_FAIL_REASON("iotbus_spi_close() fail", &fail_flag);
	} else {
		SYSIO_DEBUG("[IOTAPI] iotbus_spi_close() success \n");
	}

done:
	/* check if succeed */
	if (fail_flag == 0) {
		result = SYSIO_RESULT_SUCCESS;
	}

	return result;
}
Exemplo n.º 4
0
static void utc_spi_close_n(void)
{
	int ret = iotbus_spi_close(NULL);
	TC_ASSERT_EQ("iotbus_spi_close", ret, IOTBUS_ERROR_INVALID_PARAMETER);
	TC_SUCCESS_RESULT();
}