|
|
@@ -0,0 +1,25 @@
|
|
|
+#include "potentiometer.h"
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+void potentiometer_set(void *bar1, uint8_t pot_val_ch_a, uint8_t pot_val_ch_b) {
|
|
|
+ uint32_t cfg_reg = get_cfg_reg();
|
|
|
+ SET_REGISTER_PARAM(cfg_reg, CFG_REG_SPI_MODE_BITM, CFG_REG_SPI_MODE_BITP, CFG_REG_SPI_MODE_4MOSI);
|
|
|
+ uint32_t *spi_mode = bar1 + CFG_REG_ADDR;
|
|
|
+ *spi_mode = cfg_reg;
|
|
|
+
|
|
|
+ uint32_t pot_ch_a = (TPL0202_CMD_WR_WIPER_REG_ENUM << TPL0202_CMD_BITP)|(TPL0202_ADR_B_ENUM << TPL0202_ADR_BITP)|(pot_val_ch_a << TPL0202_DATA_BITP);
|
|
|
+ uint32_t pot_ch_b = (TPL0202_CMD_WR_WIPER_REG_ENUM << TPL0202_CMD_BITP)|(TPL0202_ADR_A_ENUM << TPL0202_ADR_BITP)|(pot_val_ch_b << TPL0202_DATA_BITP);
|
|
|
+ // Create a header for the Potentiometer 4MOSI
|
|
|
+ uint32_t pot_header = (ENUM_SPIMODE_4MOSI | (0x2 << BITP_POT_4MOSI_HEADER) | SB_HEADER_TERM_BIT_1);
|
|
|
+ uint32_t *ptr = bar1 + LMX_BASE_ADDR;
|
|
|
+ *ptr = pot_header;
|
|
|
+ // Send the data
|
|
|
+ *ptr = pot_ch_a;
|
|
|
+ *ptr = pot_ch_b;
|
|
|
+ usleep(1);
|
|
|
+ SET_REGISTER_PARAM(cfg_reg, CFG_REG_SPI_MODE_BITM, CFG_REG_SPI_MODE_BITP, CFG_REG_SPI_MODE_1MOSI);
|
|
|
+ *spi_mode = cfg_reg;
|
|
|
+
|
|
|
+ set_cfg_reg(cfg_reg);
|
|
|
+}
|