parent
94b32ec8d6
commit
1cec87973c
@ -0,0 +1,42 @@ |
||||
#include <stdint.h> |
||||
#include <stdbool.h> |
||||
#include <stdlib.h> |
||||
#include <stdio.h> |
||||
|
||||
#include "scpi_regs.h" |
||||
#include "scpi_errors.h" |
||||
#include "scpi_parser.h" |
||||
|
||||
SCPI_REG_QUES_t SCPI_REG_QUES; |
||||
SCPI_REG_QUES_t SCPI_REG_QUES_EN = {.u16 = 0xFFFF}; |
||||
|
||||
SCPI_REG_OPER_t SCPI_REG_OPER; |
||||
SCPI_REG_OPER_t SCPI_REG_OPER_EN = {.u16 = 0xFFFF}; |
||||
|
||||
SCPI_REG_SESR_t SCPI_REG_SESR; |
||||
SCPI_REG_SESR_t SCPI_REG_SESR_EN; |
||||
|
||||
SCPI_REG_STB_t SCPI_REG_STB; |
||||
SCPI_REG_STB_t SCPI_REG_SRE; |
||||
|
||||
/** Update status registers (propagate using enable registers) */ |
||||
void scpi_status_update(void) |
||||
{ |
||||
// propagate to STB
|
||||
SCPI_REG_STB.ERRQ = scpi_error_count() > 0; |
||||
SCPI_REG_STB.QUES = SCPI_REG_QUES.u16 & SCPI_REG_QUES_EN.u16; |
||||
SCPI_REG_STB.OPER = SCPI_REG_OPER.u16 & SCPI_REG_OPER_EN.u16; |
||||
SCPI_REG_STB.SESR = SCPI_REG_SESR.u8 & SCPI_REG_SESR_EN.u8; |
||||
SCPI_REG_STB.MAV = false; // TODO!!!
|
||||
|
||||
// Request Service
|
||||
SCPI_REG_STB.RQS = SCPI_REG_STB.u8 & SCPI_REG_SRE.u8; |
||||
|
||||
|
||||
// Run service request callback
|
||||
if (SCPI_REG_STB.RQS) { |
||||
if (scpi_service_request_impl) { |
||||
scpi_service_request_impl(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,104 @@ |
||||
#pragma once |
||||
#include <stdint.h> |
||||
#include <stdbool.h> |
||||
|
||||
typedef union { |
||||
struct __attribute__((packed)) { |
||||
bool VOLT: 1; |
||||
bool CURR: 1; |
||||
bool TIME: 1; |
||||
bool POWER: 1; |
||||
bool TEMP: 1; |
||||
bool FREQ: 1; |
||||
bool PHASE: 1; |
||||
bool MODUL: 1; |
||||
bool CALIB: 1; |
||||
bool BIT_9: 1; // user defined
|
||||
bool BIT_10: 1; |
||||
bool BIT_11: 1; |
||||
bool BIT_12: 1; |
||||
bool INSTR_SUM: 1; // instrument summary
|
||||
bool COMMAND_WARNING: 1; // command warning
|
||||
bool RESERVED: 1; |
||||
}; |
||||
|
||||
uint16_t u16; |
||||
} SCPI_REG_QUES_t; |
||||
|
||||
|
||||
typedef union { |
||||
struct __attribute__((packed)) { |
||||
bool CALIB: 1; |
||||
bool SETTING: 1; |
||||
bool RANGING: 1; |
||||
bool SWEEP: 1; |
||||
bool MEAS: 1; |
||||
bool WAIT_TRIG: 1; // waiting for trigger
|
||||
bool WAIT_ARM: 1; // waiting for ARM
|
||||
bool CORRECTING: 1; |
||||
bool BIT_8: 1; // user defined
|
||||
bool BIT_9: 1; |
||||
bool BIT_10: 1; |
||||
bool BIT_11: 1; |
||||
bool BIT_12: 1; |
||||
bool INSTR_SUM: 1; // instrument summary
|
||||
bool PROG_RUN: 1; // program running
|
||||
bool RESERVED: 1; |
||||
}; |
||||
|
||||
uint16_t u16; |
||||
} SCPI_REG_OPER_t; |
||||
|
||||
|
||||
typedef union { |
||||
struct __attribute__((packed)) { |
||||
bool OPC: 1; |
||||
bool REQ_CONTROL: 1; |
||||
bool QUERY_ERROR: 1; |
||||
bool DEV_ERROR: 1; |
||||
bool EXE_ERROR: 1; |
||||
bool CMD_ERROR: 1; |
||||
bool USER_REQUEST: 1; |
||||
bool POWER_ON: 1; |
||||
}; |
||||
|
||||
uint8_t u8; |
||||
} SCPI_REG_SESR_t; |
||||
|
||||
|
||||
typedef union { |
||||
struct __attribute__((packed)) { |
||||
bool BIT_0: 1; |
||||
bool BIT_1: 1; |
||||
bool ERRQ: 1; // error queue
|
||||
bool QUES: 1; |
||||
bool MAV: 1; // message available
|
||||
bool SESR: 1; |
||||
bool RQS: 1; // request service
|
||||
bool OPER: 1; |
||||
}; |
||||
|
||||
uint8_t u8; |
||||
} SCPI_REG_STB_t; |
||||
|
||||
|
||||
// QUESTionable register
|
||||
extern SCPI_REG_QUES_t SCPI_REG_QUES; |
||||
extern SCPI_REG_QUES_t SCPI_REG_QUES_EN; // picks what to use for the STB bit
|
||||
|
||||
// OPERation status register
|
||||
extern SCPI_REG_OPER_t SCPI_REG_OPER; |
||||
extern SCPI_REG_OPER_t SCPI_REG_OPER_EN; // picks what to use for the STB bit
|
||||
|
||||
// Standard Event Status register
|
||||
extern SCPI_REG_SESR_t SCPI_REG_SESR; |
||||
extern SCPI_REG_SESR_t SCPI_REG_SESR_EN; // ESE
|
||||
|
||||
// Status byte
|
||||
extern SCPI_REG_STB_t SCPI_REG_STB; |
||||
extern SCPI_REG_STB_t SCPI_REG_SRE; // SRE
|
||||
|
||||
|
||||
void scpi_status_update(void); |
||||
|
||||
extern __attribute__((weak)) void scpi_service_request_impl(void); |
@ -1,8 +0,0 @@ |
||||
#include <stdint.h> |
||||
#include <stdbool.h> |
||||
|
||||
#include "scpi_status.h" |
||||
|
||||
struct SCPI_SR_QUEST_struct SCPI_SR_QUEST; |
||||
struct SCPI_SR_OPER_struct SCPI_SR_OPER; |
||||
struct SCPI_SR_SESR_struct SCPI_SR_SESR; |
@ -1,83 +0,0 @@ |
||||
#pragma once |
||||
#include <stdint.h> |
||||
#include <stdbool.h> |
||||
|
||||
struct __attribute__((packed)) SCPI_SR_QUEST_struct { |
||||
bool VOLT: 1; |
||||
bool CURR: 1; |
||||
bool TIME: 1; |
||||
bool POWER: 1; |
||||
bool TEMP: 1; |
||||
bool FREQ: 1; |
||||
bool PHASE: 1; |
||||
bool MODUL: 1; |
||||
bool CALIB: 1; |
||||
bool BIT_9: 1; // user defined
|
||||
bool BIT_10: 1; |
||||
bool BIT_11: 1; |
||||
bool BIT_12: 1; |
||||
bool INSTR_SUM: 1; // instrument summary
|
||||
bool COMMAND_WARNING: 1; // command warning
|
||||
bool RESERVED: 1; |
||||
}; |
||||
|
||||
|
||||
struct __attribute__((packed)) SCPI_SR_OPER_struct { |
||||
bool CALIB: 1; |
||||
bool SETTING: 1; |
||||
bool RANGING: 1; |
||||
bool SWEEP: 1; |
||||
bool MEAS: 1; |
||||
bool WAIT_TRIG: 1; // waiting for trigger
|
||||
bool WAIT_ARM: 1; // waiting for ARM
|
||||
bool CORRECTING: 1; |
||||
bool BIT_8: 1; // user defined
|
||||
bool BIT_9: 1; |
||||
bool BIT_10: 1; |
||||
bool BIT_11: 1; |
||||
bool BIT_12: 1; |
||||
bool INSTR_SUM: 1; // instrument summary
|
||||
bool PROG_RUN: 1; // program running
|
||||
bool RESERVED: 1; |
||||
}; |
||||
|
||||
|
||||
struct __attribute__((packed)) SCPI_SR_SESR_struct { |
||||
bool OP_COMPLETE: 1; |
||||
bool REQ_CONTROL: 1; |
||||
bool QUERY_ERROR: 1; |
||||
bool DEV_ERROR: 1; |
||||
bool EXE_ERROR: 1; |
||||
bool CMD_ERROR: 1; |
||||
bool USER_REQUEST: 1; |
||||
bool POWER_ON: 1; |
||||
}; |
||||
|
||||
|
||||
struct __attribute__((packed)) SCPI_SR_STB_struct { |
||||
bool BIT_0: 1; |
||||
bool BIT_1: 1; |
||||
bool ERROR_QUEUE: 1; |
||||
bool QUEST: 1; |
||||
bool MSG_AVAIL: 1; |
||||
bool SESR: 1; |
||||
bool RQS: 1; // request service
|
||||
bool OPER: 1; |
||||
}; |
||||
|
||||
|
||||
// QUESTionable register
|
||||
extern struct SCPI_SR_QUEST_struct SCPI_SR_QUEST; |
||||
extern struct SCPI_SR_QUEST_struct SCPI_SR_QUEST_EN; // picks what to use for the STB bit
|
||||
|
||||
// OPERation status register
|
||||
extern struct SCPI_SR_OPER_struct SCPI_SR_OPER; |
||||
extern struct SCPI_SR_OPER_struct SCPI_SR_OPER_EN; // picks what to use for the STB bit
|
||||
|
||||
// Standard Event Status register
|
||||
extern struct SCPI_SR_SESR_struct SCPI_SR_SESR; |
||||
extern struct SCPI_SR_SESR_struct SCPI_SR_SESR_EN; // ESE
|
||||
|
||||
// Status byte
|
||||
extern struct SCPI_SR_STB_struct SCPI_SR_STB; |
||||
extern struct SCPI_SR_STB_struct SCPI_SR_STB_EN; // SRE
|
Loading…
Reference in new issue