123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351 |
- #include "nxp/config/Cpu.h"
- #include "nxp/config/canCom1.h"
- #include "nxp/config/pin_mux.h"
- #include "nxp/config/uart_pal1.h"
- #include "nxp/drivers/inc/uart_esci_callback.h"
- #include "MPC5676R_hal.h"
- #define TIMEOUT (200U)
- #include <stdint.h>
- #include <stdbool.h>
- #include <string.h>
- #if 0
- #include "board.h"
- #include "fsl_dcp.h"
- #include "fsl_lpuart.h"
- #include "fsl_snvs_lp.h"
- #include "pin_mux.h"
- #include "system_MPC5676R.h"
- #include "clock_config.h"
- #endif
- #define LED_PORT PTD
- #define LED0 0U
- #define LED1 1U
- #define BTN_PORT PTE
- #define BTN0_PIN 6U
- #define BTN1_PIN 7U
- #define BTN0_EIRQ 8U
- #define BTN1_EIRQ 9U
- #define FLASH_REG FLASH_A.BIUCR.R
- #define FLASH_DATA 0x00016B35
- #define FLASH_REG2 FLASH_A.BIUCR3.R
- #define FLASH_DATA2 0x00020015
- __attribute__ ((weak)) void uart_puts(char * s){
- while(*s){
- putch(*(s++));
- }
- }
- void init_uart(void)
- {
- UART_Init(&uart_pal1_instance, &uart_pal1_Config0);
- }
- void putch(char c)
- {
-
- char local = c;
- uint8_t* mssg = &local;
-
- ESCI_HW_SendCharacter(0, c);
-
-
- }
- char getch(void)
- {
- char mssg;
- while (!ESCI_HW_GetReceiveReadyFlag(0));
- ESCI_HW_ClearReceiveReadyFlag(0);
- UART_ReceiveDataBlocking(&uart_pal1_instance, &mssg, 1,TIMEOUT);
- return mssg;
- }
- void trigger_setup(void)
- {
-
- ;
- }
- void trigger_high(void)
- {
-
- pin_settings_config_t trig_config = {
- .base = SIU,
- .pinPortIdx = 160u,
- .mux = PORT_MUX_AS_GPIO,
- .outputBuffer = PORT_OUTPUT_BUFFER_ENABLED,
- .slewRateCtrl = HALF_STRENGTH_WITH_SLEWRATE_CONTROL,
- .openDrain = PORT_OPEN_DRAIN_DISABLED,
- .hysteresis = PORT_HYSTERESYS_DISABLED,
- .driveSelect = PORT_MINIMUM_DRIVE_STRENGTH,
- .inputBuffer = PORT_INPUT_BUFFER_DISABLED,
- .pullConfig = PORT_INTERNAL_PULL_NOT_ENABLED,
- .initValue = 1u,
- };
- PINS_DRV_Init(1, &trig_config);
- ;
- }
- void trigger_low(void)
- {
- pin_settings_config_t trig_config = {
- .base = SIU,
- .pinPortIdx = 160u,
- .mux = PORT_MUX_AS_GPIO,
- .outputBuffer = PORT_OUTPUT_BUFFER_ENABLED,
- .slewRateCtrl = HALF_STRENGTH_WITH_SLEWRATE_CONTROL,
- .openDrain = PORT_OPEN_DRAIN_DISABLED,
- .hysteresis = PORT_HYSTERESYS_DISABLED,
- .driveSelect = PORT_MINIMUM_DRIVE_STRENGTH,
- .inputBuffer = PORT_INPUT_BUFFER_DISABLED,
- .pullConfig = PORT_INTERNAL_PULL_NOT_ENABLED,
- .initValue = 0u,
- };
-
- PINS_DRV_Init(1, &trig_config);
- ;
- }
- #define EXAMPLE_LED_GPIO BOARD_USER_LED_GPIO
- #define EXAMPLE_LED_GPIO_PIN BOARD_USER_LED_PIN
-
- static void FlashInit(void)
- {
- unsigned int mem_write_code [] =
- {
-
- 0xD0344400,
- 0x7C0006AC,
- 0x44000004
- };
- typedef void (*mem_write_code_ptr_t)(unsigned int, unsigned int);
- #if defined(FLASH_REG)
- #if FLASH_DATA > 0
- (*((mem_write_code_ptr_t)mem_write_code))
-
- (FLASH_DATA,
- (unsigned int)&FLASH_REG);
- #endif
- #endif
- #if defined(FLASH_REG2)
- (*((mem_write_code_ptr_t)mem_write_code))
-
- (FLASH_DATA2,
- (unsigned int)&FLASH_REG2);
- #endif
- }
- static void XbarInit(void)
- {
-
- XBAR.SGPCR0.B.ARB = 1;
- XBAR.SGPCR1.B.ARB = 1;
- XBAR.SGPCR2.B.ARB = 1;
- XBAR.SGPCR3.B.ARB = 1;
- XBAR.SGPCR6.B.ARB = 1;
- XBAR.SGPCR7.B.ARB = 1;
- }
- static void PIT3Init(void)
- {
-
-
- PIT->MCR = 0x00000001;
- PIT->TIMER[3].LDVAL = 18000000 - 1;
-
- PIT->TIMER[3].TFLG = 0x00000001;
-
-
- PIT->TIMER[3].TCTRL = 0x00000003;
- }
- void BoardInit(void)
- {
- PINS_DRV_Init(NUM_OF_CONFIGURED_PINS, g_pin_mux_InitConfigArr);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if (SIU->SYSDIV & (1 << 31)) {
- SIU->SYSDIV &= ~(1 << 31);
- }
- uint32_t sysdiv = SIU->SYSDIV;
-
-
- sysdiv &= ~(0b11 << 12);
- sysdiv |= 0b01 << 12;
-
-
- sysdiv &= ~(0b11 << 2);
- SIU->SYSDIV = sysdiv;
- pin_settings_config_t clkokconfig = {
- .base = SIU,
- .pinPortIdx = 199,
- .mux = PORT_MUX_AS_GPIO,
- .outputBuffer = PORT_OUTPUT_BUFFER_ENABLED,
- .slewRateCtrl = HALF_STRENGTH_WITH_SLEWRATE_CONTROL,
- .openDrain = PORT_OPEN_DRAIN_DISABLED,
- .hysteresis = PORT_HYSTERESYS_DISABLED,
- .driveSelect = PORT_MINIMUM_DRIVE_STRENGTH,
- .inputBuffer = PORT_INPUT_BUFFER_DISABLED,
- .pullConfig = PORT_INTERNAL_PULL_NOT_ENABLED,
- .initValue = 1u,
- };
-
- PINS_DRV_Init(1, &clkokconfig);
-
-
-
-
- }
- volatile uint32_t g_systickCounter;
- volatile bool g_pinSet = false;
- void SysTick_Handler(void)
- {
- if (g_systickCounter != 0U)
- {
- g_systickCounter--;
- }
- }
- void SysTick_DelayTicks(uint32_t n)
- {
- g_systickCounter = n;
- while (g_systickCounter != 0U)
- {
- }
- }
- void platform_init(void)
- {
-
-
- BoardInit();
-
- FLEXCAN_DRV_Init(INST_CANCOM1, &canCom1_State, &canCom1_InitConfig0);
- }
- #define MPC56xx_ID 0x005A0000
- #define VLE_ENABLE 0x01000000
- extern void _start(void);
- #define ENTRY_POINT _start
- #define RCHW_VAL (VLE_ENABLE | MPC56xx_ID)
- const uint32_t __attribute__ ((section(".rchw"))) RCHW[] = {RCHW_VAL, (uint32_t)ENTRY_POINT};
|