Compare commits
2 commits
a91d06723f
...
60d830fdae
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60d830fdae | ||
|
|
71e567fdc5 |
6 changed files with 49 additions and 35 deletions
|
|
@ -30,7 +30,6 @@ const struct keywords ads8688_variable_names[] = {
|
|||
VARIABLE("adc_avr", &data.n),
|
||||
VARIABLE("adc_sum", &data.sum),
|
||||
VARIABLE("adc_square", &data.square),
|
||||
VARIABLE("ssp_adc", &ssp_conf_adc),
|
||||
KW_END
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -871,8 +871,6 @@ static const struct keywords main_variable_names[] = {
|
|||
VARIABLE("spy_return", &spy_return),
|
||||
VARIABLE("poll_return", &poll_return),
|
||||
|
||||
VARIABLE("ssp_dac", &ssp_conf_dac),
|
||||
|
||||
VARIABLE("reboot", &reboot_magic),
|
||||
|
||||
{"", {0}}
|
||||
|
|
@ -880,6 +878,7 @@ static const struct keywords main_variable_names[] = {
|
|||
|
||||
const struct keywords *variable_names[] = {
|
||||
main_variable_names,
|
||||
ssp_variable_names,
|
||||
spi_variable_names,
|
||||
sdcard_variable_names,
|
||||
script_variable_names,
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ const struct keywords pressure_variable_names[] = {
|
|||
{"bate_hash", {.par=(unsigned int *)(pressure_hash)}},
|
||||
{"pressure", {.par=pressure}},
|
||||
{"temperature", {.par=temperature}},
|
||||
VARIABLE("bate_mode", ssp_conf_bate),
|
||||
{"", {0}}};
|
||||
|
||||
__attribute__((noinline))
|
||||
|
|
@ -108,7 +107,7 @@ static const unsigned short bate_cmds[] = {
|
|||
static const struct ssp_batch bate_batch[] = {
|
||||
{
|
||||
.flags = ssp_b_config | ssp_b_assert,
|
||||
{ .ssel = ssp_conf_bate },
|
||||
{ .ssel = &ssp_conf_bate },
|
||||
},
|
||||
{
|
||||
.flags = ssp_b_job,
|
||||
|
|
@ -156,13 +155,13 @@ int pressure_wait_for_conversion(int timeout)
|
|||
return SSP_MISO;
|
||||
}
|
||||
|
||||
int read_pressure(int from_phase, int to_phase, int value, int idx)
|
||||
int read_pressure(int from_phase, int to_phase, int value)
|
||||
{
|
||||
int r = 0;
|
||||
int timeout;
|
||||
for (int phase = from_phase; !r && phase <= to_phase; phase++)
|
||||
switch (phase) {
|
||||
case 0: ssp_init(&ssp_conf_bate[!!idx]);
|
||||
case 0: ssp_init(&ssp_conf_bate);
|
||||
break;
|
||||
case 1:
|
||||
ssp_assert_ssel();
|
||||
|
|
@ -261,7 +260,7 @@ int bate_cmd(struct command *cmd, const struct command_par *par)
|
|||
if (from_phase >= bate_ph_calib)
|
||||
idx = !!(pressure_reading[0] & 0x80);
|
||||
|
||||
int r = read_pressure(from_phase, to_phase, value, idx);
|
||||
int r = read_pressure(from_phase, to_phase, value);
|
||||
|
||||
int code = par->code;
|
||||
if (r || to_phase < bate_ph_calib) {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include "ssp.h"
|
||||
|
||||
extern const struct keywords pressure_variable_names[];
|
||||
int read_pressure(int from_phase, int to_phase, int value, int idx);
|
||||
int read_pressure(int from_phase, int to_phase, int value);
|
||||
int bate_cmd(struct command *cmd, const struct command_par *par);
|
||||
|
||||
enum bate_phase {
|
||||
|
|
|
|||
56
ssp.c
56
ssp.c
|
|
@ -23,17 +23,17 @@ volatile unsigned int ssp_frame_count;
|
|||
|
||||
unsigned short ssp_scratch[256];
|
||||
|
||||
void ssp_set_buffer(void *start, int size)
|
||||
void ssp_set_buffer(short *buf, int size)
|
||||
{
|
||||
unsigned int iflg = disable_irq(INT_DISABLE);
|
||||
volatile struct ssp_job *j=&job;
|
||||
if (!(size && start)) {
|
||||
start = ssp_scratch;
|
||||
size = sizeof(ssp_scratch);
|
||||
if (!(size && buf)) {
|
||||
buf = ssp_scratch;
|
||||
size = sizeof(ssp_scratch)/2;
|
||||
}
|
||||
ssp_buffer = (unsigned short *)start;
|
||||
j->buf_ptr = (unsigned short *)start;
|
||||
j->buf_count = size/2;
|
||||
ssp_buffer = (unsigned short *)buf;
|
||||
j->buf_ptr = (unsigned short *)buf;
|
||||
j->buf_count = size;
|
||||
enable_irq(iflg);
|
||||
}
|
||||
|
||||
|
|
@ -240,25 +240,23 @@ int ssp_wait(int timeout)
|
|||
return c;
|
||||
}
|
||||
|
||||
struct ssp_config ssp_conf_adc =
|
||||
{
|
||||
.mode = SSPCR0_16bits | SSPCR0_CPHA | SSP_kHz(10000),
|
||||
.ssel = SSP_ADS8688,
|
||||
};
|
||||
struct ssp_config ssp_conf_dac =
|
||||
{
|
||||
.mode = SSPCR0_16bits | SSP_kHz(30000),
|
||||
.ssel = SSP_LTC2656,
|
||||
};
|
||||
struct ssp_config ssp_conf_bate[] = {
|
||||
struct ssp_config ssp_confs[] = {
|
||||
{
|
||||
.mode = SSPCR0_16bits | SSP_kHz(1000),
|
||||
.ssel = SSP_SSEL,
|
||||
},
|
||||
{
|
||||
.mode = SSPCR0_16bits | SSPCR0_CPHA | SSP_kHz(10000),
|
||||
.ssel = SSP_ADS8688,
|
||||
},
|
||||
{
|
||||
.mode = SSPCR0_16bits | SSP_kHz(30000),
|
||||
.ssel = SSP_LTC2656,
|
||||
},
|
||||
{
|
||||
.mode = SSPCR0_16bits | SSP_kHz(250),
|
||||
.ssel = SSP_MS5534C,
|
||||
},
|
||||
{
|
||||
.mode = SSPCR0_16bits | SSP_kHz(120),
|
||||
.ssel = SSP_EXT | SSP_MCLK,
|
||||
},
|
||||
};
|
||||
|
||||
const struct ssp_batch *ssp_batch;
|
||||
|
|
@ -382,3 +380,17 @@ int ssp_submit_batch(const struct ssp_batch *batch, int timeout)
|
|||
ssp_callback = ssp_run_batch;
|
||||
return ssp_run_batch();
|
||||
}
|
||||
|
||||
const struct keywords ssp_variable_names[] = {
|
||||
VARIABLE("ssp_buffer", ssp_scratch),
|
||||
VARIABLE("ssp_response", (void *)&ssp_lastword),
|
||||
VARIABLE("ssp_match", &ssp_match),
|
||||
VARIABLE("ssp_ssel_mask", &ssp_ssel_mask),
|
||||
VARIABLE("ssp_frame_count", (void *)&ssp_frame_count),
|
||||
VARIABLE("ssp_bits", &ssp_bits),
|
||||
VARIABLE("ssp_config", &ssp_conf_default),
|
||||
VARIABLE("ssp_adc", &ssp_conf_adc),
|
||||
VARIABLE("ssp_dac", &ssp_conf_dac),
|
||||
VARIABLE("ssp_pressure", &ssp_conf_bate),
|
||||
{}
|
||||
};
|
||||
|
|
|
|||
13
ssp.h
13
ssp.h
|
|
@ -4,10 +4,11 @@
|
|||
|
||||
#include "gpio.h"
|
||||
#include "timer.h"
|
||||
#include "parser.h"
|
||||
|
||||
void ssp_reset(void);
|
||||
|
||||
void ssp_set_buffer(void *start, int size);
|
||||
void ssp_set_buffer(short *buf, int size);
|
||||
void ssp_poll(void);
|
||||
int ssp_submit(const unsigned short *cmd, int cmd_size, unsigned int ic, unsigned int rc);
|
||||
int ssp_busy(void);
|
||||
|
|
@ -54,9 +55,11 @@ void ssp_deassert_ssel(void)
|
|||
#define SSP_SSEL ((1<<16)|SSP_EXT)
|
||||
#define SSP_MS5534C ((1<<25)|SSP_MCLK)
|
||||
|
||||
extern struct ssp_config ssp_conf_adc;
|
||||
extern struct ssp_config ssp_conf_dac;
|
||||
extern struct ssp_config ssp_conf_bate[];
|
||||
extern struct ssp_config ssp_confs[];
|
||||
#define ssp_conf_default ssp_confs[0]
|
||||
#define ssp_conf_adc ssp_confs[1]
|
||||
#define ssp_conf_dac ssp_confs[2]
|
||||
#define ssp_conf_bate ssp_confs[3]
|
||||
|
||||
// volatile part of the job, inaccessible globally
|
||||
struct ssp_job {
|
||||
|
|
@ -137,4 +140,6 @@ int ssp_submit_batch(const struct ssp_batch *batch, int timeout);
|
|||
int ssp_run_batch();
|
||||
void ssp_abort_batch();
|
||||
|
||||
extern const struct keywords ssp_variable_names[];
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue