Skip to content

Commit c4784f2

Browse files
committed
Updating board source and make rules for compatibility with SDK v1.3.11
1 parent b114e95 commit c4784f2

8 files changed

+92
-88
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
BUILD_ALL += utils/acc_service_data_logger_rpi_sparkx
22

33
utils/acc_service_data_logger_rpi_sparkx : \
4-
out/acc_service_data_logger.o \
4+
$(OUT_OBJ_DIR)/acc_service_data_logger.o \
55
libacconeer.a \
66
libacconeer_a111_r2c.a \
7-
out/libcustomer.a \
7+
libcustomer.a \
88
libacc_service.a \
9-
out/acc_board_rpi_sparkx.o
9+
$(OUT_OBJ_DIR)/acc_board_rpi_sparkx.o
1010
@echo " Linking $(notdir $@)"
11-
@mkdir -p utils
12-
@$(LINK.o) -Wl,--start-group $^ -Wl,--end-group $(LOADLIBES) $(LDLIBS) -o $@
11+
$(SUPPRESS)mkdir -p utils
12+
$(SUPPRESS)$(LINK.o) -Wl,--start-group $^ -Wl,--end-group $(LOADLIBES) $(LDLIBS) -o $@

Software/sparkx-sdk-addon/rule/makefile_build_acc_streaming_server_rpi_sparkx.inc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ utils/acc_streaming_server_rpi_sparkx : \
55
cJSON.o \
66
libacconeer.a \
77
libacconeer_a111_r2c.a \
8-
out/libcustomer.a \
8+
libcustomer.a \
99
libacc_service.a \
10-
out/acc_board_rpi_sparkx.o
10+
$(OUT_OBJ_DIR)/acc_board_rpi_sparkx.o
1111
@echo " Linking $(notdir $@)"
12-
@mkdir -p utils
13-
@$(LINK.o) -Wl,--start-group $^ -Wl,--end-group $(LOADLIBES) $(LDLIBS) -o $@
12+
$(SUPPRESS)mkdir -p utils
13+
$(SUPPRESS)$(LINK.o) -Wl,--start-group $^ -Wl,--end-group $(LOADLIBES) $(LDLIBS) -o $@
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
BUILD_ALL += out/sparkx_envelope_service_example
1+
BUILD_ALL += $(OUT_DIR)/sparkx_envelope_service_example
22

3-
out/sparkx_envelope_service_example : \
4-
out/example_service_envelope.o \
3+
$(OUT_DIR)/sparkx_envelope_service_example : \
4+
$(OUT_OBJ_DIR)/example_service_envelope.o \
55
libacconeer.a \
66
libacconeer_a111_r2c.a \
7-
out/libcustomer.a \
7+
libcustomer.a \
88
libacc_service.a \
9-
out/acc_board_rpi_sparkx.o
9+
$(OUT_OBJ_DIR)/acc_board_rpi_sparkx.o
1010
@echo " Linking $(notdir $@)"
11-
@mkdir -p out
12-
@$(LINK.o) -Wl,--start-group $^ -Wl,--end-group $(LOADLIBES) $(LDLIBS) -o $@
11+
$(SUPPRESS)mkdir -p $(OUT_DIR)
12+
$(SUPPRESS)$(LINK.o) -Wl,--start-group $^ -Wl,--end-group $(LOADLIBES) $(LDLIBS) -o $@
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
BUILD_ALL += out/sparkx_envelope_iq_example
1+
BUILD_ALL += $(OUT_DIR)/sparkx_envelope_iq_example
22

3-
out/sparkx_envelope_iq_example : \
4-
out/example_service_iq.o \
3+
$(OUT_DIR)/sparkx_envelope_iq_example : \
4+
$(OUT_OBJ_DIR)/example_service_iq.o \
55
libacconeer.a \
66
libacconeer_a111_r2c.a \
7-
out/libcustomer.a \
7+
libcustomer.a \
88
libacc_service.a \
9-
out/acc_board_rpi_sparkx.o
9+
$(OUT_OBJ_DIR)/acc_board_rpi_sparkx.o
1010
@echo " Linking $(notdir $@)"
11-
@mkdir -p out
12-
@$(LINK.o) -Wl,--start-group $^ -Wl,--end-group $(LOADLIBES) $(LDLIBS) -o $@
11+
$(SUPPRESS)mkdir -p $(OUT_DIR)
12+
$(SUPPRESS)$(LINK.o) -Wl,--start-group $^ -Wl,--end-group $(LOADLIBES) $(LDLIBS) -o $@
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
BUILD_ALL += out/sparkx_power_bins_example
1+
BUILD_ALL += $(OUT_DIR)/sparkx_power_bins_example
22

3-
out/sparkx_power_bins_example : \
4-
out/example_service_power_bins.o \
3+
$(OUT_DIR)/sparkx_power_bins_example : \
4+
$(OUT_OBJ_DIR)/example_service_power_bins.o \
55
libacconeer.a \
66
libacconeer_a111_r2c.a \
7-
out/libcustomer.a \
7+
libcustomer.a \
88
libacc_service.a \
9-
out/acc_board_rpi_sparkx.o
9+
$(OUT_OBJ_DIR)/acc_board_rpi_sparkx.o
1010
@echo " Linking $(notdir $@)"
11-
@mkdir -p out
12-
@$(LINK.o) -Wl,--start-group $^ -Wl,--end-group $(LOADLIBES) $(LDLIBS) -o $@
11+
$(SUPPRESS)mkdir -p $(OUT_DIR)
12+
$(SUPPRESS)$(LINK.o) -Wl,--start-group $^ -Wl,--end-group $(LOADLIBES) $(LDLIBS) -o $@
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
BUILD_ALL += out/sparkx_detector_distance
1+
BUILD_ALL += $(OUT_DIR)/sparkx_detector_distance
22

3-
out/sparkx_detector_distance : \
4-
out/sparkx_detector_distance.o \
3+
$(OUT_DIR)/sparkx_detector_distance : \
4+
$(OUT_OBJ_DIR)/sparkx_detector_distance.o \
55
libacconeer.a \
66
libacconeer_a111_r2c.a \
7-
out/libcustomer.a \
7+
libcustomer.a \
88
libacc_service.a \
99
libacc_detector_distance_peak.a \
10-
out/acc_board_rpi_sparkx.o
10+
$(OUT_OBJ_DIR)/acc_board_rpi_sparkx.o
1111
@echo " Linking $(notdir $@)"
12-
@mkdir -p out
13-
@$(LINK.o) -Wl,--start-group $^ -Wl,--end-group $(LOADLIBES) $(LDLIBS) -o $@
12+
$(SUPPRESS)mkdir -p $(OUT_DIR)
13+
$(SUPPRESS)$(LINK.o) -Wl,--start-group $^ -Wl,--end-group $(LOADLIBES) $(LDLIBS) -o $@

Software/sparkx-sdk-addon/source/acc_board_rpi_sparkx.c

Lines changed: 54 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@
77

88
#include "acc_board.h"
99
#include "acc_device_gpio.h"
10-
#include "acc_driver_gpio_linux_sysfs.h"
11-
#include "acc_driver_spi_linux_spidev.h"
12-
#include "acc_log.h"
1310
#include "acc_device_os.h"
1411
#include "acc_device_spi.h"
12+
#include "acc_driver_gpio_linux_sysfs.h"
1513
#include "acc_driver_os_linux.h"
14+
#include "acc_driver_spi_linux_spidev.h"
15+
#include "acc_log.h"
16+
1617

1718
/**
1819
* @brief The module name
1920
*
2021
* Must exist if acc_log.h is used.
2122
*/
22-
#define MODULE "acc_board_rpi_sparkx"
23+
#define MODULE "acc_board_rpi_sparkx-3_r1c"
2324

