Skip to content

Commit

Permalink
Clean-up includes in main header files / build files
Browse files Browse the repository at this point in the history
No functional change
- removed not needed includes of processor specific hal drivers
- removed (incorrect) dependency from I2S driver constant for sampling rate
  detection
- moved some inline functions to normal compile mode (-flto takes care of these)
- properly attributed some inline functions in header file as "static inline".
  this is required for unoptimized builds to work.
- fixed bootloader build issue in Eclipse settings
- readded -DUSE_HAL_DRIVERS to makefile as it is necessary for working compile now
  (we use the drivers, so this is not a workaround, but needed).
- an "out-of-tree" build dir has been added to .gitignore. This helps to
run makefile builds without changing the mchf-eclipse dir but still inside
the git repo (which the makefile likes)
  • Loading branch information
db4ple committed Jan 12, 2019
1 parent 6f3a15e commit c3cd0b3
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 192 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
docs/
mchf-eclipse/.settings/org.eclipse.cdt.managedbuilder.core.prefs
.metadata
.metadata
build/
9 changes: 8 additions & 1 deletion mchf-eclipse/.cproject
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/drivers/usb/device/class/composite}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/basesw/mcHF/Middlewares/Third_Party/FatFs/src/drivers}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/src/bootloader}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/hardware/board_configs}&quot;"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.defs.262146266" name="Defined symbols (-D)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
<listOptionValue builtIn="false" value="DEBUG"/>
Expand All @@ -1102,6 +1103,7 @@
<listOptionValue builtIn="false" value="__FPU_PRESENT=1U"/>
<listOptionValue builtIn="false" value="ARM_MATH_CM4"/>
<listOptionValue builtIn="false" value="UI_BRD_MCHF"/>
<listOptionValue builtIn="false" value="RF_BRD_MCHF"/>
</option>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input.1858623994" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.assembler.input"/>
</tool>
Expand All @@ -1118,6 +1120,7 @@
<listOptionValue builtIn="false" value="__FPU_PRESENT=1U"/>
<listOptionValue builtIn="false" value="ARM_MATH_CM4"/>
<listOptionValue builtIn="false" value="UI_BRD_MCHF"/>
<listOptionValue builtIn="false" value="RF_BRD_MCHF"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths.1334759524" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/basesw/mcHF/Inc}&quot;"/>
Expand Down Expand Up @@ -1156,6 +1159,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/drivers/usb/device/class/composite}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/basesw/mcHF/Middlewares/Third_Party/FatFs/src/drivers}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/src/bootloader}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/hardware/board_configs}&quot;"/>
</option>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.1128704163" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
</tool>
Expand All @@ -1172,6 +1176,7 @@
<listOptionValue builtIn="false" value="__FPU_PRESENT=1U"/>
<listOptionValue builtIn="false" value="ARM_MATH_CM4"/>
<listOptionValue builtIn="false" value="UI_BRD_MCHF"/>
<listOptionValue builtIn="false" value="RF_BRD_MCHF"/>
</option>
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.paths.1818837667" name="Include paths (-I)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/basesw/mcHF/Inc}&quot;"/>
Expand Down Expand Up @@ -1210,6 +1215,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/drivers/usb/device/class/composite}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/basesw/mcHF/Middlewares/Third_Party/FatFs/src/drivers}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/src/bootloader}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/hardware/board_configs}&quot;"/>
</option>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.nortti.374629389" name="Do not use RTTI (-fno-rtti)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.nortti" useByScannerDiscovery="true" value="true" valueType="boolean"/>
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.noexceptions.1750643912" name="Do not use exceptions (-fno-exceptions)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.cpp.compiler.noexceptions" useByScannerDiscovery="true" value="true" valueType="boolean"/>
Expand Down Expand Up @@ -1482,6 +1488,7 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/drivers/usb/device/class/composite}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/basesw/mcHF/Middlewares/Third_Party/FatFs/src/drivers}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/src/bootloader}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/mchf-eclipse/hardware/board_configs}&quot;"/>
</option>
<inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.1129764889" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
</tool>
Expand Down Expand Up @@ -3433,7 +3440,7 @@
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="fw-ovi40" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="${cross_rm} -rf" description="OVI40H7 Firmware (STM32H7), requires DebugLibOVI40H7 build to run before." errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser" id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.433341838.1123244320.487780019" name="DebugOVI40H7" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=" parent="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug" postannouncebuildStep="" postbuildStep="${cross_prefix}${cross_objcopy}${cross_suffix} -O binary ${BuildArtifactFileName} ${BuildArtifactFileBaseName}.bin" preannouncebuildStep="" prebuildStep="">
<configuration artifactName="fw-ovi40" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="${cross_rm} -rf" description="OVI40H7 Firmware (STM32H7), requires DebugLibOVI40H7 build to run before." errorParsers="org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser" id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.433341838.1123244320.487780019" name="DebugOVI40H7" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=" parent="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug" postannouncebuildStep="" postbuildStep="${cross_prefix}${cross_objcopy}${cross_suffix} -O binary ${BuildArtifactFileName} ${BuildArtifactFileBaseName}.bin" preannouncebuildStep="" prebuildStep="">
<folderInfo id="ilg.gnuarmeclipse.managedbuild.cross.config.elf.debug.433341838.1123244320.487780019." name="/" resourcePath="">
<toolChain errorParsers="" id="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.debug.1750162806" name="Cross ARM GCC" nonInternalBuilderId="ilg.gnuarmeclipse.managedbuild.cross.builder" superClass="ilg.gnuarmeclipse.managedbuild.cross.toolchain.elf.debug">
<option id="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.1609734234" name="Optimization Level" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level" useByScannerDiscovery="true" value="ilg.gnuarmeclipse.managedbuild.cross.option.optimization.level.debug" valueType="enumerated"/>
Expand Down
2 changes: 1 addition & 1 deletion mchf-eclipse/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ifeq ($(OS),Darwin)
SED = gsed
endif

COMPILEFLAGS := -D_GNU_SOURCE -DTRX_ID=\"$(TRX_ID)\" -DTRX_NAME=\"$(TRX_NAME)\" $(CONFIGFLAGS) \
COMPILEFLAGS := -D_GNU_SOURCE -DTRX_ID=\"$(TRX_ID)\" -DTRX_NAME=\"$(TRX_NAME)\" $(CONFIGFLAGS) -DUSE_HAL_DRIVER \
-ffunction-sections -fdata-sections -flto -Wall -Wuninitialized -Wextra -Wno-unused-parameter -Wno-unused-function -Wno-sign-compare -g3

# identifying of "official builds by DF8OE"
Expand Down
57 changes: 43 additions & 14 deletions mchf-eclipse/basesw/mcHF/Src/stm32f4xx_it.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ extern DMA_HandleTypeDef hdma_spi3_tx;
extern DMA_HandleTypeDef hdma_i2s3_ext_rx;
extern DMA_HandleTypeDef hdma_spi2_tx;

/*
* TODO: Well, we don't want leds in the bootloader fault handlers. We should decide about a general fault debugging concept
* for all platforms
*/

#if !defined(BOOTLOADER_BUILD)
#define GreenLed(a) Board_GreenLed(a)
#define RedLed(a) Board_RedLed(a)
#else
#define GreenLed(a)
#define RedLed(a)
#endif

/******************************************************************************/
/* Cortex-M4 Processor Interruption and Exception Handlers */
/******************************************************************************/
Expand All @@ -59,12 +72,15 @@ void NMI_Handler(void)
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */

/* USER CODE END NonMaskableInt_IRQn 0 */
Board_GreenLed(LED_STATE_OFF);
GreenLed(LED_STATE_OFF);
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */

/* USER CODE END NonMaskableInt_IRQn 1 */
}

// TODO: Factor out and make avail on all platforms
#if !defined(BOOTLOADER_BUILD)

void Debug_WaitShort()
{
for (int i = 20000000;i;i--)
Expand All @@ -80,26 +96,27 @@ void Debug_WaitLong()
Debug_WaitShort();
}
}

void Debug_Blink_Bit(uint32_t what)
{
Board_RedLed(LED_STATE_OFF);
Board_GreenLed(LED_STATE_OFF);
RedLed(LED_STATE_OFF);
GreenLed(LED_STATE_OFF);
Debug_WaitShort();

Board_GreenLed(LED_STATE_ON);
GreenLed(LED_STATE_ON);
if (what)
{
Board_RedLed(LED_STATE_ON);
RedLed(LED_STATE_ON);
}
Debug_WaitShort();
Board_RedLed(LED_STATE_OFF);
Board_GreenLed(LED_STATE_OFF);
RedLed(LED_STATE_OFF);
GreenLed(LED_STATE_OFF);
}
void Debug_Blink_RedLed()
{
Board_RedLed(LED_STATE_ON);
RedLed(LED_STATE_ON);
Debug_WaitShort();
Board_RedLed(LED_STATE_OFF);
RedLed(LED_STATE_OFF);
Debug_WaitShort();
}

