CHG adding additional compiler warnings in Debug mode, corrections
This commit is contained in:
parent
83c3043d2c
commit
c1ec2a61f1
11
.cproject
11
.cproject
@ -27,8 +27,8 @@
|
||||
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.246809598" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
|
||||
<builder buildPath="${workspace_loc:/stm32l4a6zg-blinky}/Debug" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.250331425" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.170688257" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.561012640" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g3" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.2118173975" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" valueType="definedSymbols">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.561012640" name="Debug level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel" useByScannerDiscovery="false" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.debuglevel.value.g3" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols.2118173975" name="Define symbols (-D)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.option.definedsymbols" useByScannerDiscovery="false" valueType="definedSymbols">
|
||||
<listOptionValue builtIn="false" value="DEBUG"/>
|
||||
</option>
|
||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input.1466960261" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.input"/>
|
||||
@ -51,6 +51,11 @@
|
||||
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2"/>
|
||||
<listOptionValue builtIn="false" value="../Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F"/>
|
||||
</option>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.warnings.extra.1133607321" name="Enable extra warning flags (-Wextra)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.warnings.extra" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.warnings.w_switch_default.1564275553" name="Warn when a switch statement does not have a default case (-Wswitch-default)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.warnings.w_switch_default" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.warnings.w_switch_enum.1884288533" name="Warn if switch is used on an enum type and the switch statement lacks case for some enumerations (-Wswitch-enum)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.warnings.w_switch_enum" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.warnings.conversion.730737367" name="Warn for implicit conversions (-Wconversion)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.warnings.conversion" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.warnings.missing_include_dirs.1151168330" name="Warn if a user-supplied include directory does not exist (-Wmissing-include-dirs)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.option.warnings.missing_include_dirs" useByScannerDiscovery="false" value="true" valueType="boolean"/>
|
||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c.650651857" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.compiler.input.c"/>
|
||||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.747400999" name="MCU G++ Compiler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler">
|
||||
@ -58,7 +63,7 @@
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level.1870504915" name="Optimization level" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.cpp.compiler.option.optimization.level" useByScannerDiscovery="false"/>
|
||||
</tool>
|
||||
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.2080247656" name="MCU GCC Linker" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker">
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.1708312028" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" value="${workspace_loc:/${ProjName}/STM32L4A6ZGTX_FLASH.ld}" valueType="string"/>
|
||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script.1708312028" name="Linker Script (-T)" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.option.script" useByScannerDiscovery="false" value="${workspace_loc:/${ProjName}/STM32L4A6ZGTX_FLASH.ld}" valueType="string"/>
|
||||
<inputType id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input.1741193466" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.c.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
|
@ -143,18 +143,16 @@ int main(void)
|
||||
}
|
||||
|
||||
puts("Registers of Device No. 1");
|
||||
char buf[33]; //using uint8_t
|
||||
//char buf[42]; //using uint16_t
|
||||
//char buf[60]; //using uint32_t
|
||||
//for (int i=0; i <= SI5351_FANOUT_ENABLE; i++) {
|
||||
for (int i=0; i <= 255; i++) {
|
||||
char buf[33];
|
||||
|
||||
for (uint8_t i=0; i <= SI5351_FANOUT_ENABLE; i++) {
|
||||
puts(si5351_read_register_debug(instance_si5351[1], buf, sizeof(buf), i));
|
||||
}
|
||||
/*
|
||||
|
||||
status = si5351_program(instance_si5351[1]);
|
||||
printf("Device #1 gets status %d\n", status);
|
||||
printf("Debug:\n%s", si5351_read_debug_msg(instance_si5351[1]));
|
||||
*/
|
||||
|
||||
for (int i=2; i>=0; i--) {
|
||||
si5351_deinit(instance_si5351[i]);
|
||||
}
|
||||
@ -562,9 +560,9 @@ PUTCHAR_PROTOTYPE
|
||||
void StartDefaultTask(void *argument)
|
||||
{
|
||||
/* USER CODE BEGIN 5 */
|
||||
(void) argument; //unused argument
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
for(;;) {
|
||||
// HAL_GPIO_TogglePin(LD1_GPIO_Port, LD1_Pin);
|
||||
HAL_GPIO_WritePin(LD1_GPIO_Port, LD1_Pin, GPIO_PIN_SET);
|
||||
osDelay(1);
|
||||
@ -584,9 +582,9 @@ void StartDefaultTask(void *argument)
|
||||
void start_terminal_task(void *argument)
|
||||
{
|
||||
/* USER CODE BEGIN start_terminal_task */
|
||||
(void)argument;
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
for(;;) {
|
||||
osDelay(1);
|
||||
}
|
||||
/* USER CODE END start_terminal_task */
|
||||
@ -602,21 +600,21 @@ void start_terminal_task(void *argument)
|
||||
void start_id_task(void *argument)
|
||||
{
|
||||
/* USER CODE BEGIN start_id_task */
|
||||
(void)argument; //unused argument
|
||||
//uint8_t tx_buf[80];
|
||||
//int tx_buf_len;
|
||||
/* check if the SI5351 is present */
|
||||
int status = HAL_I2C_IsDeviceReady(&hi2c1, SI5351_I2C_ADDR, 3, 10 /*HAL_MAX_DELAY*/ ); // HAL_MAX_DELAY is blocking, use 10 ms
|
||||
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
for(;;) {
|
||||
printf("\n" PROGRAM_ID "\n");
|
||||
printf(AUTHOR_STRING "\n");
|
||||
if (status == HAL_OK) {
|
||||
if (status == HAL_OK)
|
||||
printf("Si5351 device found.\n");
|
||||
} else {
|
||||
else
|
||||
printf("Error: Could not detect Si5351 device.\n");
|
||||
}
|
||||
|
||||
osDelay(30*60);
|
||||
}
|
||||
/* USER CODE END start_id_task */
|
||||
|
@ -11,13 +11,12 @@
|
||||
******************************************************************************/
|
||||
|
||||
/* Defines for compilation ---------------------------------------------------*/
|
||||
#define DEBUG 1
|
||||
#define OPTIMIZED 1
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include <stdlib.h>
|
||||
// @TODO try to get rid off including the HAL here, using pointer to the specified functions
|
||||
#if DEBUG
|
||||
#ifdef DEBUG
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
@ -70,6 +69,7 @@ static int si5351_error_status_i2c(HAL_StatusTypeDef status) {
|
||||
case HAL_TIMEOUT: return -ETIMEDOUT; break;
|
||||
case HAL_ERROR: return -EIO; break;
|
||||
case HAL_BUSY: return -EBUSY; break;
|
||||
case HAL_OK:
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
@ -250,35 +250,34 @@ int si5351_program(si5351_inst_t inst) {
|
||||
break;
|
||||
|
||||
/* for debugging purpose, read out fanout enable register */
|
||||
#if DEBUG
|
||||
#ifdef DEBUG
|
||||
status = si5351_read(inst, SI5351_FANOUT_ENABLE, &data, 1);
|
||||
if (status)
|
||||
break;
|
||||
cx += snprintf(inst->debug_msg + cx, sizeof(inst->debug_msg) - cx, "(%d) FANOUT_ENABLE 0x%x\n", cx, data);
|
||||
cx += snprintf(inst->debug_msg + cx, sizeof(inst->debug_msg) - cx, "(%d) FANOUT_ENABLE %d\n", cx, data);
|
||||
cx += snprintf(inst->debug_msg + cx, sizeof(inst->debug_msg) - (size_t)cx, "(%d) FANOUT_ENABLE 0x%x\n", cx, data);
|
||||
cx += snprintf(inst->debug_msg + cx, sizeof(inst->debug_msg) - (size_t)cx, "(%d) FANOUT_ENABLE %d\n", cx, data);
|
||||
#endif
|
||||
data = SI5351_CLKIN_FANOUT_EN | SI5351_XO_FANOUT_EN | SI5351_MS_FANOUT_EN; // set them to 1b
|
||||
status = si5351_write(inst, SI5351_FANOUT_ENABLE, &data, 1);
|
||||
if (status)
|
||||
break;
|
||||
#if DEBUG
|
||||
#ifdef DEBUG
|
||||
status = si5351_read(inst, SI5351_FANOUT_ENABLE, &data, 1);
|
||||
if (status)
|
||||
break;
|
||||
cx += snprintf(inst->debug_msg + cx, sizeof(inst->debug_msg) - cx, "(%d) FANOUT_ENABLE 0x%x\n", cx, data);
|
||||
cx += snprintf(inst->debug_msg + cx, sizeof(inst->debug_msg) - cx, "(%d) FANOUT_ENABLE %d\n", cx, data);
|
||||
cx += snprintf(inst->debug_msg + cx, sizeof(inst->debug_msg) - (size_t)cx, "(%d) FANOUT_ENABLE 0x%x\n", cx, data);
|
||||
cx += snprintf(inst->debug_msg + cx, sizeof(inst->debug_msg) - (size_t)cx, "(%d) FANOUT_ENABLE %d\n", cx, data);
|
||||
#endif
|
||||
|
||||
/* Crystal Internal Load Capacitance */
|
||||
|
||||
#if DEBUG
|
||||
#ifdef DEBUG
|
||||
status = si5351_read(inst, SI5351_CRYSTAL_INTERNAL_LOAD_CAPACITANCE, &data, 1);
|
||||
if (status)
|
||||
break;
|
||||
cx += snprintf(inst->debug_msg + cx, sizeof(inst->debug_msg) - cx, "(%d) XTAL int. Load Cap: 0x%x (%dd)\n", cx, data, data);
|
||||
cx += snprintf(inst->debug_msg + cx, sizeof(inst->debug_msg) - (size_t)cx, "(%d) XTAL int. Load Cap: 0x%x (%dd)\n", cx, data, data);
|
||||
#endif
|
||||
|
||||
|
||||
} while(0);
|
||||
|
||||
|
||||
@ -302,7 +301,7 @@ char * si5351_read_debug_msg(si5351_inst_t inst) {
|
||||
* @param n amount of characters to output to
|
||||
* @param value Value to output in binary representation
|
||||
* @param size
|
||||
* @return bytes written
|
||||
* @return bytes written (int)
|
||||
*/
|
||||
int __snprintb(char *buf, size_t n, void *value, size_t size)
|
||||
{
|
||||
@ -312,24 +311,24 @@ int __snprintb(char *buf, size_t n, void *value, size_t size)
|
||||
int cx = 0;
|
||||
|
||||
bits[blen] = '\0';
|
||||
for_endian(size) {
|
||||
for_endian((int)size) {
|
||||
byte = ((uint8_t *) value)[i];
|
||||
memset(bits, '0', blen);
|
||||
for (int j = 0; byte && j < blen; ++j) {
|
||||
for (int j = 0; byte && j < (int)blen; ++j) {
|
||||
if (byte & 0x80)
|
||||
bits[j] = '1';
|
||||
byte <<= 1;
|
||||
}
|
||||
cx += snprintf(buf+cx, n-cx, "%s%s", bits, (last_loop_endian)? "":" ");
|
||||
cx += snprintf(buf + cx, n - (size_t)cx, "%s%s", bits, (last_loop_endian)? "":" ");
|
||||
}
|
||||
return cx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char * si5351_read_register_debug(si5351_inst_t inst, char *buf, size_t bufsize, uint8_t regaddr) {
|
||||
|
||||
uint8_t data;
|
||||
// uint16_t data16;
|
||||
// uint32_t data32;
|
||||
int status;
|
||||
int cx;
|
||||
|
||||
@ -339,12 +338,10 @@ char * si5351_read_register_debug(si5351_inst_t inst, char *buf, size_t bufsize,
|
||||
status = si5351_read(inst, regaddr, &data, 1);
|
||||
if (status)
|
||||
return NULL;
|
||||
// data16 = data;
|
||||
// data32 = data;
|
||||
|
||||
cx = snprintf(buf, bufsize, "R%03u[0x%02x]=%3u[0x%02x][0b", regaddr, regaddr, data, data);
|
||||
cx += snprintb(buf + cx, bufsize - cx, data);
|
||||
// cx += snprintb(buf + cx, bufsize - cx, data32);
|
||||
cx += snprintf(buf + cx, bufsize - cx, "]");
|
||||
cx += snprintb(buf + cx, bufsize - (size_t)cx, data);
|
||||
cx += snprintf(buf + cx, bufsize - (size_t)cx, "]");
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user