123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294 |
- #ifndef HAL_LLD_H
- #define HAL_LLD_H
- #include "registers.h"
- #include "spc5_registry.h"
- #define HAL_IMPLEMENTS_COUNTERS FALSE
- #define PLATFORM_NAME "SPC564Axx Powertrain"
- #define SPC5_RFD_DIV2 0
- #define SPC5_RFD_DIV4 1
- #define SPC5_RFD_DIV8 2
- #define SPC5_RFD_DIV16 3
- #define BIUCR_BANK1_TOO 0x01000000
- #define BIUCR_MASTER7_PREFETCH 0x00800000
- #define BIUCR_MASTER6_PREFETCH 0x00400000
- #define BIUCR_MASTER5_PREFETCH 0x00200000
- #define BIUCR_MASTER4_PREFETCH 0x00100000
- #define BIUCR_MASTER3_PREFETCH 0x00080000
- #define BIUCR_MASTER2_PREFETCH 0x00040000
- #define BIUCR_MASTER1_PREFETCH 0x00020000
- #define BIUCR_MASTER0_PREFETCH 0x00010000
- #define BIUCR_APC_MASK 0x0000E000
- #define BIUCR_APC_0 (0 << 13)
- #define BIUCR_APC_1 (1 << 13)
- #define BIUCR_APC_2 (2 << 13)
- #define BIUCR_APC_3 (3 << 13)
- #define BIUCR_APC_4 (4 << 13)
- #define BIUCR_APC_5 (5 << 13)
- #define BIUCR_APC_6 (6 << 13)
- #define BIUCR_WWSC_MASK 0x00001800
- #define BIUCR_WWSC_0 (0 << 11)
- #define BIUCR_WWSC_1 (1 << 11)
- #define BIUCR_WWSC_2 (2 << 11)
- #define BIUCR_WWSC_3 (3 << 11)
- #define BIUCR_RWSC_MASK 0x00001800
- #define BIUCR_RWSC_0 (0 << 8)
- #define BIUCR_RWSC_1 (1 << 8)
- #define BIUCR_RWSC_2 (2 << 8)
- #define BIUCR_RWSC_3 (3 << 8)
- #define BIUCR_RWSC_4 (4 << 8)
- #define BIUCR_RWSC_5 (5 << 8)
- #define BIUCR_RWSC_6 (6 << 8)
- #define BIUCR_RWSC_7 (7 << 8)
- #define BIUCR_DPFEN 0x00000040
- #define BIUCR_IPFEN 0x00000010
- #define BIUCR_PFLIM_MASK 0x00000060
- #define BIUCR_PFLIM_NO (0 << 1)
- #define BIUCR_PFLIM_ON_MISS (1 << 1)
- #define BIUCR_PFLIM_ON_HITMISS (2 << 1)
- #define BIUCR_BFEN 0x00000001
- #if !defined(SPC5_NO_INIT) || defined(__DOXYGEN__)
- #define SPC5_NO_INIT FALSE
- #endif
- #if !defined(SPC5_CLK_BYPASS) || defined(__DOXYGEN__)
- #define SPC5_CLK_BYPASS FALSE
- #endif
- #if !defined(SPC5_ALLOW_OVERCLOCK) || defined(__DOXYGEN__)
- #define SPC5_ALLOW_OVERCLOCK FALSE
- #endif
- #if !defined(SPC5_CLK_PREDIV_VALUE) || defined(__DOXYGEN__)
- #define SPC5_CLK_PREDIV_VALUE 2
- #endif
- #if !defined(SPC5_CLK_MFD_VALUE) || defined(__DOXYGEN__)
- #define SPC5_CLK_MFD_VALUE 75
- #endif
- #if !defined(SPC5_CLK_RFD) || defined(__DOXYGEN__)
- #define SPC5_CLK_RFD RFD_DIV2
- #endif
- #if !defined(SPC5_FLASH_BIUCR) || defined(__DOXYGEN__)
- #define SPC5_FLASH_BIUCR (BIUCR_BANK1_TOO | \
- BIUCR_MASTER4_PREFETCH | \
- BIUCR_MASTER0_PREFETCH | \
- BIUCR_DPFEN | \
- BIUCR_IPFEN | \
- BIUCR_PFLIM_ON_MISS | \
- BIUCR_BFEN)
- #endif
- #if !defined(SPC5_EMIOS_GPRE_VALUE) || defined(__DOXYGEN__)
- #define SPC5_EMIOS_GPRE_VALUE 20
- #endif
- #if !defined(SPC564Axx_MCUCONF)
- #error "Using a wrong mcuconf.h file, SPC564Axx_MCUCONF not defined"
- #endif
- #if (SPC5_CLK_PREDIV_VALUE < 1) || (SPC5_CLK_PREDIV_VALUE > 15)
- #error "invalid SPC5_CLK_PREDIV_VALUE value specified"
- #endif
- #if (SPC5_CLK_MFD_VALUE < 32) || (SPC5_CLK_MFD_VALUE > 96)
- #error "invalid SPC5_CLK_MFD_VALUE value specified"
- #endif
- #if (SPC5_CLK_RFD != SPC5_RFD_DIV2) && (SPC5_CLK_RFD != SPC5_RFD_DIV4) && \
- (SPC5_CLK_RFD != SPC5_RFD_DIV8) && (SPC5_CLK_RFD != SPC5_RFD_DIV16)
- #error "invalid SPC5_CLK_RFD value specified"
- #endif
- #if (SPC5_EMIOS_GPRE_VALUE < 1) || (SPC5_EMIOS_GPRE_VALUE > 256)
- #error "invalid SPC5_EMIOS_GPRE_VALUE value specified"
- #endif
- #define SPC5_CLK_PREDIV (SPC5_CLK_PREDIV_VALUE - 1)
- #define SPC5_CLK_MFD (SPC5_CLK_MFD_VALUE)
- #define SPC5_PLLCLK ((SPC5_XOSC_CLK / SPC5_CLK_PREDIV_VALUE) * \
- SPC5_CLK_MFD_VALUE)
- #if (SPC5_PLLCLK < 256000000) || (SPC5_PLLCLK > 512000000)
- #error "VCO frequency out of the acceptable range (256...512)"
- #endif
- #if !SPC5_CLK_BYPASS || defined(__DOXYGEN__)
- #define SPC5_SYSCLK (SPC5_PLLCLK / (1 << (SPC5_CLK_RFD + 1)))
- #else
- #define SPC5_SYSCLK SPC5_XOSC_CLK
- #endif
- #if (SPC5_SYSCLK > 150000000) && !SPC5_ALLOW_OVERCLOCK
- #error "System clock above maximum rated frequency (150MHz)"
- #endif
- #if (SPC5_SYSCLK <= 20000000) || defined(__DOXYGEN__)
- #define SPC5_FLASH_WS (BIUCR_APC_0 | BIUCR_RWSC_0 | BIUCR_WWSC_3)
- #elif SPC5_SYSCLK <= 61000000
- #define SPC5_FLASH_WS (BIUCR_APC_1 | BIUCR_RWSC_1 | BIUCR_WWSC_3)
- #elif SPC5_SYSCLK <= 90000000
- #define SPC5_FLASH_WS (BIUCR_APC_2 | BIUCR_RWSC_2 | BIUCR_WWSC_3)
- #elif SPC5_SYSCLK <= 123000000
- #define SPC5_FLASH_WS (BIUCR_APC_3 | BIUCR_RWSC_3 | BIUCR_WWSC_3)
- #else
- #define SPC5_FLASH_WS (BIUCR_APC_4 | BIUCR_RWSC_4 | BIUCR_WWSC_3)
- #endif
- #if (SPC5_SYSCLK <= 98000000) || defined(__DOXYGEN__)
- #define SPC5_RAM_WS 0
- #else
- #define SPC5_RAM_WS 0x40000000
- #endif
- #define SPC5_EMIOS_GPRE (SPC5_EMIOS_GPRE_VALUE << 8)
- #include "spc5_edma.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- void hal_lld_init(void);
- void spc_clock_init(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|