Change SGPIO CPLD decimation API interface to be one-based (decimation of 1 to 8).

This commit is contained in:
Jared Boone
2014-06-15 10:12:43 -07:00
parent 44df9d1f82
commit 0ab6a92ae6
2 changed files with 4 additions and 3 deletions

View File

@ -48,7 +48,7 @@ void sgpio_configure_pin_functions() {
scu_pinmux(SCU_PINMUX_SGPIO14, SCU_GPIO_FAST | SCU_CONF_FUNCTION4); /* GPIO5[13] */
scu_pinmux(SCU_PINMUX_SGPIO15, SCU_GPIO_FAST | SCU_CONF_FUNCTION4); /* GPIO5[14] */
sgpio_cpld_stream_rx_set_decimation(0);
sgpio_cpld_stream_rx_set_decimation(1);
GPIO_DIR(GPIO5) |= GPIOPIN14 | GPIOPIN13 | GPIOPIN12;
}
@ -286,7 +286,7 @@ bool sgpio_cpld_stream_is_enabled() {
return (SGPIO_GPIO_OUTREG & (1L << 10)) == 0; /* SGPIO10 */
}
bool sgpio_cpld_stream_rx_set_decimation(const uint_fast8_t skip_n) {
bool sgpio_cpld_stream_rx_set_decimation(const uint_fast8_t n) {
/* CPLD interface is three bits, SGPIO[15:13]:
* 111: decimate by 1 (skip_n=0, skip no samples)
* 110: decimate by 2 (skip_n=1, skip every other sample)
@ -294,6 +294,7 @@ bool sgpio_cpld_stream_rx_set_decimation(const uint_fast8_t skip_n) {
* ...
* 000: decimate by 8 (skip_n=7, skip seven of eight samples)
*/
const uint_fast8_t skip_n = n - 1;
GPIO_SET(GPIO5) = GPIOPIN14 | GPIOPIN13 | GPIOPIN12;
GPIO_CLR(GPIO5) = (skip_n & 7) << 12;

View File

@ -41,6 +41,6 @@ void sgpio_cpld_stream_enable();
void sgpio_cpld_stream_disable();
bool sgpio_cpld_stream_is_enabled();
bool sgpio_cpld_stream_rx_set_decimation(const uint_fast8_t skip_n);
bool sgpio_cpld_stream_rx_set_decimation(const uint_fast8_t n);
#endif//__SGPIO_H__