static GSList *device_instances = NULL;
static uint64_t supported_samplerates[] = {
- KHZ(200),
- KHZ(250),
- KHZ(500),
- MHZ(1),
- MHZ(5),
- MHZ(10),
- MHZ(25),
- MHZ(50),
- MHZ(100),
- MHZ(200),
+ SR_KHZ(200),
+ SR_KHZ(250),
+ SR_KHZ(500),
+ SR_MHZ(1),
+ SR_MHZ(5),
+ SR_MHZ(10),
+ SR_MHZ(25),
+ SR_MHZ(50),
+ SR_MHZ(100),
+ SR_MHZ(200),
0,
};
-static struct samplerates samplerates = {
- KHZ(200),
- MHZ(200),
- 0,
+static struct sr_samplerates samplerates = {
+ SR_KHZ(200),
+ SR_MHZ(200),
+ SR_HZ(0),
supported_samplerates,
};
return 0;
}
-static int hw_init(char *deviceinfo)
+static int hw_init(const char *deviceinfo)
{
struct sr_device_instance *sdi;
struct sigma *sigma = g_malloc(sizeof(struct sigma));
if (supported_samplerates[i] == 0)
return SR_ERR_SAMPLERATE;
- if (samplerate <= MHZ(50)) {
+ if (samplerate <= SR_MHZ(50)) {
ret = upload_firmware(0, sigma);
sigma->num_probes = 16;
}
- if (samplerate == MHZ(100)) {
+ if (samplerate == SR_MHZ(100)) {
ret = upload_firmware(1, sigma);
sigma->num_probes = 8;
}
- else if (samplerate == MHZ(200)) {
+ else if (samplerate == SR_MHZ(200)) {
ret = upload_firmware(2, sigma);
sigma->num_probes = 4;
}
if (!probe->enabled || !probe->trigger)
continue;
- if (sigma->cur_samplerate >= MHZ(100)) {
+ if (sigma->cur_samplerate >= SR_MHZ(100)) {
/* Fast trigger support. */
if (trigger_set) {
g_warning("Asix Sigma only supports a single "
/* Check if trigger is in this chunk. */
if (triggerpos != -1) {
- if (sigma->cur_samplerate <= MHZ(50))
+ if (sigma->cur_samplerate <= SR_MHZ(50))
triggerpos -= EVENTS_PER_CLUSTER - 1;
if (triggerpos < 0)
packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples + sent;
- session_bus(sigma->session_id, &packet);
+ sr_session_bus(sigma->session_id, &packet);
sent += tosend;
}
packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples;
- session_bus(sigma->session_id, &packet);
+ sr_session_bus(sigma->session_id, &packet);
sent += tosend;
}
packet.type = SR_DF_TRIGGER;
packet.length = 0;
packet.payload = 0;
- session_bus(sigma->session_id, &packet);
+ sr_session_bus(sigma->session_id, &packet);
}
}
packet.length = tosend * sizeof(uint16_t);
packet.unitsize = 2;
packet.payload = samples + sent;
- session_bus(sigma->session_id, &packet);
+ sr_session_bus(sigma->session_id, &packet);
}
*lastsample = samples[n - 1];
/* End of samples. */
packet.type = SR_DF_END;
packet.length = 0;
- session_bus(sigma->session_id, &packet);
+ sr_session_bus(sigma->session_id, &packet);
sigma->state.state = SIGMA_IDLE;
struct sr_datafeed_packet packet;
struct sr_datafeed_header header;
struct clockselect_50 clockselect;
- int frac;
+ int frac, triggerpin, ret;
uint8_t triggerselect;
struct triggerinout triggerinout_conf;
struct triggerlut lut;
- int triggerpin;
session_device_id = session_device_id;
sigma = sdi->priv;
/* If the samplerate has not been set, default to 200 KHz. */
- if (sigma->cur_firmware == -1)
- set_samplerate(sdi, KHZ(200));
+ if (sigma->cur_firmware == -1) {
+ if ((ret = set_samplerate(sdi, SR_KHZ(200))) != SR_OK)
+ return ret;
+ }
/* Enter trigger programming mode. */
sigma_set_register(WRITE_TRIGGER_SELECT1, 0x20, sigma);
/* 100 and 200 MHz mode. */
- if (sigma->cur_samplerate >= MHZ(100)) {
+ if (sigma->cur_samplerate >= SR_MHZ(100)) {
sigma_set_register(WRITE_TRIGGER_SELECT1, 0x81, sigma);
/* Find which pin to trigger on from mask. */
triggerselect |= 1 << 3;
/* All other modes. */
- } else if (sigma->cur_samplerate <= MHZ(50)) {
+ } else if (sigma->cur_samplerate <= SR_MHZ(50)) {
build_basic_trigger(&lut, sigma);
sigma_write_trigger_lut(&lut, sigma);
sigma_set_register(WRITE_TRIGGER_SELECT1, triggerselect, sigma);
/* Set clock select register. */
- if (sigma->cur_samplerate == MHZ(200))
+ if (sigma->cur_samplerate == SR_MHZ(200))
/* Enable 4 probes. */
sigma_set_register(WRITE_CLOCK_SELECT, 0xf0, sigma);
- else if (sigma->cur_samplerate == MHZ(100))
+ else if (sigma->cur_samplerate == SR_MHZ(100))
/* Enable 8 probes. */
sigma_set_register(WRITE_CLOCK_SELECT, 0x00, sigma);
else {
* 50 MHz mode (or fraction thereof). Any fraction down to
* 50 MHz / 256 can be used, but is not supported by sigrok API.
*/
- frac = MHZ(50) / sigma->cur_samplerate - 1;
+ frac = SR_MHZ(50) / sigma->cur_samplerate - 1;
clockselect.async = 0;
clockselect.fraction = frac;
header.protocol_id = SR_PROTO_RAW;
header.num_logic_probes = sigma->num_probes;
header.num_analog_probes = 0;
- session_bus(session_device_id, &packet);
+ sr_session_bus(session_device_id, &packet);
/* Add capture source. */
- source_add(0, G_IO_IN, 10, receive_data, sdi);
+ sr_source_add(0, G_IO_IN, 10, receive_data, sdi);
sigma->state.state = SIGMA_CAPTURE;