Compare commits
No commits in common. "3b667318cba349a6b993d57afbee28ccb33784c7" and "560f7b806beff732d083ff94e954ac3d4e4c7ed1" have entirely different histories.
3b667318cb
...
560f7b806b
4 changed files with 6 additions and 99 deletions
1
gpio.h
1
gpio.h
|
|
@ -96,7 +96,6 @@ static inline void init_gpio(void) {}
|
||||||
#define SSP_SSEL_MASK1 0x03000000 // gpio1 pins to set high on deassert ssel
|
#define SSP_SSEL_MASK1 0x03000000 // gpio1 pins to set high on deassert ssel
|
||||||
#define SSP_SSEL_CONF0 0x00113f00 // ssel bits associated with gpio0 pins
|
#define SSP_SSEL_CONF0 0x00113f00 // ssel bits associated with gpio0 pins
|
||||||
#define SSP_SSEL_CONF1 0x03ee0000 // ssel bits associated with gpio1 pins
|
#define SSP_SSEL_CONF1 0x03ee0000 // ssel bits associated with gpio1 pins
|
||||||
#define SSP_MISO (GPIO_FIO0PIN2 & 4)
|
|
||||||
|
|
||||||
extern unsigned int gpio1_mask;
|
extern unsigned int gpio1_mask;
|
||||||
void gpio_set(unsigned int pins);
|
void gpio_set(unsigned int pins);
|
||||||
|
|
|
||||||
80
pressure.c
80
pressure.c
|
|
@ -47,83 +47,3 @@ int calib_pressure(int hashit)
|
||||||
pressure[idx] = ((8000+X)*10)>>5;
|
pressure[idx] = ((8000+X)*10)>>5;
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline
|
|
||||||
int pressure_wait_for_conversion(int timeout)
|
|
||||||
{
|
|
||||||
while (SSP_MISO && timeout-->0);
|
|
||||||
return SSP_MISO;
|
|
||||||
}
|
|
||||||
|
|
||||||
int read_pressure(int from_phase, int to_phase, int value, struct ssp_config *sspc)
|
|
||||||
{
|
|
||||||
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 (phase = from_phase; !r && phase <= to_phase; phase++)
|
|
||||||
switch (phase) {
|
|
||||||
case 0: if (!sspc)
|
|
||||||
sspc = spi_conf_bate;
|
|
||||||
ssp_init(sspc);
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
ssp_assert_ssel(ssp_ssel);
|
|
||||||
ssp_set_buffer(pressure_reading, 8);
|
|
||||||
ssp_set_match(0, 0, 3, 0, 8);
|
|
||||||
r = ssp_submit(cmds, 11, 0, 0);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
case 6:
|
|
||||||
case 9: if (phase==to_phase)
|
|
||||||
timeout = value
|
|
||||||
else
|
|
||||||
timeout = 1000;
|
|
||||||
r = ssp_wait(timeout);
|
|
||||||
break;
|
|
||||||
case 3: pressure_reading[3] = pressure_reading[2];
|
|
||||||
pressure_reading[2] = pressure_reading[0];
|
|
||||||
pressure_reading[5] = pressure_reading[6];
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
case 7: if (phase==to_phase)
|
|
||||||
timeout = value;
|
|
||||||
else
|
|
||||||
timeout = 1000000;
|
|
||||||
r = pressure_wait_for_conversion(timeout);
|
|
||||||
break;
|
|
||||||
case 5: ssp_set_buffer(pressure_reading+6, 2);
|
|
||||||
ssp_set_match(0, 0, 0, 0, 0);
|
|
||||||
r = ssp_submit(cmds+11, 2, 0, 1);
|
|
||||||
break;
|
|
||||||
case 8: r = ssp_submit(cmds+11, 1, 0, 1);
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
ssp_deassert_ssel();
|
|
||||||
if (ssp_ssel & SSP_EXT)
|
|
||||||
pressure_reading[0] = 0xbafe;
|
|
||||||
else
|
|
||||||
pressure_reading[0] = 0xba7e;
|
|
||||||
break;
|
|
||||||
case 11:
|
|
||||||
calib_pressure(value);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
r = -1;
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
10
ssp.c
10
ssp.c
|
|
@ -77,8 +77,8 @@ static void ssp_isr(void)
|
||||||
sr=SSPSR;
|
sr=SSPSR;
|
||||||
nread++;
|
nread++;
|
||||||
ssp_lastword = ssp_lastword << ssp_bits | dr;
|
ssp_lastword = ssp_lastword << ssp_bits | dr;
|
||||||
if (ssp_frame_count++ >= ssp_match_count
|
if (!rc
|
||||||
&& !rc
|
&& ssp_frame_count++ >= ssp_match_count
|
||||||
&& (dr & ssp_match_mask) == ssp_match_value) {
|
&& (dr & ssp_match_mask) == ssp_match_value) {
|
||||||
rc = ssp_read_size;
|
rc = ssp_read_size;
|
||||||
j->idle_count = 0;
|
j->idle_count = 0;
|
||||||
|
|
@ -173,6 +173,7 @@ void ssp_reset(void)
|
||||||
j->cmd_count = 0;
|
j->cmd_count = 0;
|
||||||
j->idle_count = 0;
|
j->idle_count = 0;
|
||||||
j->read_count = 0;
|
j->read_count = 0;
|
||||||
|
ssp_set_buffer(0,0);
|
||||||
enable_irq(iflg);
|
enable_irq(iflg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,9 +236,8 @@ done:
|
||||||
|
|
||||||
int ssp_wait(int timeout)
|
int ssp_wait(int timeout)
|
||||||
{
|
{
|
||||||
unsigned int c;
|
while (ssp_busy() && timeout-->0);
|
||||||
while ((c=ssp_busy()) && timeout-->0);
|
return !timeout;
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct ssp_config ssp_conf_adc =
|
const struct ssp_config ssp_conf_adc =
|
||||||
|
|
|
||||||
14
ssp.h
14
ssp.h
|
|
@ -3,7 +3,7 @@ void ssp_reset(void);
|
||||||
|
|
||||||
void ssp_set_buffer(void *start, int size);
|
void ssp_set_buffer(void *start, int size);
|
||||||
void ssp_poll(void);
|
void ssp_poll(void);
|
||||||
int ssp_submit(unsigned short *cmd, int cmd_size, unsigned int ic, unsigned int rc);
|
int ssp_submit(unsigned short *cmd, int cmd_size, unsigned int idle, unsigned int compress);
|
||||||
int ssp_busy(void);
|
int ssp_busy(void);
|
||||||
int ssp_wait(int timeout);
|
int ssp_wait(int timeout);
|
||||||
|
|
||||||
|
|
@ -47,15 +47,3 @@ extern const struct ssp_config ssp_conf_dac;
|
||||||
extern const struct ssp_config ssp_conf_dac_daisy;
|
extern const struct ssp_config ssp_conf_dac_daisy;
|
||||||
extern const struct ssp_config ssp_conf_bate;
|
extern const struct ssp_config ssp_conf_bate;
|
||||||
extern const struct ssp_config ssp_conf_bate_ext;
|
extern const struct ssp_config ssp_conf_bate_ext;
|
||||||
|
|
||||||
static inline
|
|
||||||
void ssp_set_match(unsigned int mask, unsigned int value,
|
|
||||||
unsigned int count, unsigned int idle,
|
|
||||||
unsigned int size)
|
|
||||||
{
|
|
||||||
ssp_idle = idle;
|
|
||||||
ssp_match_mask = mask;
|
|
||||||
ssp_match_value = value;
|
|
||||||
ssp_match_count = count;
|
|
||||||
ssp_read_size = size;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue