Skip to content

Commit

Permalink
Some bugfixes for input ports
Browse files Browse the repository at this point in the history
- New Input is now triggered correctly
  • Loading branch information
CShark committed Apr 7, 2024
1 parent f2fe8ba commit 6367ac4
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 14 deletions.
4 changes: 2 additions & 2 deletions DMX_ArtNet/.settings/language.settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1813661854470843258" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-95116236004912229" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand All @@ -16,7 +16,7 @@
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-1813661854470843258" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<provider class="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" console="false" env-hash="-95116236004912229" id="com.st.stm32cube.ide.mcu.toolchain.armnone.setup.CrossBuiltinSpecsDetector" keep-relative-paths="false" name="MCU ARM GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
<language-scope id="org.eclipse.cdt.core.gcc"/>
<language-scope id="org.eclipse.cdt.core.g++"/>
</provider>
Expand Down
6 changes: 3 additions & 3 deletions DMX_ArtNet/.settings/stm32cubeide.project.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
2F62501ED4689FB349E356AB974DBE57=56508B65047827EBBE781E33AE78746A
8DF89ED150041C4CBC7CB9A9CAA90856=56508B65047827EBBE781E33AE78746A
DC22A860405A8BF2F2C095E5B6529F12=EF3A100160CFFA7ED73461C4A1BA3C26
2F62501ED4689FB349E356AB974DBE57=5E6695455D925FF934C778F179C2DD07
8DF89ED150041C4CBC7CB9A9CAA90856=5E6695455D925FF934C778F179C2DD07
DC22A860405A8BF2F2C095E5B6529F12=6293536FD389645FE341C3DB7ACA1743
eclipse.preferences.version=1
4 changes: 3 additions & 1 deletion DMX_ArtNet/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"cmsis_armclang_ltm.h": "c",
"cmsis_gcc.h": "c",
"config.h": "c",
"platform.h": "c"
"platform.h": "c",
"dmx.h": "c",
"netif.h": "c"
},
"cmake.configureOnOpen": false
}
2 changes: 1 addition & 1 deletion DMX_ArtNet/DMX_ArtNet Debug.launch
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.stlink_txt_serial_number" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlink.watchdog_config" value="none"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkenable_rtos" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\r\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.debug.stlinkrestart_configurations" value="{&quot;fVersion&quot;:1,&quot;fItems&quot;:[{&quot;fDisplayName&quot;:&quot;Reset&quot;,&quot;fIsSuppressible&quot;:false,&quot;fResetAttribute&quot;:&quot;Software system reset&quot;,&quot;fResetStrategies&quot;:[{&quot;fDisplayName&quot;:&quot;Software system reset&quot;,&quot;fLaunchAttribute&quot;:&quot;system_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Hardware reset&quot;,&quot;fLaunchAttribute&quot;:&quot;hardware_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset hardware\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;Core reset&quot;,&quot;fLaunchAttribute&quot;:&quot;core_reset&quot;,&quot;fGdbCommands&quot;:[&quot;monitor reset core\n&quot;],&quot;fCmdOptions&quot;:[&quot;-g&quot;]},{&quot;fDisplayName&quot;:&quot;None&quot;,&quot;fLaunchAttribute&quot;:&quot;no_reset&quot;,&quot;fGdbCommands&quot;:[],&quot;fCmdOptions&quot;:[&quot;-g&quot;]}],&quot;fGdbCommandGroup&quot;:{&quot;name&quot;:&quot;Additional commands&quot;,&quot;commands&quot;:[]},&quot;fStartApplication&quot;:true}]}"/>
<booleanAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.enableRtosProxy" value="false"/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyCustomProperties" value=""/>
<stringAttribute key="com.st.stm32cube.ide.mcu.rtosproxy.rtosProxyDriver" value="threadx"/>
Expand Down
39 changes: 32 additions & 7 deletions DMX_ArtNet/Src/usart.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void USART_UpdateInputEnabled(unsigned char i) {
}
}

void USART_Transmit(USART_PortConfig *port, const unsigned char *buffer, unsigned short length, void (*callback)(USART_PortConfig*)) {
void USART_Transmit(USART_PortConfig *port, const unsigned char *buffer, unsigned short length, void (*callback)(USART_PortConfig *)) {
USART_SetTx(port);
port->RxTxMetadata.Buffer = buffer;
port->RxTxMetadata.Length = length;
Expand Down Expand Up @@ -164,6 +164,13 @@ static void USART_HandleIRQ(USART_PortConfig *port) {
if (port->Usart->ISR & USART_ISR_FE) {
port->Usart->ICR = USART_ICR_FECF;

if (port->RxTxMetadata.Status == USART_RxTxState_Data) {
if (port->RxTxMetadata.Callback != NULL) {
port->RxTxMetadata.Callback(port);
port->RxTxMetadata.Callback = NULL;
}
}

// Break detected, start reception
USART_DisableDma(port);
port->RxTxMetadata.Status = USART_RxTxState_Break;
Expand All @@ -183,12 +190,14 @@ static void USART_HandleIRQ(USART_PortConfig *port) {

USART_RxDma(port, port->RxTxMetadata.Buffer, port->RxTxMetadata.Length);
}
}else if(data == USART_SC_RDM) {

}else{
} else if (data == USART_SC_RDM) {
}
} else if (port->RxTxMetadata.Status == USART_RxTxState_Data) {
if (DMA1->ISR & (DMA_ISR_TCIF1 << port->DmaIFCR_Offset)) {
DMA1->IFCR = DMA_IFCR_CTCIF1 << port->DmaIFCR_Offset;
port->RxTxMetadata.Status = USART_RxTxState_Idle;

if(port->RxTxMetadata.Callback != NULL) {
if (port->RxTxMetadata.Callback != NULL) {
port->RxTxMetadata.Callback(port);
port->RxTxMetadata.Callback = NULL;
}
Expand Down Expand Up @@ -229,7 +238,7 @@ static void USART_SetTx(USART_PortConfig *port) {
// Configure driver & DMA
port->DRPort->BSRR = 1 << port->DRPin;
port->Dma->CPAR = &(port->Usart->TDR);
port->Dma->CCR = DMA_CCR_MINC | DMA_CCR_DIR | DMA_CCR_TCIE;
port->Dma->CCR = DMA_CCR_MINC | DMA_CCR_DIR;
port->DmaMux->CCR = port->DmaMux_TX;

// Set port state
Expand Down Expand Up @@ -310,4 +319,20 @@ void USART3_IRQHandler() {

void UART4_IRQHandler() {
USART_HandleIRQ(&usart_config[2]);
}
}

void DMA1_Channel1_IRQHandler() {
USART_HandleIRQ(&usart_config[0]);
}

void DMA1_Channel2_IRQHandler() {
USART_HandleIRQ(&usart_config[1]);
}

void DMA1_Channel3_IRQHandler() {
USART_HandleIRQ(&usart_config[2]);
}

void DMA1_Channel4_IRQHanlder() {
USART_HandleIRQ(&usart_config[3]);
}

0 comments on commit 6367ac4

Please sign in to comment.