2425
/**
2526
* @brief The number of sensors available on the board
@@ -53,8 +54,7 @@
5354
/**
5455
* @brief The SPI speed of this board
5556
*/
56-
//#define ACC_BOARD_SPI_SPEED 15000000
57-
#define ACC_BOARD_SPI_SPEED 1000000
57+
#define ACC_BOARD_SPI_SPEED 15000000
5858

5959
/**
6060
* @brief The SPI bus all sensors are using
@@ -87,9 +87,11 @@ static const uint_fast8_t sensor_interrupt_pins[SENSOR_COUNT] = {
8787
GPIO0_PIN
8888
};
8989

90+
9091
static acc_board_isr_t master_isr;
92+
static acc_device_handle_t spi_handle;
9193

92-
static void isr_sensor1(void) { if (master_isr) master_isr(1); }
94+
static void isr_sensor1(void) {if (master_isr) master_isr(1);}
9395

9496

9597
/**
@@ -131,17 +133,15 @@ acc_status_t acc_board_gpio_init(void)
131133
if (
132134
(status = acc_device_gpio_set_initial_pull(GPIO0_PIN, 0)) ||
133135
(status = acc_device_gpio_set_initial_pull(RSTn_PIN, 1)) ||
134-
(status = acc_device_gpio_set_initial_pull(ENABLE_PIN, 0))// ||
135-
//(status = acc_device_gpio_set_initial_pull(CE_PIN, 1))
136+
(status = acc_device_gpio_set_initial_pull(ENABLE_PIN, 0))
136137
) {
137138
ACC_LOG_WARNING("%s: failed to set initial pull with status: %s", __func__, acc_log_status_name(status));
138139
}
139140

140141
if (
141142
(status = acc_device_gpio_input(GPIO0_PIN)) ||
142143
(status = acc_device_gpio_write(RSTn_PIN, 0)) ||
143-
(status = acc_device_gpio_write(ENABLE_PIN, 0))// ||
144-
//(status = acc_device_gpio_write(CE_PIN, 1))
144+
(status = acc_device_gpio_write(ENABLE_PIN, 0))
145145
) {
146146
ACC_LOG_ERROR("%s failed with %s", __func__, acc_log_status_name(status));
147147
acc_os_mutex_unlock(init_mutex);
@@ -177,6 +177,17 @@ acc_status_t acc_board_init(void)
177177
acc_driver_gpio_linux_sysfs_register(28);
178178
acc_driver_spi_linux_spidev_register();
179179

180+
acc_device_gpio_init();
181+
182+
acc_device_spi_configuration_t configuration;
183+
configuration.bus = ACC_BOARD_BUS;
184+
configuration.configuration = NULL;
185+
configuration.device = ACC_BOARD_CS;
186+
configuration.master = true;
187+
configuration.speed = ACC_BOARD_SPI_SPEED;
188+
189+
spi_handle = acc_device_spi_create(&configuration);
190+
180191
for (uint_fast8_t sensor_index = 0; sensor_index < SENSOR_COUNT; sensor_index++) {
181192
sensor_state[sensor_index] = SENSOR_STATE_UNKNOWN;
182193
}
@@ -232,6 +243,9 @@ acc_status_t acc_board_start_sensor(acc_sensor_t sensor)
232243
return status;
233244
}
234245

246+
// Wait for PMU to stabilize
247+
acc_os_sleep_us(5000);
248+
235249
status = acc_device_gpio_write(ENABLE_PIN, 1);
236250
if (status != ACC_STATUS_SUCCESS) {
237251
ACC_LOG_ERROR("Unable to activate ENABLE");
@@ -282,41 +296,10 @@ acc_status_t acc_board_stop_sensor(acc_sensor_t sensor)
282296
}
283297

284298

285-
void acc_board_get_spi_bus_cs(acc_sensor_t sensor, uint_fast8_t *bus, uint_fast8_t *cs)
286-
{
287-
if ((sensor <= 0) || (sensor > SENSOR_COUNT)) {
288-
*bus = -1;
289-
*cs = -1;
290-
} else {
291-
*bus = ACC_BOARD_BUS;
292-
*cs = ACC_BOARD_CS;
293-
}
294-
}
295-
296-
297299
acc_status_t acc_board_chip_select(acc_sensor_t sensor, uint_fast8_t cs_assert)
298300
{
299301
ACC_UNUSED(sensor);
300302
ACC_UNUSED(cs_assert);
301-
/*acc_status_t status;
302-
303-
if (cs_assert) {
304-
uint_fast8_t cea_val = (sensor == 1 || sensor == 2) ? 0 : 1;
305-
uint_fast8_t ceb_val = (sensor == 1 || sensor == 3) ? 0 : 1;
306-
307-
if (
308-
(status = acc_device_gpio_write(CE_A_PIN, cea_val)) ||
309-
(status = acc_device_gpio_write(CE_B_PIN, ceb_val))
310-
) {
311-
ACC_LOG_ERROR("%s failed with %s", __func__, acc_log_status_name(status));
312-
return status;
313-
}
314-
status = acc_device_gpio_write(CE_PIN, 0);
315-
if (status) {
316-
ACC_LOG_ERROR("%s failed with %s", __func__, acc_log_status_name(status));
317-
return status;
318-
}
319-
}*/
320303

