Compare commits

..

No commits in common. "47be0651b0b72a981868ecb2880be9a0c0e8e364" and "5954e875b18449ebf3f1b361b1c105671bfb5fc7" have entirely different histories.

4 changed files with 22 additions and 87 deletions

View file

@ -107,9 +107,7 @@ CPUA= -mlittle-endian -mcpu=arm7tdmi
CPUC= $(CPUA) -msoft-float -mno-thumb-interwork -mpoke-function-name
DEBUGFORMAT=-g -gdwarf-2
WARN = -Wall -Wextra -Wno-char-subscripts -Wno-unused -Wno-pointer-sign \
-Wno-parentheses -Wno-missing-field-initializers \
$(WWARN)
WARN = -Wall -Wextra -Wno-char-subscripts -Wno-unused -Wno-pointer-sign -Wno-parentheses $(WWARN)
BUILTIN = --no-builtin-snprintf -fno-builtin-printf
CC=$(ARCH)-gcc-$(GCC) -std=gnu99 -O3 $(CPUC) $(WARN) $(BUILTIN)

View file

@ -52,78 +52,6 @@ int calib_pressure(int hashit)
return idx;
}
extern const struct timer_wait wait_conversion;
unsigned int bate_status;
static void bate_callback(const volatile struct timer_tick* tick) {
if (timer_wait_pin_status(&wait_conversion))
ssp_run_batch();
else {
bate_status = 9;
ssp_abort_batch();
}
}
const struct timer_wait wait_conversion = {
.mclk = 3333, // 50 ms
.pinmask = 1<<18, // wait for port0.18 to go low
.callback = bate_callback,
};
static const unsigned short bate_cmds[] = {
0b0000000010101010, // 0 reset part 1
0b1010101000000000, // 1 reset part 2
0b0001110101010000, // 2 word 1 cmd
0, // 3 word 1 value
0b0001110101100000, // 4 word 2 cmd
0, // 5 word 2 value
0b0001110110010000, // 6 word 3 cmd
0, // 7 word 3 value
0b0001110110100000, // 8 word 4 cmd
0, // 9 word 5 value
0b0000111101000000, // 10 data 1 cmd
// wait
0, // 11 data 1,2 value
0b0000111100100000, // 12 data 2 cmd
};
unsigned short bate_buffer[16];
static const struct ssp_batch bate_batch[] = {
[0] = {
.ssel = ssp_conf_bate,
.job = &(const struct ssp_job) {
.command = bate_cmds,
.cmd_count = 11,
.buf_count = 16,
.buf_ptr = bate_buffer,
},
.match = &(const struct ssp_match) {
.count = 3,
.size = 7,
},
},
[1] = {
.wait = &wait_conversion,
.job = &(const struct ssp_job) {
.command = bate_cmds+11,
.cmd_count = 2,
.read_count = 1,
},
},
[2] = {
.wait = &wait_conversion,
.job = &(const struct ssp_job) {
.command = bate_cmds+11,
.cmd_count = 1,
.read_count = 1,
},
},
[3] = { }
};
static inline
int pressure_wait_for_conversion(int timeout)
{
@ -133,6 +61,22 @@ int pressure_wait_for_conversion(int timeout)
int read_pressure(int from_phase, int to_phase, int value, int idx)
{
static const unsigned short cmds[] = {
0b0000000010101010, // 0 reset part 1
0b1010101000000000, // 1 reset part 2
0b0001110101010000, // 2 word 1 cmd
0, // 3 word 1 value
0b0001110101100000, // 4 word 2 cmd
0, // 5 word 2 value
0b0001110110010000, // 6 word 3 cmd
0, // 7 word 3 value
0b0001110110100000, // 8 word 4 cmd
0, // 9 word 5 value
0b0000111101000000, // 10 data 1 cmd
// wait
0, // 11 data 1,2 value
0b0000111100100000, // 12 data 2 cmd
};
int r = 0;
int timeout;
for (int phase = from_phase; !r && phase <= to_phase; phase++)
@ -143,7 +87,7 @@ int read_pressure(int from_phase, int to_phase, int value, int idx)
ssp_assert_ssel();
ssp_set_buffer(pressure_reading, 8);
ssp_set_read(3, 8);
r = ssp_submit(bate_cmds, 11, 0, 0);
r = ssp_submit(cmds, 11, 0, 0);
break;
case 2:
case 6:
@ -166,9 +110,9 @@ int read_pressure(int from_phase, int to_phase, int value, int idx)
break;
case 5: ssp_set_buffer(pressure_reading+6, 2);
ssp_set_read(0, 0);
r = ssp_submit(bate_cmds+11, 2, 0, 1);
r = ssp_submit(cmds+11, 2, 0, 1);
break;
case 8: r = ssp_submit(bate_cmds+11, 1, 0, 1);
case 8: r = ssp_submit(cmds+11, 1, 0, 1);
break;
case 10:
ssp_deassert_ssel();

10
ssp.c
View file

@ -303,19 +303,13 @@ int ssp_run_batch()
return ssp_submit_job(batch->job);
}
void ssp_abort_batch()
{
ssp_batch_repeats = 0;
ssp_batch_wait = 0;
ssp_batch = 0;
}
int ssp_submit_batch(const struct ssp_batch *batch, int timeout)
{
unsigned int c = ssp_wait(timeout);
if (c)
return c;
ssp_abort_batch();
ssp_batch_repeats = 0;
ssp_batch = batch;
ssp_batch_wait = 0;
return ssp_run_batch();
}

1
ssp.h
View file

@ -107,6 +107,5 @@ void ssp_set_read(unsigned int count, unsigned int size)
int ssp_submit_job(const struct ssp_job *jj);
int ssp_submit_batch(const struct ssp_batch *batch, int timeout);
int ssp_run_batch();
void ssp_abort_batch();
#endif