void ADS131M03_Init(void)
{
    // Ensure SYNC/RESET is High so the chip can wake up
    HAL_GPIO_WritePin(ADC_SYNC_GPIO_Port, ADC_SYNC_Pin, GPIO_PIN_SET);

    /* -------------------------------------------------------------------------
    * Unlock sequence
    * ----------------------------------------------------------------------- */
    uint8_t unlock_cmd[3] = {0x06, 0x55, 0x00};                                 // For 24-bit SPI, the command is 0x06 0x55 0x00
    HAL_GPIO_WritePin(ADC_CS_GPIO_Port, ADC_CS_Pin, GPIO_PIN_RESET);
    HAL_SPI_Transmit(&hspi1, unlock_cmd, 3, 100);
    HAL_GPIO_WritePin(ADC_CS_GPIO_Port, ADC_CS_Pin, GPIO_PIN_SET);

    /* -------------------------------------------------------------------------
    * Write to CLOCK Register (0x0D) to enable channels; Opcode: 0x6000 | (Address << 7) -> (0x6000 | (0x0D << 7)) = 0x6680
    * ----------------------------------------------------------------------- */
    uint8_t clock_enable_packet[6] = {0x66, 0x80, 0x00, 0x00, 0x00, 0x3F};      // Full 24-bit command: 0x66 0x80 0x00 + Data Word: 0x00 0x00 0x3F
    HAL_GPIO_WritePin(ADC_CS_GPIO_Port, ADC_CS_Pin, GPIO_PIN_RESET);
    HAL_SPI_Transmit(&hspi1, clock_enable_packet, 6, 100);                      // We send them in one continuous CS assertion
    HAL_GPIO_WritePin(ADC_CS_GPIO_Port, ADC_CS_Pin, GPIO_PIN_SET);

    /* -------------------------------------------------------------------------
    * Send a NULL command to clear the RESET flag
    * ----------------------------------------------------------------------- */
    uint8_t null_cmd[3] = {0x00, 0x00, 0x00};                                   // Once the ADC sees a valid command, the Status Word will change to 0x2200
    HAL_GPIO_WritePin(ADC_CS_GPIO_Port, ADC_CS_Pin, GPIO_PIN_RESET);
    HAL_SPI_Transmit(&hspi1, null_cmd, 3, 100);
    HAL_GPIO_WritePin(ADC_CS_GPIO_Port, ADC_CS_Pin, GPIO_PIN_SET);
}

void ADS131M03_Rate_Config(void)
{
    /* -------------------------------------------------------------------------
    * Reset CS 
    * ----------------------------------------------------------------------- */
    HAL_GPIO_WritePin(ADC_CS_GPIO_Port, ADC_CS_Pin, GPIO_PIN_SET);              // ensure CS is high 

    /* -------------------------------------------------------------------------
    * Clock configuration byte construction
    * ----------------------------------------------------------------------- */
    uint8_t unlock[3] = {0x06, 0x55, 0x00};                                     // address 0x0655 + 8-bit padding
    uint8_t wreg_opcode[3] = {0x61, 0x80, 0x00};                                // WREG Opcode for Address 0x03 (CLOCK Register); Formula: 0x6000 | (0x03 << 7) = 0x6180
    uint8_t reg_data[3] = {0x08, 0x22, 0x00};                                   // config data for CLOCK Register

    /* -------------------------------------------------------------------------
    * Send SPI data
    * ----------------------------------------------------------------------- */
    HAL_GPIO_WritePin(ADC_CS_GPIO_Port, ADC_CS_Pin, GPIO_PIN_RESET);            // CS low to start communication
    HAL_SPI_Transmit(&hspi1, unlock, 3, 100);                                   // send unlock
    HAL_SPI_Transmit(&hspi1, wreg_opcode, 3, 100);                              // send opcode
    HAL_SPI_Transmit(&hspi1, reg_data, 3, 100);                                 // send clock config register data
    HAL_GPIO_WritePin(ADC_CS_GPIO_Port, ADC_CS_Pin, GPIO_PIN_SET);              // CS high to end communication
}