MPC5646C_init_flash.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. *
  3. * FILE : MPC55xx_init.c
  4. *
  5. * DESCRIPTION:
  6. * This file contains the MPC55xx derivative needed initializations.
  7. * usr_init() is called by the startup code of the application at initialization time
  8. * You can add needed hardware initializations here.
  9. * This file also contains the RCHW and Reset Vector setup:
  10. /* The chip is by default setup to boot from internal Flash and the watchdog is disabled.
  11. */
  12. #include "Exceptions.h" /* IVPR and default exception handlers setup */
  13. #include "IntcInterrupts.h" /* INTC Interrupts Requests configuration */
  14. #include "MPC5646C_HWInit.h"
  15. #pragma section code_type ".init"
  16. #define INIT_DERIVATIVE_INTERNAL_SETUP 1
  17. #define INIT_EXTERNAL_BUS_INTERFACE_SETUP 0
  18. #ifndef INIT_DERIVATIVE_INTERNAL_SETUP
  19. #pragma error INIT_DERIVATIVE_INTERNAL_SETUP should be defined !
  20. #endif
  21. #ifndef INIT_EXTERNAL_BUS_INTERFACE_SETUP
  22. #pragma error INIT_EXTERNAL_BUS_INTERFACE_SETUP should be defined !
  23. #endif
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. extern __asm void __startup();
  28. __asm void usr_init();
  29. /*lint -esym(752,__start) */
  30. #ifdef __cplusplus
  31. }
  32. #endif
  33. /*****************************************************************/
  34. /* usr_init(): */
  35. /* Define here the needed hardware initializations at startup */
  36. __asm void usr_init()
  37. {
  38. /* Add needed hardware initializations in this function */
  39. nofralloc
  40. mflr r30 /* Save off return address in NV reg */
  41. #if INIT_DERIVATIVE_INTERNAL_SETUP==1
  42. bl INIT_Derivative /* Derivative specific hardware initializations */
  43. #endif
  44. #if INIT_EXTERNAL_BUS_INTERFACE_SETUP==1
  45. bl INIT_ExternalBusAndMemory /* Set up access to external memory (inc. chip select and MMU) */
  46. #endif
  47. bl EXCEP_InitExceptionHandlers /* Set up Default Exception handling */
  48. bl INTC_InitINTCInterrupts /* Set up INTC Interrupts Requests handling */
  49. mtlr r30 /* Get saved return address */
  50. blr
  51. }
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. /**************************************************************/
  56. /* RCHW and Reset Vector setup: */
  57. /* The chip is by default setup to boot from internal Flash */
  58. /* and the watchdog is disabled. */
  59. typedef void (*resetfuncptr)(void);
  60. #pragma push /* Save the current state */
  61. #pragma section sconst_type ".__bam_bootarea"
  62. extern const unsigned long bam_rchw;
  63. extern const resetfuncptr bam_resetvector;
  64. /* RCHW_VALUE Flags */
  65. #define RCHW_WTE 0x0400L /* Enable Watchdog */
  66. #define RCHW_VLE 0x0100L /* Enable Variable Length Encoding*/
  67. #define RCHW_PS0_32BITS 0x0000L /* Boot from External Bus CS0, 32-bit CS0 port size. */
  68. #define RCHW_PS0_16BITS 0x0200L /* Boot from External Bus CS0, 16-bit CS0 port size. */
  69. #define RCHW_BOOTIDENTIFIER 0x005AL
  70. /* Used RCHW value: boot from internal flash, watchdog disabled */
  71. #if VLE_IS_ON == 1
  72. #define RCHW_VALUE RCHW_BOOTIDENTIFIER|RCHW_PS0_32BITS|RCHW_VLE
  73. #else
  74. #define RCHW_VALUE RCHW_BOOTIDENTIFIER|RCHW_PS0_32BITS
  75. #endif
  76. const unsigned long bam_rchw = (RCHW_VALUE)<<16;
  77. const resetfuncptr bam_resetvector = __startup;
  78. #pragma pop
  79. #ifdef __cplusplus
  80. }
  81. #endif