1
0
forked from me/IronOS

Merge branch 'dev' into refactor-gui-files

This commit is contained in:
Ben V. Brown
2022-11-25 21:24:49 +11:00
11 changed files with 230 additions and 270 deletions

View File

@@ -8,8 +8,8 @@
], ],
"tempUnitFahrenheit": false, "tempUnitFahrenheit": false,
"messages": { "messages": {
"SettingsCalibrationWarning": "Before rebooting, make sure tip & handle are at room temperature!", "SettingsCalibrationWarning": "Пераканайцеся, што пры наступнай загрузцы наканечнік і ручка маюць пакаёвую тэмпературу!",
"CJCCalibrating": "calibrating", "CJCCalibrating": "каліброўка",
"SettingsResetWarning": "Вы ўпэннены, што жадаеце зкінуць налады да першапачатковых значэнняў?", "SettingsResetWarning": "Вы ўпэннены, што жадаеце зкінуць налады да першапачатковых значэнняў?",
"UVLOWarningString": "НАПРУГА--", "UVLOWarningString": "НАПРУГА--",
"UndervoltageString": "Нізкая напруга", "UndervoltageString": "Нізкая напруга",

View File

@@ -7,8 +7,8 @@
], ],
"tempUnitFahrenheit": false, "tempUnitFahrenheit": false,
"messages": { "messages": {
"SettingsCalibrationWarning": "Before rebooting, make sure tip & handle are at room temperature!", "SettingsCalibrationWarning": "Upewnij się, że końcówka i uchwyt mają temperaturę pokojową podczas następnego rozruchu!",
"CJCCalibrating": "calibrating", "CJCCalibrating": "kalibracja",
"SettingsResetWarning": "Czy na pewno chcesz przywrócić ustawienia fabryczne?", "SettingsResetWarning": "Czy na pewno chcesz przywrócić ustawienia fabryczne?",
"UVLOWarningString": "NIS. NAP", "UVLOWarningString": "NIS. NAP",
"UndervoltageString": "Zbyt niskie nap.", "UndervoltageString": "Zbyt niskie nap.",

View File

@@ -8,8 +8,8 @@
], ],
"tempUnitFahrenheit": false, "tempUnitFahrenheit": false,
"messages": { "messages": {
"SettingsCalibrationWarning": "Before rebooting, make sure tip & handle are at room temperature!", "SettingsCalibrationWarning": "Пожалуйста, убедитесь, что жало и корпус имеют комнатную температуру при следующей загрузке!",
"CJCCalibrating": "calibrating", "CJCCalibrating": "калибровка",
"SettingsResetWarning": "Вы уверены, что хотите сбросить настройки к значениям по умолчанию?", "SettingsResetWarning": "Вы уверены, что хотите сбросить настройки к значениям по умолчанию?",
"UVLOWarningString": "НАПРЯЖ--", "UVLOWarningString": "НАПРЯЖ--",
"UndervoltageString": "Низ. напряжение", "UndervoltageString": "Низ. напряжение",

View File

@@ -8,8 +8,8 @@
], ],
"tempUnitFahrenheit": false, "tempUnitFahrenheit": false,
"messages": { "messages": {
"SettingsCalibrationWarning": "Before rebooting, make sure tip & handle are at room temperature!", "SettingsCalibrationWarning": "Під час наступного завантаження переконайтеся, що жало і ручка мають кімнатну температуру!",
"CJCCalibrating": "calibrating", "CJCCalibrating": "калібрування",
"SettingsResetWarning": "Ви дійсно хочете скинути налаштування до значень за замовчуванням? (A=Так, В=Ні)", "SettingsResetWarning": "Ви дійсно хочете скинути налаштування до значень за замовчуванням? (A=Так, В=Ні)",
"UVLOWarningString": "АККУМ--", "UVLOWarningString": "АККУМ--",
"UndervoltageString": "Низька напруга", "UndervoltageString": "Низька напруга",

View File

@@ -40,7 +40,9 @@ bool FRToSI2C::Mem_Read(uint16_t DevAddress, uint16_t read_address, uint8_t *p_b
i2cCfg.data = p_buffer; i2cCfg.data = p_buffer;
i2cCfg.subAddrSize = 1; // one byte address i2cCfg.subAddrSize = 1; // one byte address
taskENTER_CRITICAL();
err = I2C_MasterReceiveBlocking(I2C0_ID, &i2cCfg); err = I2C_MasterReceiveBlocking(I2C0_ID, &i2cCfg);
taskEXIT_CRITICAL();
bool res = err == SUCCESS; bool res = err == SUCCESS;
if (!res) { if (!res) {
I2C_Unstick(); I2C_Unstick();
@@ -61,8 +63,9 @@ bool FRToSI2C::Mem_Write(uint16_t DevAddress, uint16_t MemAddress, uint8_t *p_bu
i2cCfg.dataSize = number_of_byte; i2cCfg.dataSize = number_of_byte;
i2cCfg.data = p_buffer; i2cCfg.data = p_buffer;
i2cCfg.subAddrSize = 1; // one byte address i2cCfg.subAddrSize = 1; // one byte address
taskENTER_CRITICAL();
err = I2C_MasterSendBlocking(I2C0_ID, &i2cCfg); err = I2C_MasterSendBlocking(I2C0_ID, &i2cCfg);
taskEXIT_CRITICAL();
bool res = err == SUCCESS; bool res = err == SUCCESS;
if (!res) { if (!res) {
I2C_Unstick(); I2C_Unstick();

View File

@@ -37,7 +37,11 @@ void hardware_init() {
setup_timer_scheduler(); setup_timer_scheduler();
setup_adc(); setup_adc();
setup_pwm(); setup_pwm();
I2C_ClockSet(I2C0_ID, 200000); // Sets clock to around 175kHz I2C_SetSclSync(I2C0_ID,1);
I2C_SetDeglitchCount(I2C0_ID,1); // Turn on de-glitch
//Note on I2C clock rate @ 100Khz the screen update == 20ms which is too long for USB-PD to work
//200kHz and above works
I2C_ClockSet(I2C0_ID, 300000); // Sets clock to around 25 kHz less than set here
TIMER_SetCompValue(TIMER_CH0, TIMER_COMP_ID_1, 0); TIMER_SetCompValue(TIMER_CH0, TIMER_COMP_ID_1, 0);
} }
void setup_pwm(void) { void setup_pwm(void) {

View File

@@ -21,8 +21,8 @@
* *
*/ */
#include "hal_i2c.h" #include "hal_i2c.h"
#include "bl702_i2c.h"
#include "bl702_glb.h" #include "bl702_glb.h"
#include "bl702_i2c.h"
static i2c_device_t i2cx_device[I2C_MAX_INDEX] = { static i2c_device_t i2cx_device[I2C_MAX_INDEX] = {
#ifdef BSP_USING_I2C0 #ifdef BSP_USING_I2C0
@@ -39,8 +39,7 @@ static i2c_device_t i2cx_device[I2C_MAX_INDEX] = {
* @param oflag * @param oflag
* @return int * @return int
*/ */
int i2c_open(struct device *dev, uint16_t oflag) int i2c_open(struct device *dev, uint16_t oflag) {
{
i2c_device_t *i2c_device = (i2c_device_t *)dev; i2c_device_t *i2c_device = (i2c_device_t *)dev;
if (i2c_device->mode == I2C_HW_MODE) { if (i2c_device->mode == I2C_HW_MODE) {
@@ -50,54 +49,6 @@ int i2c_open(struct device *dev, uint16_t oflag)
return 0; return 0;
} }
// int i2c_close(struct device *dev)
// {
// return 0;
// }
// int i2c_control(struct device *dev, int cmd, void *args)
// {
// //i2c_device_t *i2c_device = (i2c_device_t *)dev;
// switch (cmd)
// {
// case DEVICE_CTRL_SET_INT /* constant-expression */:
// break;
// case DEVICE_CTRL_CLR_INT /* constant-expression */:
// /* code */
// /* Enable UART interrupt*/
// break;
// case DEVICE_CTRL_GET_INT /* constant-expression */:
// /* code */
// break;
// case DEVICE_CTRL_CONFIG /* constant-expression */:
// /* code */
// break;
// case 4 /* constant-expression */:
// /* code */
// break;
// case 5 /* constant-expression */:
// /* code */
// break;
// default:
// break;
// }
// return 0;
// }
// int i2c_write(struct device *dev, uint32_t pos, const void *buffer, uint32_t size)
// {
// return 0;
// }
// int i2c_read(struct device *dev, uint32_t pos, void *buffer, uint32_t size)
// {
// return 0;
// }
/** /**
* @brief * @brief
* *
@@ -106,8 +57,7 @@ int i2c_open(struct device *dev, uint16_t oflag)
* @param flag * @param flag
* @return int * @return int
*/ */
int i2c_register(enum i2c_index_type index, const char *name) int i2c_register(enum i2c_index_type index, const char *name) {
{
struct device *dev; struct device *dev;
if (I2C_MAX_INDEX == 0) { if (I2C_MAX_INDEX == 0) {
@@ -135,10 +85,9 @@ int i2c_register(enum i2c_index_type index, const char *name)
* @param num * @param num
* @return uint32_t * @return uint32_t
*/ */
int i2c_transfer(struct device *dev, i2c_msg_t msgs[], uint32_t num) int i2c_transfer(struct device *dev, i2c_msg_t msgs[], uint32_t num) {
{
i2c_msg_t *msg; i2c_msg_t *msg;
I2C_Transfer_Cfg i2cCfg = { 0 }; I2C_Transfer_Cfg i2cCfg = {0};
i2c_device_t *i2c_device = (i2c_device_t *)dev; i2c_device_t *i2c_device = (i2c_device_t *)dev;

View File

@@ -89,7 +89,7 @@ intCallback_Type *i2cIntCbfArra[I2C_ID_MAX][I2C_INT_ALL] = {{NULL}};
* @{ * @{
*/ */
/****************************************************************************/ /** /**
* @brief I2C interrupt handler * @brief I2C interrupt handler
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -157,7 +157,7 @@ static void I2C_IntHandler(I2C_ID_Type i2cNo) {
* @{ * @{
*/ */
/****************************************************************************/ /** /**
* @brief I2C write word data * @brief I2C write word data
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -174,7 +174,7 @@ void I2C_SendWord(I2C_ID_Type i2cNo, uint32_t data) {
BL_WR_REG(I2Cx, I2C_FIFO_WDATA, data); BL_WR_REG(I2Cx, I2C_FIFO_WDATA, data);
} }
/****************************************************************************/ /** /**
* @brief I2C read word data * @brief I2C read word data
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -190,7 +190,7 @@ uint32_t I2C_RecieveWord(I2C_ID_Type i2cNo) {
return BL_RD_REG(I2Cx, I2C_FIFO_RDATA); return BL_RD_REG(I2Cx, I2C_FIFO_RDATA);
} }
/****************************************************************************/ /** /**
* @brief I2C enable * @brief I2C enable
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -210,7 +210,7 @@ void I2C_Enable(I2C_ID_Type i2cNo) {
BL_WR_REG(I2Cx, I2C_CONFIG, tmpVal); BL_WR_REG(I2Cx, I2C_CONFIG, tmpVal);
} }
/****************************************************************************/ /** /**
* @brief I2C disable * @brief I2C disable
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -243,7 +243,7 @@ void I2C_Disable(I2C_ID_Type i2cNo) {
BL_WR_REG(I2Cx, I2C_INT_STS, tmpVal); BL_WR_REG(I2Cx, I2C_INT_STS, tmpVal);
} }
/****************************************************************************/ /** /**
* @brief I2C set global reset function * @brief I2C set global reset function
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -259,7 +259,7 @@ BL_Err_Type I2C_Reset(I2C_ID_Type i2cNo) {
return SUCCESS; return SUCCESS;
} }
/****************************************************************************/ /** /**
* @brief I2C init function * @brief I2C init function
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -308,7 +308,7 @@ void I2C_Init(I2C_ID_Type i2cNo, I2C_Direction_Type direct, I2C_Transfer_Cfg *cf
#endif #endif
} }
/****************************************************************************/ /** /**
* @brief Set de-glitch function cycle count value * @brief Set de-glitch function cycle count value
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -343,7 +343,7 @@ BL_Err_Type I2C_SetDeglitchCount(I2C_ID_Type i2cNo, uint8_t cnt) {
return SUCCESS; return SUCCESS;
} }
/****************************************************************************/ /** /**
* @brief Set i2c prd * @brief Set i2c prd
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -380,7 +380,7 @@ void I2C_SetPrd(I2C_ID_Type i2cNo, uint8_t phase) {
BL_WR_REG(I2Cx, I2C_PRD_DATA, tmpVal); BL_WR_REG(I2Cx, I2C_PRD_DATA, tmpVal);
} }
/****************************************************************************/ /** /**
* @brief I2C set scl output clock * @brief I2C set scl output clock
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -412,7 +412,7 @@ void I2C_ClockSet(I2C_ID_Type i2cNo, uint32_t clk) {
} }
} }
/****************************************************************************/ /** /**
* @brief I2C set scl sync * @brief I2C set scl sync
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -439,7 +439,7 @@ void I2C_SetSclSync(I2C_ID_Type i2cNo, uint8_t enable) {
BL_WR_REG(I2Cx, I2C_CONFIG, tmpVal); BL_WR_REG(I2Cx, I2C_CONFIG, tmpVal);
} }
/****************************************************************************/ /** /**
* @brief Get i2c busy state * @brief Get i2c busy state
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -458,7 +458,7 @@ BL_Sts_Type I2C_IsBusy(I2C_ID_Type i2cNo) {
return ((BL_IS_REG_BIT_SET(tmpVal, I2C_STS_I2C_BUS_BUSY)) ? SET : RESET); return ((BL_IS_REG_BIT_SET(tmpVal, I2C_STS_I2C_BUS_BUSY)) ? SET : RESET);
} }
/****************************************************************************/ /** /**
* @brief Get i2c transfer end state * @brief Get i2c transfer end state
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -477,7 +477,7 @@ BL_Sts_Type I2C_TransferEndStatus(I2C_ID_Type i2cNo) {
return ((BL_IS_REG_BIT_SET(tmpVal, I2C_END_INT)) ? SET : RESET); return ((BL_IS_REG_BIT_SET(tmpVal, I2C_END_INT)) ? SET : RESET);
} }
/****************************************************************************/ /** /**
* @brief I2C master write block data * @brief I2C master write block data
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -550,7 +550,7 @@ BL_Err_Type I2C_MasterSendBlocking(I2C_ID_Type i2cNo, I2C_Transfer_Cfg *cfg) {
return SUCCESS; return SUCCESS;
} }
/****************************************************************************/ /** /**
* @brief I2C master read block data * @brief I2C master read block data
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -643,7 +643,7 @@ BL_Err_Type I2C_MasterReceiveBlocking(I2C_ID_Type i2cNo, I2C_Transfer_Cfg *cfg)
return SUCCESS; return SUCCESS;
} }
/****************************************************************************/ /** /**
* @brief Mask/Unmask the I2C interrupt * @brief Mask/Unmask the I2C interrupt
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -783,7 +783,7 @@ void I2C_IntMask(I2C_ID_Type i2cNo, I2C_INT_Type intType, BL_Mask_Type intMask)
BL_WR_REG(I2Cx, I2C_INT_STS, tmpVal); BL_WR_REG(I2Cx, I2C_INT_STS, tmpVal);
} }
/****************************************************************************/ /** /**
* @brief Install I2C interrupt callback function * @brief Install I2C interrupt callback function
* *
* @param i2cNo: I2C ID type * @param i2cNo: I2C ID type
@@ -803,7 +803,7 @@ void I2C_Int_Callback_Install(I2C_ID_Type i2cNo, I2C_INT_Type intType, intCallba
} }
#endif #endif
/****************************************************************************/ /** /**
* @brief I2C IRQ handler * @brief I2C IRQ handler
* *
* @param None * @param None

View File

@@ -361,13 +361,17 @@ void OLED::setRotation(bool leftHanded) {
OLED_Setup_Array[9].val = 0xA0; OLED_Setup_Array[9].val = 0xA0;
} }
I2C_CLASS::writeRegistersBulk(DEVICEADDR_OLED, OLED_Setup_Array, sizeof(OLED_Setup_Array) / sizeof(OLED_Setup_Array[0])); I2C_CLASS::writeRegistersBulk(DEVICEADDR_OLED, OLED_Setup_Array, sizeof(OLED_Setup_Array) / sizeof(OLED_Setup_Array[0]));
osDelay(TICKS_10MS);
inLeftHandedMode = leftHanded; inLeftHandedMode = leftHanded;
screenBuffer[5] = inLeftHandedMode ? 0 : 32; // display is shifted by 32 in left handed screenBuffer[5] = inLeftHandedMode ? 0 : 32; // display is shifted by 32 in left handed
// mode as driver ram is 128 wide // mode as driver ram is 128 wide
screenBuffer[7] = inLeftHandedMode ? 95 : 0x7F; // End address of the ram segment we are writing to (96 wide) screenBuffer[7] = inLeftHandedMode ? 95 : 0x7F; // End address of the ram segment we are writing to (96 wide)
screenBuffer[9] = inLeftHandedMode ? 0xC8 : 0xC0; screenBuffer[9] = inLeftHandedMode ? 0xC8 : 0xC0;
//Force a screen refresh
const int len = FRAMEBUFFER_START + (OLED_WIDTH * 2);
I2C_CLASS::Transmit(DEVICEADDR_OLED, screenBuffer, len);
osDelay(TICKS_10MS);
} }
void OLED::setBrightness(uint8_t contrast) { void OLED::setBrightness(uint8_t contrast) {

View File

@@ -271,8 +271,8 @@ LDSCRIPT=./Core/BSP/Pinecilv2/bl_mcu_sdk/drivers/bl702_driver/bl702_flash.ld
CPUFLAGS= -march=rv32imafc \ CPUFLAGS= -march=rv32imafc \
-mabi=ilp32f \ -mabi=ilp32f \
-mcmodel=medany -fsigned-char -fno-builtin -nostartfiles \ -mcmodel=medany -fsigned-char -fno-builtin -nostartfiles \
-DportasmHANDLE_INTERRUPT=FreeRTOS_Interrupt_Handler -DARCH_RISCV -D__RISCV_FEATURE_MVE=0 -DportUSING_MPU_WRAPPERS=0 -DportasmHANDLE_INTERRUPT=FreeRTOS_Interrupt_Handler -DARCH_RISCV -D__RISCV_FEATURE_MVE=0 -DportUSING_MPU_WRAPPERS=0 -DDBFLB_USE_ROM_DRIVER=1
# -DBFLB_USE_ROM_DRIVER=1
DEV_LDFLAGS=-nostartfiles DEV_LDFLAGS=-nostartfiles
DEV_AFLAGS= DEV_AFLAGS=
DEV_GLOBAL_DEFS= DEV_GLOBAL_DEFS=