Added the start to a EMC2101 driver. Setting fan speed works, reading fan speed doesn't.

This commit is contained in:
Skot Croshere 2023-01-18 00:34:51 -05:00 committed by johnny9
parent bab5ac54aa
commit d9b4e0e4f0
12 changed files with 535 additions and 87 deletions

38
.devcontainer/Dockerfile Normal file
View File

@ -0,0 +1,38 @@
FROM espressif/idf
ARG DEBIAN_FRONTEND=nointeractive
RUN apt-get update \
&& apt install -y -q \
cmake \
git \
hwdata \
libglib2.0-0 \
libnuma1 \
libpixman-1-0 \
linux-tools-virtual \
&& rm -rf /var/lib/apt/lists/*
RUN update-alternatives --install /usr/local/bin/usbip usbip `ls /usr/lib/linux-tools/*/usbip | tail -n1` 20
# QEMU
ENV QEMU_REL=esp-develop-20220919
ENV QEMU_SHA256=f6565d3f0d1e463a63a7f81aec94cce62df662bd42fc7606de4b4418ed55f870
ENV QEMU_DIST=qemu-${QEMU_REL}.tar.bz2
ENV QEMU_URL=https://github.com/espressif/qemu/releases/download/${QEMU_REL}/${QEMU_DIST}
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
RUN wget --no-verbose ${QEMU_URL} \
&& echo "${QEMU_SHA256} *${QEMU_DIST}" | sha256sum --check --strict - \
&& tar -xf $QEMU_DIST -C /opt \
&& rm ${QEMU_DIST}
ENV PATH=/opt/qemu/bin:${PATH}
RUN echo "source /opt/esp/idf/export.sh > /dev/null 2>&1" >> ~/.bashrc
ENTRYPOINT [ "/opt/esp/entrypoint.sh" ]
CMD ["/bin/bash"]

View File

@ -0,0 +1,29 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.183.0/containers/ubuntu
{
"name": "ESP-IDF QEMU",
"build": {
"dockerfile": "Dockerfile"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"espressif.esp-idf-extension"
],
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces,type=bind",
/* the path of workspace folder to be opened after container is running
*/
"workspaceFolder": "/workspaces",
"mounts": [
"source=extensionCache,target=/root/.vscode-server/extensions,type=volume"
],
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",
"idf.espIdfPath": "/opt/esp/idf",
"idf.customExtraPaths": "",
"idf.pythonBinPath": "/opt/esp/python_env/idf5.1_py3.8_env/bin/python",
"idf.toolsPath": "/opt/esp",
"idf.gitPath": "/usr/bin/git"
},
"runArgs": ["--privileged"]
}

29
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,29 @@
{
"configurations": [
{
"name": "ESP-IDF",
"compilerPath": "/Users/skot/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin/xtensa-esp32s3-elf-gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"includePath": [
"${config:idf.espIdfPath}/components/**",
"${config:idf.espIdfPathWin}/components/**",
"${config:idf.espAdfPath}/components/**",
"${config:idf.espAdfPathWin}/components/**",
"${workspaceFolder}/**"
],
"browse": {
"path": [
"${config:idf.espIdfPath}/components",
"${config:idf.espIdfPathWin}/components",
"${config:idf.espAdfPath}/components/**",
"${config:idf.espAdfPathWin}/components/**",
"${workspaceFolder}"
],
"limitSymbolsToIncludedHeaders": false
},
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}

10
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,10 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "espidf",
"name": "Launch",
"request": "launch"
}
]
}

22
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,22 @@
{
"C_Cpp.intelliSenseEngine": "Tag Parser",
"idf.adapterTargetName": "esp32s3",
"idf.customExtraPaths": "/Users/skot/.espressif/tools/xtensa-esp32-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32-elf/bin:/Users/skot/.espressif/tools/xtensa-esp32s2-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s2-elf/bin:/Users/skot/.espressif/tools/xtensa-esp32s3-elf/esp-2021r2-patch3-8.4.0/xtensa-esp32s3-elf/bin:/Users/skot/.espressif/tools/riscv32-esp-elf/esp-2021r2-patch3-8.4.0/riscv32-esp-elf/bin:/Users/skot/.espressif/tools/esp32ulp-elf/2.28.51-esp-20191205/esp32ulp-elf-binutils/bin:/Users/skot/.espressif/tools/esp32s2ulp-elf/2.28.51-esp-20191205/esp32s2ulp-elf-binutils/bin:/Users/skot/.espressif/tools/openocd-esp32/v0.11.0-esp32-20211220/openocd-esp32/bin",
"idf.customExtraVars": "{\"OPENOCD_SCRIPTS\":\"/Users/skot/.espressif/tools/openocd-esp32/v0.11.0-esp32-20211220/openocd-esp32/share/openocd/scripts\"}",
"idf.espIdfPath": "/Users/skot/esp/esp-idf",
"idf.openOcdConfigs": [
"interface/ftdi/esp32_devkitj_v1.cfg",
"target/esp32s3.cfg"
],
"idf.port": "/dev/cu.usbserial-14301",
"idf.pythonBinPath": "/Users/skot/.espressif/python_env/idf4.4_py3.9_env/bin/python",
"idf.toolsPath": "/Users/skot/.espressif",
"files.associations": {
"array": "c",
"string": "c",
"string_view": "c",
"ds4432u.h": "c",
"led_controller.h": "c"
},
"idf.flashType": "UART"
}

300
.vscode/tasks.json vendored Normal file
View File

@ -0,0 +1,300 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build - Build project",
"type": "shell",
"command": "${config:idf.pythonBinPath} ${config:idf.espIdfPath}/tools/idf.py build",
"windows": {
"command": "${config:idf.pythonBinPathWin} ${config:idf.espIdfPathWin}\\tools\\idf.py build",
"options": {
"env": {
"PATH": "${env:PATH};${config:idf.customExtraPaths}"
}
}
},
"options": {
"env": {
"PATH": "${env:PATH}:${config:idf.customExtraPaths}"
}
},
"problemMatcher": [
{
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "^\\.\\.(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
{
"owner": "cpp",
"fileLocation": "absolute",
"pattern": {
"regexp": "^[^\\.](.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Set ESP-IDF Target",
"type": "shell",
"command": "${command:espIdf.setTarget}",
"problemMatcher": {
"owner": "cpp",
"fileLocation": "absolute",
"pattern": {
"regexp": "^(.*):(//d+):(//d+)://s+(warning|error)://s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
{
"label": "Clean - Clean the project",
"type": "shell",
"command": "${config:idf.pythonBinPath} ${config:idf.espIdfPath}/tools/idf.py fullclean",
"windows": {
"command": "${config:idf.pythonBinPathWin} ${config:idf.espIdfPathWin}\\tools\\idf.py fullclean",
"options": {
"env": {
"PATH": "${env:PATH};${config:idf.customExtraPaths}"
}
}
},
"options": {
"env": {
"PATH": "${env:PATH}:${config:idf.customExtraPaths}"
}
},
"problemMatcher": [
{
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "^\\.\\.(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
{
"owner": "cpp",
"fileLocation": "absolute",
"pattern": {
"regexp": "^[^\\.](.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
]
},
{
"label": "Flash - Flash the device",
"type": "shell",
"command": "${config:idf.pythonBinPath} ${config:idf.espIdfPath}/tools/idf.py -p ${config:idf.port} -b ${config:idf.flashBaudRate} flash",
"windows": {
"command": "${config:idf.pythonBinPathWin} ${config:idf.espIdfPathWin}\\tools\\idf.py flash -p ${config:idf.portWin} -b ${config:idf.flashBaudRate}",
"options": {
"env": {
"PATH": "${env:PATH};${config:idf.customExtraPaths}"
}
}
},
"options": {
"env": {
"PATH": "${env:PATH}:${config:idf.customExtraPaths}"
}
},
"problemMatcher": [
{
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "^\\.\\.(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
{
"owner": "cpp",
"fileLocation": "absolute",
"pattern": {
"regexp": "^[^\\.](.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
]
},
{
"label": "Monitor: Start the monitor",
"type": "shell",
"command": "${config:idf.pythonBinPath} ${config:idf.espIdfPath}/tools/idf.py -p ${config:idf.port} monitor",
"windows": {
"command": "${config:idf.pythonBinPathWin} ${config:idf.espIdfPathWin}\\tools\\idf.py -p ${config:idf.portWin} monitor",
"options": {
"env": {
"PATH": "${env:PATH};${config:idf.customExtraPaths}"
}
}
},
"options": {
"env": {
"PATH": "${env:PATH}:${config:idf.customExtraPaths}"
}
},
"problemMatcher": [
{
"owner": "cpp",
"fileLocation": [
"relative",
"${workspaceFolder}"
],
"pattern": {
"regexp": "^\\.\\.(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
{
"owner": "cpp",
"fileLocation": "absolute",
"pattern": {
"regexp": "^[^\\.](.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
],
"dependsOn": "Flash - Flash the device"
},
{
"label": "OpenOCD: Start openOCD",
"type": "shell",
"presentation": {
"echo": true,
"reveal": "never",
"focus": false,
"panel": "new"
},
"command": "openocd -s ${command:espIdf.getOpenOcdScriptValue} ${command:espIdf.getOpenOcdConfigs}",
"windows": {
"command": "openocd.exe -s ${command:espIdf.getOpenOcdScriptValue} ${command:espIdf.getOpenOcdConfigs}",
"options": {
"env": {
"PATH": "${env:PATH};${config:idf.customExtraPaths}"
}
}
},
"options": {
"env": {
"PATH": "${env:PATH}:${config:idf.customExtraPaths}"
}
},
"problemMatcher": {
"owner": "cpp",
"fileLocation": "absolute",
"pattern": {
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
}
},
{
"label": "adapter",
"type": "shell",
"command": "${config:idf.pythonBinPath}",
"isBackground": true,
"options": {
"env": {
"PATH": "${env:PATH}:${config:idf.customExtraPaths}",
"PYTHONPATH": "${command:espIdf.getExtensionPath}/esp_debug_adapter/debug_adapter"
}
},
"problemMatcher": {
"background": {
"beginsPattern": "\bDEBUG_ADAPTER_STARTED\b",
"endsPattern": "DEBUG_ADAPTER_READY2CONNECT",
"activeOnStart": true
},
"pattern": {
"regexp": "(\\d+)-(\\d+)-(\\d+)\\s(\\d+):(\\d+):(\\d+),(\\d+)\\s-(.+)\\s(ERROR)",
"file": 8,
"line": 2,
"column": 3,
"severity": 4,
"message": 9
}
},
"args": [
"${command:espIdf.getExtensionPath}/esp_debug_adapter/debug_adapter_main.py",
"-e",
"${workspaceFolder}/build/${command:espIdf.getProjectName}.elf",
"-s",
"${command:espIdf.getOpenOcdScriptValue}",
"-ip",
"localhost",
"-dn",
"${config:idf.adapterTargetName}",
"-om",
"connect_to_instance"
],
"windows": {
"command": "${config:idf.pythonBinPathWin}",
"options": {
"env": {
"PATH": "${env:PATH};${config:idf.customExtraPaths}",
"PYTHONPATH": "${command:espIdf.getExtensionPath}/esp_debug_adapter/debug_adapter"
}
}
}
}
]
}

View File

@ -1,72 +0,0 @@
## BM1397 protocol
notes from sniffing BM1397 communication and trying to match it up with cgminer
It looks like this setting up the BM1397:
(TX is _to_ the BM1397, RX is _from_ the BM1397)
```
TX: 55 AA 52 05 00 00 0A //chippy
RX: AA 55 13 97 18 00 00 00 06 //response from the BM1397
TX: 55 AA 53 05 00 00 03 //chain inactive
TX: 55 AA 53 05 00 00 03 //chain inactive
TX: 55 AA 53 05 00 00 03 //chain inactive
TX: 55 AA 40 05 00 00 1C //chippy
TX: 55 AA 51 09 00 80 00 00 00 00 1C //init1 - clock_order_control0
TX: 55 AA 51 09 00 84 00 00 00 00 11 //init2 - clock_order_control1
TX: 55 AA 51 09 00 20 00 00 00 01 02 //init3 - ordered_clock_enable
TX: 55 AA 51 09 00 3C 80 00 80 74 10 //init4 - init_4_?
TX: 55 AA 51 09 00 14 00 00 00 00 1C //set_ticket - ticket_mask
TX: 55 AA 51 09 00 68 C0 70 01 11 00 //init5 - pll3_parameter
TX: 55 AA 51 09 00 68 C0 70 01 11 00 //init5 - pll3_parameter
TX: 55 AA 51 09 00 28 06 00 00 0F 18 //init6 - fast_uart_configuration
TX: 55 AA 51 09 00 18 00 00 7A 31 15 //baudrate - misc_control
TX: 55 AA 51 09 00 70 0F 0F 0F 00 19 //prefreq - pll0_divider
TX: 55 AA 51 09 00 70 0F 0F 0F 00 19 //prefreq - pll0_divider
TX: 55 AA 51 09 00 08 40 A0 02 25 16 //freqbuf - pll0_parameter
TX: 55 AA 51 09 00 08 40 A0 02 25 16 //freqbuf - pll0_parameter
```
Sending work to the BM1397 looks like this;
```
55 AA 21 96 04 04 00 00 00 00 A3 89 06 17 2F A8 0A 64 6F 1C C5 E8 99 CE 15 A2 DE DF 61 49 77 90 69 84 1C 8A 0C E0 A0 30 E4 0A CB A6 A5 FB 33 19 30 5D E2 46 EF 18 1D 63 63 EB E7 BA D9 8D 4B CA FE 9C 4F 45 F6 45 FA 71 A0 1E 8C B8 2D 68 DC 6C B8 4E 25 39 8C 50 FA 7E 2E C6 C8 08 61 B9 A5 89 90 71 C4 75 56 E4 78 85 35 22 65 51 EA 68 EB F8 96 B0 CA 40 77 D4 0C AF 1B D4 47 37 85 BB 39 6A 22 C3 9C 23 56 E7 CE B6 57 4C 1F A3 A9 9A D3 C1 A0 17 79 1F BC 38 8C 24
```
How does this big work field break down?
`55 AA` - (most) All of the commands to the BM1397 start with this
`21` - Header fields -> (TYPE_JOB | GROUP_SINGLE | CMD_WRITE)
`96` - Length
`04` - JobID
`04` - Midstates
`00 00 00 00` - always zero. Is this the starting nonce?
`A3 89 06 17` - nbits
`2F A8 0A 64` - ntime → Fri Mar 10 2023 03:46:55 GMT
`6F 1C C5 E8` - last 4 bytes of the merkle root
`99 CE 15 A2 DE DF 61 49 77 90 69 84 1C 8A 0C E0 A0 30 E4 0A CB A6 A5 FB 33 19 30 5D E2 46 EF 18` - midstate computed from the first 64 bytes of the header
`1D 63 63 EB E7 BA D9 8D 4B CA FE 9C 4F 45 F6 45 FA 71 A0 1E 8C B8 2D 68 DC 6C B8 4E 25 39 8C 50` - midstate 2
`FA 7E 2E C6 C8 08 61 B9 A5 89 90 71 C4 75 56 E4 78 85 35 22 65 51 EA 68 EB F8 96 B0 CA 40 77 D4` - midstate 3
`0C AF 1B D4 47 37 85 BB 39 6A 22 C3 9C 23 56 E7 CE B6 57 4C 1F A3 A9 9A D3 C1 A0 17 79 1F BC 38` - midstate 4
`8C 24` - checksum
- for the checksum use crc16_false() on all bytes except for `55 AA`
when the BM1397 finds a nonce that makes a hash below the difficulty (which difficulty is that?) it responds with;
```
AA 55 00 03 EA 0F 02 20 9C
```
this means the Nonce `0003EA0F` was found for JobID `20`
If the BM1397 _doesn't_ find a good nonce in the whole nonce space, it just starts over. This is super wasteful, so it's up to the miner to keep track of what the ASIC is doing and send it more work if this happens. If you look at the hashing frequency you should be able to time this.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 KiB

View File

@ -1,2 +1,2 @@
idf_component_register(SRCS "i2c_simple_main.c" "led_controller.c" "DS4432U.c"
idf_component_register(SRCS "EMC2101.c" "i2c_simple_main.c" "led_controller.c" "DS4432U.c" "EMC2101.c"
INCLUDE_DIRS ".")

View File

@ -1,8 +1,81 @@
#include <stdio.h>
#include "esp_log.h"
#include "driver/i2c.h"
#define I2C_MASTER_SCL_IO CONFIG_I2C_MASTER_SCL /*!< GPIO number used for I2C master clock */
#define I2C_MASTER_SDA_IO CONFIG_I2C_MASTER_SDA /*!< GPIO number used for I2C master data */
#define I2C_MASTER_NUM 0 /*!< I2C master i2c port number, the number of i2c peripheral interfaces available will depend on the chip */
#define I2C_MASTER_FREQ_HZ 400000 /*!< I2C master clock frequency */
#define I2C_MASTER_TX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
#define I2C_MASTER_RX_BUF_DISABLE 0 /*!< I2C master doesn't need buffer */
#define I2C_MASTER_TIMEOUT_MS 1000
//EMC2101 -- Fan and temp sensor controller
//address: 0x4C
#define EMC2101_SENSOR_ADDR 0x4C //Slave address of the EMC2101
#define EMC2101_PRODUCTID_REG 0xFD //should be 0x16 or 0x28
#define EMC2101_CONFIG_REG 0x03
// /* Read the EMC2101 WHO_AM_I register, on power up the register should have the value 0x16 or 0x28 */
// ESP_ERROR_CHECK(register_read(EMC2101_SENSOR_ADDR, EMC2101_PRODUCTID_REG, data, 1));
// ESP_LOGI(TAG, "EMC2101 PRODUCT ID = 0x%02X", data[0]);
#define EMC2101_FANCONFIG_REG 0x4A
#define EMC2101_FANSETTING_REG 0x4C
#define EMC2101_TACHREADING_REG 0x46 //2 bytes
static const char *TAG = "EMC2101.c";
/**
* @brief Read a sequence of I2C bytes
*/
static esp_err_t register_read(uint8_t reg_addr, uint8_t *data, size_t len) {
return i2c_master_write_read_device(I2C_MASTER_NUM, EMC2101_SENSOR_ADDR, &reg_addr, 1, data, len, I2C_MASTER_TIMEOUT_MS / portTICK_RATE_MS);
}
/**
* @brief Write a byte to a I2C register
*/
static esp_err_t register_write_byte(uint8_t reg_addr, uint8_t data) {
int ret;
uint8_t write_buf[2] = {reg_addr, data};
ret = i2c_master_write_to_device(I2C_MASTER_NUM, EMC2101_SENSOR_ADDR, write_buf, sizeof(write_buf), I2C_MASTER_TIMEOUT_MS / portTICK_RATE_MS);
return ret;
}
//takes a fan speed percent
void EMC2101_set_config(uint8_t reg) {
ESP_ERROR_CHECK(register_write_byte(EMC2101_CONFIG_REG, reg));
}
//takes a fan speed percent
void EMC2101_set_fan_speed(float percent) {
uint8_t speed;
speed = (uint8_t)(63.0 * percent);
ESP_ERROR_CHECK(register_write_byte(EMC2101_FANSETTING_REG, speed));
}
//RPM = 5400000/reading
uint32_t EMC2101_get_fan_speed(void) {
uint8_t data[3];
uint16_t reading;
uint32_t RPM;
ESP_ERROR_CHECK(register_read(EMC2101_TACHREADING_REG, data, 2));
ESP_LOGI(TAG, "Raw Fan Speed = %02X %02X", data[0], data[1]);
reading = data[0] | (data[1] << 8);
RPM = 5400000/reading;
ESP_LOGI(TAG, "Fan Speed = %d RPM", RPM);
return RPM;
}
void EMC2101_read(void) {
uint8_t data[3];
/* Read the EMC2101 WHO_AM_I register, on power up the register should have the value 0x16 or 0x28 */
ESP_ERROR_CHECK(register_read(EMC2101_PRODUCTID_REG, data, 1));
ESP_LOGI(TAG, "EMC2101 PRODUCT ID = 0x%02X", data[0]);
}

9
main/EMC2101.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef EMC2101_H_
#define EMC2101_H_
void EMC2101_set_fan_speed(float);
void EMC2101_read(void);
uint32_t EMC2101_get_fan_speed(void);
void EMC2101_set_config(uint8_t);
#endif /* EMC2101_H_ */

View File

@ -18,33 +18,43 @@
#include "esp_log.h"
#include "driver/i2c.h"
// Include FreeRTOS for delay
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include "led_controller.h"
#include "DS4432U.h"
#include "EMC2101.h"
static const char *TAG = "i2c-test";
void app_main(void) {
//test the LEDs
ESP_LOGI(TAG, "Init LEDs!");
ledc_init();
led_set();
// ESP_LOGI(TAG, "Init LEDs!");
// ledc_init();
// led_set();
ESP_ERROR_CHECK(i2c_master_init());
ESP_LOGI(TAG, "I2C initialized successfully");
DS4432U_read();
// DS4432U_read();
DS4432U_set(0x00);
float core_voltage = 1.0;
uint8_t reg_setting;
// DS4432U_set(0x00);
// float core_voltage = 1.0;
// uint8_t reg_setting;
reg_setting = voltage_to_reg(core_voltage);
// reg_setting = voltage_to_reg(core_voltage);
ESP_LOGI(TAG, "Test set %.3fV = 0x%02X", core_voltage, reg_setting);
// ESP_LOGI(TAG, "Test set %.3fV = 0x%02X", core_voltage, reg_setting);
DS4432U_set(reg_setting); ///eek!
// DS4432U_set(reg_setting); ///eek!
EMC2101_read();
EMC2101_set_config(0x04); //set the tach input
EMC2101_set_fan_speed(0.5);
vTaskDelay(2000 / portTICK_RATE_MS);
EMC2101_get_fan_speed();
ESP_ERROR_CHECK(i2c_master_delete());
ESP_LOGI(TAG, "I2C unitialized successfully");