321304
return ACC_STATUS_SUCCESS;
322305
}
@@ -332,7 +315,7 @@ bool acc_board_is_sensor_interrupt_connected(acc_sensor_t sensor)
332315
{
333316
ACC_UNUSED(sensor);
334317

335-
return false;
318+
return true;
336319
}
337320

338321

@@ -384,17 +367,38 @@ float acc_board_get_ref_freq(void)
384367
}
385368

386369

387-
uint32_t acc_board_get_spi_speed(uint_fast8_t bus)
370+
acc_status_t acc_board_set_ref_freq(float ref_freq)
388371
{
389-
ACC_UNUSED(bus);
372+
ACC_UNUSED(ref_freq);
390373

391-
return ACC_BOARD_SPI_SPEED;
374+
return ACC_STATUS_UNSUPPORTED;
392375
}
393376

394377

395-
acc_status_t acc_board_set_ref_freq(float ref_freq)
378+
acc_status_t acc_board_sensor_transfer(acc_sensor_t sensor_id, uint8_t *buffer, size_t buffer_length)
396379
{
397-
ACC_UNUSED(ref_freq);
380+
acc_status_t status;
381+
uint_fast8_t bus = acc_device_spi_get_bus(spi_handle);
398382

399-
return ACC_STATUS_UNSUPPORTED;
400-
}
383+
acc_device_spi_lock(bus);
384+
385+
if ((status = acc_board_chip_select(sensor_id, 1))) {
386+
ACC_LOG_ERROR("%s failed with %s", __func__, acc_log_status_name(status));
387+
acc_device_spi_unlock(bus);
388+
return status;
389+
}
390+
391+
if ((status = acc_device_spi_transfer(spi_handle, buffer, buffer_length))) {
392+
acc_device_spi_unlock(bus);
393+
return status;
394+
}
395+
396+
if ((status = acc_board_chip_select(sensor_id, 0))) {
397+
acc_device_spi_unlock(bus);
398+
return status;
399+
}
400+
401+
acc_device_spi_unlock(bus);
402+
403+
return status;
404+
}

Software/sparkx-sdk-addon/source/sparkx_detector_distance.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <signal.h>
99

1010
#include "acc_detector_distance_peak.h"
11-
#include "acc_os.h"
11+
//#include "acc_os.h"
1212
#include "acc_rss.h"
1313
#include "acc_sweep_configuration.h"
1414
#include "acc_types.h"

0 commit comments

Comments
 (0)