Skip to content

Commit

Permalink
Refactored MCU specific offsets to separate module (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
stylesuxx committed Jun 15, 2023
1 parent 0b286d9 commit 38cc961
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 15 deletions.
6 changes: 1 addition & 5 deletions src/BLHeliBootLoad.inc
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,7 @@ pro4:
pro5:
clr C
mov A, DPH ; Check that address is not in bootloader area
IF MCU_TYPE == MCU_BB1 or MCU_TYPE = MCU_BB2
subb A, #1Ch
ELSEIF MCU_TYPE == MCU_BB51
subb A, #0F0h
ENDIF
subb A, #BOOTLOADER_OFFSET
jc ($+5)

inc DPTR ; Increment flash address
Expand Down
7 changes: 2 additions & 5 deletions src/Bluejay.asm
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ IF PWM_FREQ == PWM_24 or PWM_FREQ == PWM_48 or PWM_FREQ == PWM_96
PWM_BITS_H EQU (2 + IS_MCU_48MHZ - PWM_CENTERED - PWM_FREQ)
ENDIF

$include (Modules\McuOffsets.asm)
$include (Modules\Codespace.asm)
$include (Modules\Common.asm)
$include (Modules\Macros.asm)
Expand Down Expand Up @@ -507,11 +508,7 @@ input_high_check:

call beep_enter_bootloader

IF MCU_TYPE == MCU_BB51
ljmp 0F000h ; Jump to bootloader
ELSE
ljmp 1C00h ; Jump to bootloader
ENDIF
ljmp CSEG_BOOT_START ; Jump to bootloader

bootloader_done:
jnb Flag_Had_Signal, setup_dshot ; Check if DShot signal was lost
Expand Down
6 changes: 1 addition & 5 deletions src/Modules/Eeprom.asm
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,7 @@ write_eeprom_byte_from_acc:
mov Temp8, A
clr C
mov A, DPH ; Check that address is not in bootloader area
IF MCU_TYPE == MCU_BB51
subb A, #0F0h
ELSE
subb A, #1Ch
ENDIF
subb A, #BOOTLOADER_OFFSET
jc ($+3)

ret
Expand Down
34 changes: 34 additions & 0 deletions src/Modules/McuOffsets.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
;**** **** **** **** **** **** **** **** **** **** **** **** ****
;
; Bluejay digital ESC firmware for controlling brushless motors in multirotors
;
; Copyleft 2023 Chris Landa
;
; This file is part of Bluejay.
;
; Bluejay is free software: you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation, either version 3 of the License, or
; (at your option) any later version.
;
; Bluejay is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with Bluejay. If not, see <http://www.gnu.org/licenses/>.
;
;**** **** **** **** **** **** **** **** **** **** **** **** ****
;
; MCU Offsets
;
; Offsets for memory space based on MCU
;
;**** **** **** **** **** **** **** **** **** **** **** **** ****

IF MCU_TYPE == MCU_BB51
BOOTLOADER_OFFSET EQU 0F0h
ELSE
BOOTLOADER_OFFSET EQU 1Ch
ENDIF

0 comments on commit 38cc961

Please sign in to comment.