diff --git a/radio/src/gui/horus/bitmaps.cpp b/radio/src/gui/horus/bitmaps.cpp index 3bf6fe79b..ff628a8d8 100644 --- a/radio/src/gui/horus/bitmaps.cpp +++ b/radio/src/gui/horus/bitmaps.cpp @@ -240,31 +240,31 @@ const uint8_t * const LBM_MAINVIEWS_ICONS[] = { * Model selection screen bitmaps */ -const uint8_t LBM_LIBRARY_ICON[] __DMA = { +const uint8_t LBM_LIBRARY_ICON[] = { #include "mask_library.lbm" }; -const uint8_t LBM_LIBRARY_SLOT[] __DMA = { +const uint8_t LBM_LIBRARY_SLOT[] = { #include "mask_library_slot.lbm" }; -const uint8_t LBM_LIBRARY_CURSOR[] __DMA = { +const uint8_t LBM_LIBRARY_CURSOR[] = { #include "mask_library_category_index.lbm" }; -const uint8_t LBM_SCORE0[] __DMA = { +const uint8_t LBM_SCORE0[] = { #include "mask_library_score_0.lbm" }; -const uint8_t LBM_SCORE1[] __DMA = { +const uint8_t LBM_SCORE1[] = { #include "mask_library_score_1.lbm" }; -const uint8_t LBM_STAR0[] __DMA = { +const uint8_t LBM_STAR0[] = { #include "mask_library_star_0.lbm" }; -const uint8_t LBM_STAR1[] __DMA = { +const uint8_t LBM_STAR1[] = { #include "mask_library_star_1.lbm" }; @@ -272,15 +272,15 @@ const uint8_t LBM_STAR1[] __DMA = { * Calibration screen */ -const uint8_t LBM_HORUS[] __DMA = { +const uint8_t LBM_HORUS[] = { #include "alpha_horus.lbm" }; -const uint8_t LBM_STICK_BACKGROUND[] __DMA = { +const uint8_t LBM_STICK_BACKGROUND[] = { #include "alpha_stick_background.lbm" }; -const uint8_t LBM_STICK_POINTER[] __DMA = { +const uint8_t LBM_STICK_POINTER[] = { #include "alpha_stick_pointer.lbm" }; @@ -288,83 +288,83 @@ const uint8_t LBM_STICK_POINTER[] __DMA = { * Other */ -const uint8_t LBM_ASTERISK[] __DMA = { +const uint8_t LBM_ASTERISK[] = { #include "alpha_asterisk.lbm" }; -const uint8_t LBM_POINT[] __DMA = { +const uint8_t LBM_POINT[] = { #include "mask_point.lbm" }; -const uint8_t LBM_CURVE_POINT[] __DMA = { +const uint8_t LBM_CURVE_POINT[] = { #include "mask_cvpoint.lbm" }; -const uint8_t LBM_CURVE_POINT_CENTER[] __DMA = { +const uint8_t LBM_CURVE_POINT_CENTER[] = { #include "mask_cvpoint_center.lbm" }; -const uint8_t LBM_CURVE_COORD_SHADOW[] __DMA = { +const uint8_t LBM_CURVE_COORD_SHADOW[] = { #include "mask_coord_shadow.lbm" }; -const uint8_t LBM_SHUTDOWN[] __DMA = { +const uint8_t LBM_SHUTDOWN[] = { #include "alpha_shutdown.lbm" }; -const uint8_t LBM_SLEEP[] __DMA = { +const uint8_t LBM_SLEEP[] __ALIGNED = { #include "bmp_sleep.lbm" }; -const uint8_t LBM_SHUTDOWN_CIRCLE[] __DMA = { +const uint8_t LBM_SHUTDOWN_CIRCLE[] = { #include "mask_shutdown_circle.lbm" }; -const uint8_t LBM_SLIDER_BAR_LEFT[] __DMA = { +const uint8_t LBM_SLIDER_BAR_LEFT[] __ALIGNED = { #include "bar_left.lbm" }; -const uint8_t LBM_SLIDER_BAR_RIGHT[] __DMA = { +const uint8_t LBM_SLIDER_BAR_RIGHT[] __ALIGNED = { #include "bar_right.lbm" }; -const uint8_t LBM_SLIDER_POINT_OUT[] __DMA = { +const uint8_t LBM_SLIDER_POINT_OUT[] __ALIGNED = { #include "point_out.lbm" }; -const uint8_t LBM_SLIDER_POINT_MID[] __DMA = { +const uint8_t LBM_SLIDER_POINT_MID[] __ALIGNED = { #include "point_mid.lbm" }; -const uint8_t LBM_SLIDER_POINT_IN[] __DMA = { +const uint8_t LBM_SLIDER_POINT_IN[] __ALIGNED = { #include "point_in.lbm" }; -const uint8_t LBM_CARROUSSEL_LEFT[] __DMA = { +const uint8_t LBM_CARROUSSEL_LEFT[] = { #include "mask_carroussel_left.lbm" }; -const uint8_t LBM_CARROUSSEL_RIGHT[] __DMA = { +const uint8_t LBM_CARROUSSEL_RIGHT[] = { #include "mask_carroussel_right.lbm" }; -const uint8_t LBM_BUTTON_ON[] __DMA = { +const uint8_t LBM_BUTTON_ON[] = { #include "alpha_button_on.lbm" }; -const uint8_t LBM_BUTTON_OFF[] __DMA = { +const uint8_t LBM_BUTTON_OFF[] = { #include "alpha_button_off.lbm" }; -const uint8_t LBM_SWIPE_CIRCLE[] __DMA = { +const uint8_t LBM_SWIPE_CIRCLE[] = { #include "mask_swipe_circle.lbm" }; -const uint8_t LBM_SWIPE_LEFT[] __DMA = { +const uint8_t LBM_SWIPE_LEFT[] = { #include "mask_swipe_left.lbm" }; -const uint8_t LBM_SWIPE_RIGHT[] __DMA = { +const uint8_t LBM_SWIPE_RIGHT[] = { #include "mask_swipe_right.lbm" }; diff --git a/radio/src/gui/horus/splash.cpp b/radio/src/gui/horus/splash.cpp index 7804594a9..94164d7b4 100644 --- a/radio/src/gui/horus/splash.cpp +++ b/radio/src/gui/horus/splash.cpp @@ -20,7 +20,7 @@ #include "../../opentx.h" -const uint8_t LBM_SPLASH[] __DMA = { +const uint8_t LBM_SPLASH[] __ALIGNED = { #include "bmp_splash.lbm" }; diff --git a/radio/src/gui/horus/themes/darkblue.cpp b/radio/src/gui/horus/themes/darkblue.cpp index 44caf5ef1..6c4e8e200 100644 --- a/radio/src/gui/horus/themes/darkblue.cpp +++ b/radio/src/gui/horus/themes/darkblue.cpp @@ -20,11 +20,11 @@ #include "opentx.h" -const uint8_t LBM_TOPMENU_BMP_OPENTX[] __DMA = { +const uint8_t LBM_TOPMENU_BMP_OPENTX[] __ALIGNED = { #include "bmp_topmenu_opentx.lbm" }; -const uint8_t LBM_THEME_DARKBLUE[] __DMA = { +const uint8_t LBM_THEME_DARKBLUE[] __ALIGNED = { #include "bmp_darkblue.lbm" }; diff --git a/radio/src/gui/horus/themes/default.cpp b/radio/src/gui/horus/themes/default.cpp index a4bc3c81c..b8bfe45d4 100644 --- a/radio/src/gui/horus/themes/default.cpp +++ b/radio/src/gui/horus/themes/default.cpp @@ -24,11 +24,11 @@ const uint8_t LBM_TOPMENU_MASK_OPENTX[] = { #include "mask_topmenu_opentx.lbm" }; -const uint8_t LBM_MAINVIEW_BACKGROUND[] = { +const uint8_t LBM_MAINVIEW_BACKGROUND[] __ALIGNED = { #include "bmp_background.lbm" }; -const uint8_t LBM_THEME_DEFAULT[] __DMA = { +const uint8_t LBM_THEME_DEFAULT[] __ALIGNED = { #include "bmp_default.lbm" }; diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 15185ada8..ac07c0517 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -203,14 +203,14 @@ #define ROTARY_ENCODER_NAVIGATION #endif +#define __ALIGNED __attribute__((aligned(32))) + #if defined(SIMU) #define __DMA -#elif defined(PCBSKY9X) - #define __DMA __attribute__((aligned(32))) #elif defined(STM32F4) #define __DMA __attribute__((section(".ram"), aligned(32))) #else - #define __DMA __attribute__((aligned(32))) + #define __DMA __ALIGNED #endif #if defined(SIMU) || defined(CPUARM) || GCC_VERSION < 472 diff --git a/radio/src/targets/horus/diskio.cpp b/radio/src/targets/horus/diskio.cpp index 8d44d37b9..e28f04a52 100644 --- a/radio/src/targets/horus/diskio.cpp +++ b/radio/src/targets/horus/diskio.cpp @@ -66,7 +66,7 @@ int ff_del_syncobj (_SYNC_t mutex) /* Inidialize a Drive */ DSTATUS disk_initialize ( - BYTE drv /* Physical drive nmuber (0..) */ + BYTE drv /* Physical drive nmuber (0..) */ ) { DSTATUS stat = 0; @@ -76,8 +76,8 @@ DSTATUS disk_initialize ( { stat |= STA_NOINIT; } - - /*-------------------------- SD Init ----------------------------- */ + + /*-------------------------- SD Init ----------------------------- */ if (SD_Init() != SD_OK) { TRACE("SD_Init() failed"); @@ -87,23 +87,23 @@ DSTATUS disk_initialize ( return(stat); } - +DWORD scratch[BLOCK_SIZE / 4] __DMA; /*-----------------------------------------------------------------------*/ /* Return Disk Status */ DSTATUS disk_status ( - BYTE drv /* Physical drive nmuber (0..) */ + BYTE drv /* Physical drive nmuber (0..) */ ) { DSTATUS stat = 0; - + if (SD_Detect() != SD_PRESENT) stat |= STA_NODISK; // STA_NOTINIT - Subsystem not initailized // STA_PROTECTED - Write protected, MMC/SD switch if available - + return(stat); } @@ -113,28 +113,23 @@ uint32_t sdReadRetries = 0; /* Read Sector(s) */ DRESULT disk_read ( - BYTE drv, /* Physical drive nmuber (0..) */ - BYTE *buff, /* Data buffer to store read data */ - DWORD sector, /* Sector address (LBA) */ - UINT count /* Number of sectors to read (1..255) */ + BYTE drv, /* Physical drive nmuber (0..) */ + BYTE *buff, /* Data buffer to store read data */ + DWORD sector, /* Sector address (LBA) */ + UINT count /* Number of sectors to read (1..255) */ ) { DRESULT res = RES_OK; SD_Error Status; // TRACE("disk_read %d %p %10d %d", drv, buff, sector, count); - + if (SD_Detect() != SD_PRESENT) { TRACE("SD_Detect() != SD_PRESENT"); return RES_NOTRDY; } - if ((DWORD)buff & 3) // DMA Alignment failure, do single up to aligned buffer - { - TRACE("DMA Alignment failure, align buffer"); - - DWORD scratch[BLOCK_SIZE / 4]; // Alignment assured, you'll need a sufficiently big stack - + if ((DWORD)buff < 0x20000000 || (DWORD)buff >= 0x20030000 || ((DWORD)buff & 3)) { while(count--) { res = disk_read(drv, (BYTE *)scratch, sector++, 1); @@ -198,63 +193,58 @@ DRESULT disk_read ( #if _READONLY == 0 DRESULT disk_write ( - BYTE drv, /* Physical drive nmuber (0..) */ - const BYTE *buff, /* Data to be written */ - DWORD sector, /* Sector address (LBA) */ - UINT count /* Number of sectors to write (1..255) */ + BYTE drv, /* Physical drive nmuber (0..) */ + const BYTE *buff, /* Data to be written */ + DWORD sector, /* Sector address (LBA) */ + UINT count /* Number of sectors to write (1..255) */ ) { - SD_Error Status; - DRESULT res = RES_OK; + SD_Error Status; + DRESULT res = RES_OK; - // TRACE("disk_write %d %p %10d %d", drv, buff, sector, count); - - if (SD_Detect() != SD_PRESENT) - return(RES_NOTRDY); + // TRACE("disk_write %d %p %10d %d", drv, buff, sector, count); - if ((DWORD)buff & 3) // DMA Alignment failure, do single up to aligned buffer - { - DWORD scratch[BLOCK_SIZE / 4]; // Alignment assured, you'll need a sufficiently big stack + if (SD_Detect() != SD_PRESENT) + return(RES_NOTRDY); - while(count--) - { - memcpy(scratch, buff, BLOCK_SIZE); + if ((DWORD)buff < 0x20000000 || (DWORD)buff >= 0x20030000 || ((DWORD)buff & 3)) { + while(count--) { + memcpy(scratch, buff, BLOCK_SIZE); - res = disk_write(drv, (BYTE *)scratch, sector++, 1); + res = disk_write(drv, (BYTE *)scratch, sector++, 1); - if (res != RES_OK) - break; + if (res != RES_OK) + break; - buff += BLOCK_SIZE; - } + buff += BLOCK_SIZE; + } + return(res); + } - return(res); - } + if (count == 1) { + Status = SD_WriteBlock((uint8_t *)buff, sector, BLOCK_SIZE); // 4GB Compliant + } + else { + Status = SD_WriteMultiBlocks((uint8_t *)buff, sector, BLOCK_SIZE, count); // 4GB Compliant + } - if (count == 1) { - Status = SD_WriteBlock((uint8_t *)buff, sector, BLOCK_SIZE); // 4GB Compliant - } - else { - Status = SD_WriteMultiBlocks((uint8_t *)buff, sector, BLOCK_SIZE, count); // 4GB Compliant - } + if (Status == SD_OK) + { + SDTransferState State; - if (Status == SD_OK) - { - SDTransferState State; + Status = SD_WaitWriteOperation(); // Check if the Transfer is finished - Status = SD_WaitWriteOperation(); // Check if the Transfer is finished + while((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL) - while((State = SD_GetStatus()) == SD_TRANSFER_BUSY); // BUSY, OK (DONE), ERROR (FAIL) + if ((State == SD_TRANSFER_ERROR) || (Status != SD_OK)) + res = RES_ERROR; + } + else { + res = RES_ERROR; + } - if ((State == SD_TRANSFER_ERROR) || (Status != SD_OK)) - res = RES_ERROR; - } - else { - res = RES_ERROR; - } - - // TRACE("result=%d", res); - return res; + // TRACE("result=%d", res); + return res; } #endif /* _READONLY */ @@ -265,9 +255,9 @@ DRESULT disk_write ( /* Miscellaneous Functions */ DRESULT disk_ioctl ( - BYTE drv, /* Physical drive nmuber (0..) */ - BYTE ctrl, /* Control code */ - void *buff /* Buffer to send/receive control data */ + BYTE drv, /* Physical drive nmuber (0..) */ + BYTE ctrl, /* Control code */ + void *buff /* Buffer to send/receive control data */ ) { DRESULT res;