* @param[in] and_ and_ value is bitwise AND by shadow register for the command
* @param[in] xor_ xor_ value is bitwise XOR by product of shadow register AND
* and_
- * @return return spi response
+ * @return return spi response or zero in case of error
*/
uint16_t din_set_reg(enum SpiCmdTable cmd_index, uint16_t and_, uint16_t xor_);
*/
int din_spi_transfer_mst(const uint32_t din_spi_cmd);
-/**
- * This find an index in register list
- * @param index
- * @return command
- */
-uint32_t din_spi_get_command_from_enum(const uint8_t index);
-
-
-
/******************************************************************************
* Close variable declaration sections
******************************************************************************/
#define DACA_INIT_VAL (_BV(13) | _BV(12) )
#define DACB_INIT_VAL (_BV(13) | _BV(12) | _BV(15))
+/**
+ * This find an index in register list
+ * @param command
+ * @return index
+ */
+static uint32_t enum2cmd(const enum SpiCmdTable index)
+{
+ if (index == DIN_RESET_CMD)
+ return 0x007F0000;
+ else
+ return index << 16;
+}
/* Public functions */
/* ---------------- */
uint16_t din_set_reg(
enum SpiCmdTable spi_cmd_index, uint16_t clear_mask, uint16_t xor_mask)
{
- if ((uint8_t)spi_cmd_index > DIN_NUM_SPI_CMD){
+ if (spi_cmd_index >= DIN_NUM_SPI_CMD) {
return 0;
}
- else{}
shadow_reg_list[spi_cmd_index] =
shadow_reg_list[spi_cmd_index] & ~clear_mask ^ xor_mask;
- uint32_t din_spi_cmd = din_spi_get_command_from_enum(spi_cmd_index) |
- shadow_reg_list[spi_cmd_index];
+ uint32_t din_spi_cmd = enum2cmd(spi_cmd_index) | shadow_reg_list[spi_cmd_index];
return din_spi_transfer_mst(din_spi_cmd);
}
commands);
return din_spi_resp;
}
-/**
- * This find an index in register list
- * @param command
- * @return index
- */
-uint32_t din_spi_get_command_from_enum(const uint8_t index)
-{
- uint32_t command = 0x0;
-
- if (index == DIN_RESET_CMD){
- return 0x007F0000;
- }
- else {}
-
- command = index << 16;
- return command;
-}