From 85a6097b8576ec0bbdb2f3d9e6686e38ee6d091b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lefaure?= Date: Thu, 22 Oct 2026 16:59:44 +0200 Subject: [PATCH 1/3] firmware: Add robot tests to be executed with Renode --- firmware/RAMNV1/Tests/RAMN.resource | 50 +++++ .../RAMNV1/Tests/RAMN_full_test_suite.robot | 210 ++++++++++++++++++ firmware/RAMNV1/Tests/RAMN_smoke_tests.robot | 63 ++++++ firmware/RAMNV1/Tests/ramn_boot_menu.png | Bin 0 -> 2047 bytes firmware/RAMNV1/Tests/ramn_screen_uds.png | Bin 0 -> 2782 bytes 5 files changed, 323 insertions(+) create mode 100644 firmware/RAMNV1/Tests/RAMN.resource create mode 100644 firmware/RAMNV1/Tests/RAMN_full_test_suite.robot create mode 100644 firmware/RAMNV1/Tests/RAMN_smoke_tests.robot create mode 100644 firmware/RAMNV1/Tests/ramn_boot_menu.png create mode 100644 firmware/RAMNV1/Tests/ramn_screen_uds.png diff --git a/firmware/RAMNV1/Tests/RAMN.resource b/firmware/RAMNV1/Tests/RAMN.resource new file mode 100644 index 00000000..601caaf6 --- /dev/null +++ b/firmware/RAMNV1/Tests/RAMN.resource @@ -0,0 +1,50 @@ +*** Settings *** +Documentation Keywords and variables used by RAMN robot tests. + + +*** Variables *** +${LED_HOLDING_TIMEOUT} 2 + +&{UDS_RX_ID} ECUA=0x7e0 ECUB=0x7e1 ECUC=0x7e2 ECUD=0x7e3 +${UDS_TX_ID_OFFSET} 8 +${UDS_SESSION_CONTROL} 0x10 +${UDS_TESTER_PRESENT} 0x3e +${POSITIVE_RESPONSE_OFFSET} 0x40 + + +*** Keywords *** +RAMN Suite Setup + [Documentation] Display warnings if default firmware are used and setup Renode. + + FOR ${ECU} IN ECUA ECUB ECUC ECUD + TRY + Log Using ELF file ${${ECU}_ELF} for ${ECU} + EXCEPT Variable * not found.* type=GLOB + Log Using default ${ECU} from Renode script. level=WARN + END + END + Renode Suite Setup + +RAMN Test Setup + [Documentation] Prepare Renode with RAMN firmwares. + + Renode Test Setup + + # Using ramn.resc from Renode, that uses bin_ECU{A,B,C,D} variables to load ELF files. + FOR ${ECU} IN ECUA ECUB ECUC ECUD + TRY + Execute Command $global.bin_${ECU} = @${${ECU}_ELF} + EXCEPT Variable * not found.* type=GLOB + Log Using default ${ECU} from Renode script. level=TRACE + END + END + Execute Command include @scripts/multi-node/ramn.resc + +Prepare RAMN With Frame Buffer Tester + [Documentation] Prepare the frame buffer tester and emulation for display tests + [Arguments] ${fb_tester_name} + + # As RAMN firmware is randomly choosing a theme, the seed must be set to have reproducible tests + Execute Command emulation SetSeed 0 + Execute Command emulation CreateFrameBufferTester "${fb_tester_name}" 10 + Execute Command ${fb_tester_name} AttachTo sysbus.spi2.screen machine=ECUA diff --git a/firmware/RAMNV1/Tests/RAMN_full_test_suite.robot b/firmware/RAMNV1/Tests/RAMN_full_test_suite.robot new file mode 100644 index 00000000..5f2b430e --- /dev/null +++ b/firmware/RAMNV1/Tests/RAMN_full_test_suite.robot @@ -0,0 +1,210 @@ +*** Settings *** +Documentation Full test suite using Renode for RAMN firmwares. +Resource RAMN.resource +Test Setup RAMN Test Setup +Suite Setup RAMN Suite Setup + + +*** Variables *** +# Cortex-M33 thumb shellcode: write 0xDEADBEEF to 0x20000000 and return. +# This is plain machine code, reproduce it from source with: +# +# cat > sc.s <<'EOF' +# .syntax unified +# .thumb +# .thumb_func +# _start: +# movw r0, #0xBEEF +# movt r0, #0xDEAD @ r0 = 0xDEADBEEF +# movw r1, #0x0000 +# movt r1, #0x2000 @ r1 = 0x20000000 +# str r0, [r1] @ *0x20000000 = 0xDEADBEEF +# bx lr @ return to the UDS handler +# EOF +# arm-none-eabi-as -mcpu=cortex-m33 -mthumb sc.s -o sc.o +# arm-none-eabi-objcopy -O binary sc.o sc.bin +# xxd -p sc.bin +${UDS_SHELLCODE} 4BF6EF60CDF6AD6040F20001C2F2000108607047 + + +*** Test Cases *** +Should Provide Started Platform + [Documentation] Boot the 4-ECU platforms and run the emulation to skip startup sequence. + + Execute Command emulation RunFor "5s" + Provides post-startup + +ECUA Should Display Actuators Changes + [Documentation] Test that ECU{C,B,D} communicate to ECUA over CAN and that new actuator values are + ... reflected on screen. + + Prepare RAMN With Frame Buffer Tester fb_tester + + # Arbitrary sequence of commands executed before saving the reference frame + Execute Command adc1.engineKey CurrentState "middle" machine=ECUD + Execute Command adc1.parkingBrake CurrentState "on" machine=ECUB + Execute Command adc1.wheel Percentage 50 machine=ECUB + Execute Command adc1.lightingSwitch CurrentState "pos4" machine=ECUB + Execute Command adc1.brake Percentage 33 machine=ECUC + Execute Command adc1.accel Percentage 100 machine=ECUC + Execute Command adc1.joystick CurrentState "left" machine=ECUC + + Execute Command fb_tester WaitForFrame @${CURDIR}/ramn_screen_uds.png + +ECUs Should Respond To Tester Present UDS Command + # 0x3E Tester Present: keep-alive used to stop a diagnostic session from timing out + Restore Started Platform + FOR ${ECU} IN ECUA ECUB ECUC ECUD + # Sub-function 0x00 requests a positive response (0x80 would suppress it) + ${response}= Send UDS Command To ECU ${ECU} 0x3E 00 + Should Be Equal ${response} 7E00 + END + +ECUs Should Respond To Diagnostic Session Control UDS Command + # 0x10 Diagnostic Session Control: switch the ECU into a diagnostic session that unlocks further services + # Session type 0x04 (safety system) is skipped - it requires additional setup + FOR ${ECU} IN ECUA ECUB ECUC ECUD + # Switching the session is a state change, so restore a clean platform per ECU + Restore Started Platform + # 0x01 default, 0x02 programming, 0x03 extended; the response echoes the session type + FOR ${session} IN 01 02 03 + ${response}= Send UDS Command To ECU ${ECU} 0x10 ${session} + Should Start With ${response} 50${session} + END + END + +ECUs Should Respond To ECU Reset UDS Command + # 0x11 ECU Reset + FOR ${ECU} IN ECUA ECUB ECUC ECUD + # Reset mutates ECU state, so restore test to a clean state per ECU under test + Restore Started Platform + # Sub-function 0x01 = hard reset + ${response}= Send UDS Command To ECU ${ECU} 0x11 01 session=02 + Should Start With ${response} 5101 + END + +ECUs Should Respond To Read Data By Identifier UDS Command + # 0x22 Read Data By Identifier: read one 16-bit DID per request + Restore Started Platform + FOR ${ECU} IN ECUA ECUB ECUC ECUD + # DID 0xF184 = firmware compile-time string; response echoes 62 + the DID + the data + ${response}= Send UDS Command To ECU ${ECU} 0x22 F184 + Should Start With ${response} 62F184 + END + +ECUs Should Respond To Read Memory By Address UDS Command + # 0x23 Read Memory By Address: read arbitrary ECU memory + Restore Started Platform + FOR ${ECU} IN ECUA ECUB ECUC ECUD + # data[1]=0x14: high nibble 1 = 1-byte length field, low nibble 4 = 32-bit address; + # read 4 bytes from flash base 0x08000000 + ${response}= Send UDS Command To ECU ${ECU} 0x23 140800000004 session=02 + + # Verify the read-out bytes match what Renode reads straight off that ECU's bus. Both + # Read Memory By Address and ReadBytes return bytes in ascending-address order, so the + # UDS payload (response without its 0x63 service byte) must equal the bus bytes + Execute Command mach set "${ECU}" + ${bus_bytes}= Execute Command sysbus ReadBytes 0x08000000 4 + ${expected}= Evaluate "63" + "".join("%02X" % b for b in ${bus_bytes}) + Should Be Equal ${response} ${expected} + END + +ECUs Should Respond To Control DTC Settings UDS Command + # 0x85 Control DTC Settings: temporarily enable/disable DTC storage + FOR ${ECU} IN ECUA ECUB ECUC ECUD + # Mutates global platform state, restore clean state per ECU + Restore Started Platform + # 0x01 = on (0x02 = off) + ${response}= Send UDS Command To ECU ${ECU} 0x85 01 + Should Start With ${response} C501 + END + +ECUs Should Respond To Link Control UDS Command + # 0x87 Link Control: stage/apply a CAN baudrate change + FOR ${ECU} IN ECUA ECUB ECUC ECUD + # Mutates global platform state, restore clean state per ECU + Restore Started Platform + # 0x01 verifyBaudrateTransitionWithFixedBaudrate, 0x12 = 500000 + ${response}= Send UDS Command To ECU ${ECU} 0x87 0112 + Should Start With ${response} C701 + END + +ECUs Should Respond To Routine Control UDS Command + # 0x31 Routine Control: start (sub-function 0x01) a routine by 16-bit ID. + Restore Started Platform + FOR ${ECU} IN ECUA ECUB ECUC ECUD + # Routine 0x0203 = "echo message": no security access required; no side-effects; response echoes 71 01 0203 + ${response}= Send UDS Command To ECU ${ECU} 0x31 010203 + Should Start With ${response} 71010203 + END + +ECUs Should Grant Security Access UDS Command + # 0x27 Security Access: challenge-response unlock + FOR ${ECU} IN ECUA ECUB ECUC ECUD + # Unlocking changes ECU security state, so restore a clean platform per ECU + Restore Started Platform + Grant Security Access To ECU ${ECU} + END + +ECUA Should Accept Display Pixels Custom UDS Command + # Custom service 0x41: draw pixels on the ECU screen + Restore Started Platform + # 2x2 RGB565 rectangle at (0,0); 2*2*2 = 8 pixel bytes + Send UDS Command To ECU ECUA 0x41 000002020000000000000000 + +ECUA Should Execute Shellcode Via Routine Control UDS Command + # 0x31 Routine Control routine 0x0209: execute caller-supplied ARM code + Restore Started Platform + Grant Security Access To ECU ECUA + + ${send_id}= Evaluate ${UDS_RX_ID}[ECUA] + ${recv_id}= Evaluate ${UDS_RX_ID}[ECUA] + ${UDS_TX_ID_OFFSET} + + # Run the shellcode (0x0209) + Send UDS Command And Wait For Positive Response ${send_id} ${recv_id} 0x31 010209${UDS_SHELLCODE} timeout=2 + + # Read those 4 bytes back via Read Memory By Address; RAM is little-endian, so 0xDEADBEEF + # reads back as EF BE AD DE -> a full response of 63 EF BE AD DE proves the code executed + Send ISOTP Message ${send_id} ${recv_id} 23142000000004 + ${mem_hex}= Wait For ISOTP Message Hex ${send_id} ${recv_id} timeout=1 + Should Be Equal ${mem_hex} 63EFBEADDE + + +*** Keywords *** +Restore Started Platform + Requires post-startup + Create CAN Tester canHub 1 + +Send UDS Command To ECU + [Arguments] ${ECU} ${service} ${data} ${session}=01 + ${send_id}= Evaluate ${UDS_RX_ID}[${ECU}] + ${recv_id}= Evaluate ${send_id} + ${UDS_TX_ID_OFFSET} + + IF $session != "01" + # Command needs to switch session type first + Send UDS Command And Wait For Positive Response ${send_id} ${recv_id} + ... ${UDS_SESSION_CONTROL} ${session} timeout=1 + END + + ${response}= Send UDS Command And Wait For Positive Response ${send_id} ${recv_id} + ... ${service} ${data} timeout=1 + RETURN ${response} + +Grant Security Access To ECU + [Arguments] ${ECU} + ${send_id}= Evaluate ${UDS_RX_ID}[${ECU}] + ${recv_id}= Evaluate ${send_id} + ${UDS_TX_ID_OFFSET} + + # Security access is only meaningful in a non-default session + Send UDS Command And Wait For Positive Response ${send_id} ${recv_id} ${UDS_SESSION_CONTROL} 02 timeout=1 + + # Request the seed, ECU responds with "6701" + 4 seed bytes + Send ISOTP Message ${send_id} ${recv_id} 2701 + ${seed_hex}= Wait For ISOTP Message Hex ${send_id} ${recv_id} timeout=1 + Should Start With ${seed_hex} 6701 + + # In the current RAMN ECUn binaries key = xor(seed,0x12345678) - see `RAMN_UDS_RequestSeed` and `RAMN_UDS_TryKey` + ${key}= Evaluate "2702%08X" % (int($seed_hex[4:12], 16) ^ 0x12345678) + Send ISOTP Message ${send_id} ${recv_id} ${key} + ${resp_hex}= Wait For ISOTP Message Hex ${send_id} ${recv_id} timeout=1 + Should Start With ${resp_hex} 6702 diff --git a/firmware/RAMNV1/Tests/RAMN_smoke_tests.robot b/firmware/RAMNV1/Tests/RAMN_smoke_tests.robot new file mode 100644 index 00000000..e3e3617a --- /dev/null +++ b/firmware/RAMNV1/Tests/RAMN_smoke_tests.robot @@ -0,0 +1,63 @@ +*** Settings *** +Documentation Smoke tests using Renode for RAMN firmwares. +Resource RAMN.resource +Test Setup RAMN Test Setup +Suite Setup RAMN Suite Setup + + +*** Test Cases *** +Should Produce CAN Traffic + [Documentation] Using Renode's log tester to ensure that ECUB, ECUC and ECUD are producing + ... CAN messages. + + Create Log Tester timeout=1 + Execute Command logLevel 0 canHub + + FOR ${ECU} IN ECUB ECUC ECUD + Wait For Log Entry canHub: Received from ${ECU} + END + +ECUA Should Display Boot Menu + [Documentation] Using Renode's frame buffer tester to ensure that boot menu is displayed + + Prepare RAMN With Frame Buffer Tester fb_tester + Execute Command fb_tester WaitForFrame @${CURDIR}/ramn_boot_menu.png + +Should Provide Started Platform + [Documentation] Boot the 4-ECU platforms and run the emulation to skip startup sequence + + Execute Command emulation RunFor "5s" + Provides post-startup + +Brake Should Affect Brake LED + [Documentation] Using Renode's LED tester to validate the data path ECUC's ADC --> ECUC's + ... CAN --> ECUD's CAN --> ECUD's SPI. + + Requires post-startup + + Create LED Tester sysbus.spi2.ledController.parkingBrake machine=ECUD + Execute Command adc1.brake SetPercentage 0 machine=ECUC + Execute Command adc1.parkingBrake CurrentState "off" machine=ECUB + + Assert And Hold Led State false timeoutAssert=0 timeoutHold=${LED_HOLDING_TIMEOUT} + Execute Command adc1.brake SetPercentage 80 machine=ECUC + Assert And Hold Led State true timeoutAssert=1 timeoutHold=${LED_HOLDING_TIMEOUT} + +ECUs Should Respond To Tester Present UDS Command + [Documentation] Using Renode's CAN Tester to test UDS reception + + ${TESTER_PRESENT_DATA} = Set Variable 00 + ${TESTER_PRESENT_RESP} = Evaluate ${UDS_TESTER_PRESENT} + ${POSITIVE_RESPONSE_OFFSET} + ${EXPECTED_RESP} = Convert To Hex ${TESTER_PRESENT_RESP} + + Requires post-startup + Create CAN Tester canHub 1 + + FOR ${ECU} IN ECUA ECUB ECUC ECUD + ${send_id} = Evaluate ${UDS_RX_ID}[${ECU}] + ${recv_id} = Evaluate ${send_id} + ${UDS_TX_ID_OFFSET} + ${response} = Send UDS Command And Wait For Positive Response ${send_id} + ... ${recv_id} service=${UDS_TESTER_PRESENT} data=${TESTER_PRESENT_DATA} + + Should Be Equal ${response} ${EXPECTED_RESP}${TESTER_PRESENT_DATA} + END diff --git a/firmware/RAMNV1/Tests/ramn_boot_menu.png b/firmware/RAMNV1/Tests/ramn_boot_menu.png new file mode 100644 index 0000000000000000000000000000000000000000..751cf74b715f7bd891dece5afb5ae0dba263cbf7 GIT binary patch literal 2047 zcmdT_`BM^j6vv}Dzj38HnFT+wY7u-McvjlQOpYuj%?Djwt{Ly zEEO}4GEzL^P%g_g3ldTj6bZB)!~^lbAVO_v_Lu&Ho!-p%y&v9p-ur&vd_JFd`B+%6 zi_qy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00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lefaure?= Date: Thu, 22 Oct 2026 16:59:44 +0200 Subject: [PATCH 2/3] ci: Add tests GitHub action --- .github/workflows/build_all.yml | 42 +++++++++++++++++++ .github/workflows/tests.yml | 45 +++++++++++++++++++++ scripts/build/docker_BUILD_Clean_Release.sh | 4 ++ 3 files changed, 91 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/build_all.yml b/.github/workflows/build_all.yml index d933297e..e662b9d6 100644 --- a/.github/workflows/build_all.yml +++ b/.github/workflows/build_all.yml @@ -132,6 +132,13 @@ jobs: name: firmware-default-${{ matrix.conf }}-${{ matrix.cubeide_docker_tag }} path: scripts/firmware/*.hex + - name: Upload ELF + if: ${{ matrix.conf == 'Release' && matrix.cubeide_docker_tag == '2.1.1' }} + uses: actions/upload-artifact@v4 + with: + name: firmware-elf-${{ matrix.conf }}-${{ matrix.cubeide_docker_tag }} + path: scripts/firmware/*.elf + macro_coverage: name: ${{ matrix.variant }} needs: [prepare, warm_cache] @@ -463,3 +470,38 @@ jobs: echo "Uploading ${zipfile}..." gh release upload "$RELEASE_TAG" "$zipfile" --clobber --repo "$GH_REPO" done + + smoke_tests: + name: Smoke tests for firmware ${{ matrix.conf }} (tag ${{ matrix.cubeide_docker_tag }}) + needs: [build_all] + runs-on: ubuntu-latest + strategy: + matrix: + conf: [Release] + cubeide_docker_tag: [2.1.1] + steps: + - name: checkout + uses: actions/checkout@v7 + + - name: Download ELF artifacts + uses: actions/download-artifact@v8 + with: + pattern: firmware-elf-Release* + + - name: Run robot test suite on Renode + uses: antmicro/renode-test-action@v5 + with: + tests-to-run: firmware/RAMNV1/Tests/RAMN_smoke_tests.robot + renode-arguments: >- + --variable ECUA_ELF:../ECUA.elf + --variable ECUB_ELF:../ECUB.elf + --variable ECUC_ELF:../ECUC.elf + --variable ECUD_ELF:../ECUD.elf + artifacts-path: tests-results/ + + - name: Upload tests results + if: always() + uses: actions/upload-artifact@v7 + with: + path: tests-results/* + name: smoke-tests-results diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..0c7b76b7 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,45 @@ +name: Tests + +on: + workflow_run: + workflows: ["Build"] + types: [completed] + branches: + - 'main' + +jobs: + run_full_test_suite: + name: Full tests suite for firmware ${{ matrix.conf }} (tag ${{ matrix.cubeide_docker_tag }}) + runs-on: ubuntu-latest + strategy: + matrix: + conf: [Release] + cubeide_docker_tag: [2.1.1] + steps: + - name: checkout + uses: actions/checkout@v7 + + - name: Download ELF artifacts + uses: actions/download-artifact@v8 + with: + pattern: firmware-elf-Release* + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + + - name: Run robot test suite on Renode + uses: antmicro/renode-test-action@v5 + with: + tests-to-run: firmware/RAMNV1/Tests/RAMN_full_test_suite.robot + renode-arguments: >- + --variable ECUA_ELF:../ECUA.elf + --variable ECUB_ELF:../ECUB.elf + --variable ECUC_ELF:../ECUC.elf + --variable ECUD_ELF:../ECUD.elf + artifacts-path: tests-results/ + + - name: Upload tests results + if: always() + uses: actions/upload-artifact@v7 + with: + path: tests-results/* + name: tests-results diff --git a/scripts/build/docker_BUILD_Clean_Release.sh b/scripts/build/docker_BUILD_Clean_Release.sh index be268d0d..f046c678 100755 --- a/scripts/build/docker_BUILD_Clean_Release.sh +++ b/scripts/build/docker_BUILD_Clean_Release.sh @@ -10,14 +10,18 @@ if [ -e /workspace ]; then mkdir -p "${OUTPUT_FOLDER}" bash "${SCRIPT_DIR}/_build_ecu.sh" TARGET_ECUA Release "$@" cp -pr "/workspace/firmware/${PROJECT_NAME}/Release/${PROJECT_NAME}.hex" "${OUTPUT_FOLDER}/ECUA.hex" + cp -p "/workspace/firmware/${PROJECT_NAME}/Release/${PROJECT_NAME}.elf" "${OUTPUT_FOLDER}/ECUA.elf" bash "${SCRIPT_DIR}/_build_ecu.sh" TARGET_ECUB Release --skip-import "$@" cp -pr "/workspace/firmware/${PROJECT_NAME}/Release/${PROJECT_NAME}.hex" "${OUTPUT_FOLDER}/ECUB.hex" + cp -p "/workspace/firmware/${PROJECT_NAME}/Release/${PROJECT_NAME}.elf" "${OUTPUT_FOLDER}/ECUB.elf" bash "${SCRIPT_DIR}/_build_ecu.sh" TARGET_ECUB Release --skip-import -D CHASSIS_LINEAR_POTENTIOMETER "$@" cp -pr "/workspace/firmware/${PROJECT_NAME}/Release/${PROJECT_NAME}.hex" "${OUTPUT_FOLDER}/ECUB_LINEAR.hex" bash "${SCRIPT_DIR}/_build_ecu.sh" TARGET_ECUC Release --skip-import "$@" cp -pr "/workspace/firmware/${PROJECT_NAME}/Release/${PROJECT_NAME}.hex" "${OUTPUT_FOLDER}/ECUC.hex" + cp -p "/workspace/firmware/${PROJECT_NAME}/Release/${PROJECT_NAME}.elf" "${OUTPUT_FOLDER}/ECUC.elf" bash "${SCRIPT_DIR}/_build_ecu.sh" TARGET_ECUD Release --skip-import "$@" cp -pr "/workspace/firmware/${PROJECT_NAME}/Release/${PROJECT_NAME}.hex" "${OUTPUT_FOLDER}/ECUD.hex" + cp -p "/workspace/firmware/${PROJECT_NAME}/Release/${PROJECT_NAME}.elf" "${OUTPUT_FOLDER}/ECUD.elf" exit 0 fi From a3e8a944aa707d0141d8626a239e51095716aa1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lefaure?= Date: Thu, 22 Oct 2026 16:58:55 +0200 Subject: [PATCH 3/3] ci: Break SPI to test failure detection --- firmware/RAMNV1/Core/Src/ramn_spi.c | 39 +++-------------------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/firmware/RAMNV1/Core/Src/ramn_spi.c b/firmware/RAMNV1/Core/Src/ramn_spi.c index 74b2ad20..b899c3ad 100644 --- a/firmware/RAMNV1/Core/Src/ramn_spi.c +++ b/firmware/RAMNV1/Core/Src/ramn_spi.c @@ -50,43 +50,17 @@ void HAL_SPI_TxCpltCallback (SPI_HandleTypeDef * hspi) static HAL_StatusTypeDef SPI_WriteData_DMA(const uint8_t *data, uint16_t nbytes) { - HAL_StatusTypeDef result; - - HAL_GPIO_WritePin(LCD_DC_GPIO_Port, LCD_DC_Pin , GPIO_PIN_SET); // 1 for data, 0 for control - HAL_GPIO_WritePin(LCD_nCS_GPIO_Port, LCD_nCS_Pin, GPIO_PIN_RESET); - result = HAL_SPI_Transmit_DMA(hspi, (uint8_t*)data, nbytes); - if (result == HAL_OK) ulTaskNotifyTake(pdTRUE, portMAX_DELAY); - HAL_GPIO_WritePin(LCD_nCS_GPIO_Port, LCD_nCS_Pin, GPIO_PIN_SET); - return result; + return HAL_OK; } static HAL_StatusTypeDef SPI_WriteCommand_DMA(uint8_t cmd) { - HAL_StatusTypeDef result; - - HAL_GPIO_WritePin(LCD_DC_GPIO_Port, LCD_DC_Pin, GPIO_PIN_RESET); - HAL_GPIO_WritePin(LCD_nCS_GPIO_Port, LCD_nCS_Pin, GPIO_PIN_RESET); - result = HAL_SPI_Transmit_DMA(hspi, &cmd, 1); - if (result == HAL_OK) ulTaskNotifyTake( pdTRUE, portMAX_DELAY); - HAL_GPIO_WritePin(LCD_nCS_GPIO_Port, LCD_nCS_Pin, GPIO_PIN_SET); - return result; + return HAL_OK; } static HAL_StatusTypeDef SPI_WriteDataUint32_DMA(uint32_t data) { - HAL_StatusTypeDef result; - uint8_t buf[4]; - - buf[0] = (data>>24)&0xFF; - buf[1] = (data>>16)&0xFF; - buf[2] = (data>>8)&0xFF; - buf[3] = (data)&0xFF; - HAL_GPIO_WritePin(LCD_DC_GPIO_Port, LCD_DC_Pin, GPIO_PIN_SET); - HAL_GPIO_WritePin(LCD_nCS_GPIO_Port, LCD_nCS_Pin, GPIO_PIN_RESET); - result = HAL_SPI_Transmit_DMA(hspi, buf, 4); - if (result == HAL_OK) ulTaskNotifyTake( pdTRUE, portMAX_DELAY); - HAL_GPIO_WritePin(LCD_nCS_GPIO_Port, LCD_nCS_Pin, GPIO_PIN_SET); - return result; + return HAL_OK; } static void SPI_SetAddrWindow(uint16_t x, uint16_t y, uint16_t w, uint16_t h) @@ -344,12 +318,7 @@ void RAMN_SPI_RefreshUint32(uint16_t x, uint16_t y, uint16_t fgColor, uint16_t b // You may consider setting LCD_nCS_Pin permanently high and skip the TaskNotifyTake to avoid waiting. void RAMN_SPI_UpdateLED(uint8_t* pval) { - HAL_StatusTypeDef result; - - HAL_GPIO_WritePin(LCD_nCS_GPIO_Port, LCD_nCS_Pin, GPIO_PIN_RESET); - result = HAL_SPI_Transmit_IT(hspi, pval, 1); - if (result == HAL_OK) ulTaskNotifyTake(pdTRUE, portMAX_DELAY); - HAL_GPIO_WritePin(LCD_nCS_GPIO_Port, LCD_nCS_Pin, GPIO_PIN_SET); + return; } #endif