Expand All @@ -122,8 +139,8 @@ void Debug_Send_32Bits(uint32_t val)

void Debug_Send_ValueAndId(uint32_t val, int id)
{
Board_RedLed(LED_STATE_OFF);
Board_GreenLed(LED_STATE_OFF);
RedLed(LED_STATE_OFF);
GreenLed(LED_STATE_OFF);
Debug_WaitLong();
Debug_Send_RedBlinks(id);
Debug_WaitLong();
Expand Down Expand Up @@ -195,14 +212,26 @@ void HardFault_Handler(void)

/* USER CODE END HardFault_IRQn 1 */
}
#else
void HardFault_Handler()
{
/* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */
/* USER CODE BEGIN HardFault_IRQn 1 */
while(1)
{
}
/* USER CODE END HardFault_IRQn 1 */
}
#endif

/**
* @brief This function handles Memory management fault.
*/
void MemManage_Handler(void)
{
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
Board_GreenLed(LED_STATE_OFF);
GreenLed(LED_STATE_OFF);
/* USER CODE END MemoryManagement_IRQn 0 */
while (1)
{
Expand Down Expand Up @@ -235,7 +264,7 @@ void BusFault_Handler(void)
void UsageFault_Handler(void)
{
/* USER CODE BEGIN UsageFault_IRQn 0 */
Board_RedLed(LED_STATE_OFF);
RedLed(LED_STATE_OFF);
/* USER CODE END UsageFault_IRQn 0 */
while (1)
{
Expand All @@ -251,7 +280,7 @@ void UsageFault_Handler(void)
void SVC_Handler(void)
{
/* USER CODE BEGIN SVCall_IRQn 0 */
// Board_GreenLed(LED_STATE_OFF);
// GreenLed(LED_STATE_OFF);
/* USER CODE END SVCall_IRQn 0 */
/* USER CODE BEGIN SVCall_IRQn 1 */

Expand Down
25 changes: 18 additions & 7 deletions mchf-eclipse/drivers/audio/codec/codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@
#define W8731_POWER_DOWN_CNTR_MICPD (0x02)
#define W8731_POWER_DOWN_CNTR_LINEPD (0x01)

#define W8731_SAMPLING_CNTR_BOSR (0x0002)

#define W8731_SAMPLING_CNTR_96K (0x0007 << 2)
#define W8731_SAMPLING_CNTR_48K (0x0000 << 2)
#define W8731_SAMPLING_CNTR_32K (0x0006 << 2)
#define W8731_SAMPLING_CNTR_8K (0x0003 << 2)


#define W8731_VOL_MAX 0x50

#define W8731_POWER_DOWN_CNTR_MCHF_ALL_ON (W8731_POWER_DOWN_CNTR_CLKOUTPD|W8731_POWER_DOWN_CNTR_OSCPD)
Expand Down Expand Up @@ -106,7 +114,7 @@ __IO mchf_codec_t mchf_codecs[CODEC_NUM];
#endif

#ifdef UI_BRD_OVI40

#include "dac.h"
/**
* @brief controls volume on "external" PA via DAC
* @param vol volume in range of 0 to CODEC_SPEAKER_MAX_VOLUME
Expand Down Expand Up @@ -208,15 +216,18 @@ static uint32_t Codec_ResetCodec(I2C_HandleTypeDef* hi2c, uint32_t AudioFreq, Co

switch (AudioFreq)
{
case I2S_AUDIOFREQ_32K:
samp_reg_val = 0x0018;
case 32000:
samp_reg_val = W8731_SAMPLING_CNTR_32K;
break;
case 8000:
samp_reg_val = W8731_SAMPLING_CNTR_8K;
break;
case I2S_AUDIOFREQ_8K:
samp_reg_val = 0x000C;
case 96000:
samp_reg_val = W8731_SAMPLING_CNTR_96K;
break;
case I2S_AUDIOFREQ_48K:
case 48000:
default:
samp_reg_val = 0x0000;
samp_reg_val = W8731_SAMPLING_CNTR_48K;
break;
}

Expand Down
1 change: 1 addition & 0 deletions mchf-eclipse/drivers/audio/freedv_uhsdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
************************************************************************************/
#include "uhsdr_board.h"

#include "comp.h"

#define FDV_BUFFER_SIZE 320
#define FDV_RX_AUDIO_SIZE_MAX 360
Expand Down
106 changes: 106 additions & 0 deletions mchf-eclipse/hardware/uhsdr_board.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
// Eeprom items
#include "eeprom.h"
#include "adc.h"
#include "dac.h"

#include "uhsdr_keypad.h"
#include "osc_si5351a.h"
Expand Down Expand Up @@ -721,3 +722,108 @@ const char* Board_BootloaderVersion()
}
return outs;
}

/**
* @brief set PA bias at the LM2931CDG (U18) using DAC Channel 2
*/
void Board_SetPaBiasValue(uint16_t bias)
{
// Set DAC Channel 1 DHR12L register
// DAC_SetChannel2Data(DAC_Align_8b_R,bias);
HAL_DAC_SetValue(&hdac, DAC_CHANNEL_2, DAC_ALIGN_8B_R, bias);

}

void Board_GreenLed(ledstate_t state)
{
switch(state)
{
case LED_STATE_ON:
GPIO_SetBits(GREEN_LED_PIO, GREEN_LED);
break;
case LED_STATE_OFF:
GPIO_ResetBits(GREEN_LED_PIO, GREEN_LED);
break;
default:
GPIO_ToggleBits(GREEN_LED_PIO, GREEN_LED);
break;
}
}

void Board_RedLed(ledstate_t state)
{
switch(state)
{
case LED_STATE_ON:
GPIO_SetBits(RED_LED_PIO, RED_LED);
break;
case LED_STATE_OFF:
GPIO_ResetBits(RED_LED_PIO, RED_LED);
break;
default:
GPIO_ToggleBits(RED_LED_PIO, RED_LED);
break;
}
}

#ifdef UI_BRD_OVI40
void Board_BlueLed(ledstate_t state)
{
switch(state)
{
case LED_STATE_ON:
GPIO_SetBits(BLUE_LED_PIO, BLUE_LED);
break;
case LED_STATE_OFF:
GPIO_ResetBits(BLUE_LED_PIO, BLUE_LED);
break;
default:
GPIO_ToggleBits(BLUE_LED_PIO, BLUE_LED);
break;
}
}
#endif
/**
* @brief sets the hw ptt line and by this switches the mcHF board signal path between rx and tx configuration
* @param tx_enable true == TX Paths, false == RX Paths
*/
void Board_EnableTXSignalPath(bool tx_enable)
{
// to make switching as noiseless as possible, make sure the codec lineout is muted/produces zero output before switching
if (tx_enable)
{
GPIO_SetBits(PTT_CNTR_PIO,PTT_CNTR); // TX on and switch CODEC audio paths
// Antenna Direction Output
// BPF Direction Output (U1,U2)
// PTT Optocoupler LED On (ACC Port) (U6)
// QSD Mixer Output Disable (U15)
// QSE Mixer Output Enable (U17)
// Codec LineIn comes from mcHF LineIn Socket (U3)
// Codec LineOut connected to QSE mixer (IQ Out) (U3a)
}
else
{
GPIO_ResetBits(PTT_CNTR_PIO,PTT_CNTR); // TX off
// Antenna Direction Input
// BPF Direction Input (U1,U2)
// PTT Optocoupler LED Off (ACC Port) (U6)
// QSD Mixer Output Enable (U15)
// QSE Mixer Output Disable (U17)
// Codec LineIn comes from RF Board QSD mixer (IQ In) (U3)
// Codec LineOut disconnected from QSE mixer (IQ Out) (U3a)
}
}

/**
* Is the hardware contact named DAH pressed
*/
bool Board_PttDahLinePressed() {
return !HAL_GPIO_ReadPin(PADDLE_DAH_PIO,PADDLE_DAH);
}

/**
* Is the hardware contact named DIT pressed
*/
bool Board_DitLinePressed() {
return !HAL_GPIO_ReadPin(PADDLE_DIT_PIO,PADDLE_DIT);
}
Loading

0 comments on commit c3cd0b3

Please sign in to comment.