Skip to content

Commit 98143e4

Browse files
authored
Merge pull request #14323 from artokin/update_from_feature_wisun
Bring in MIMXRT1050_EVK changes from feature-wisun branch
2 parents d7aded6 + ad3bb0d commit 98143e4

File tree

9 files changed

+45
-23
lines changed

9 files changed

+45
-23
lines changed

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_IMX/flash_api.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ status_t flexspi_nor_flash_page_program_ram(uint32_t address, const uint32_t *sr
293293
flashXfer.cmdType = kFLEXSPI_Write;
294294
flashXfer.SeqNumber = 2;
295295
flashXfer.seqIndex = HYPERFLASH_CMD_LUT_SEQ_IDX_PAGEPROGRAM;
296-
flashXfer.data = (uint32_t *)(src + offset);
296+
flashXfer.data = (uint32_t *)((uint32_t)src + offset);
297297
flashXfer.dataSize = BOARD_FLASH_PAGE_SIZE;
298298

299299
status = FLEXSPI_TransferBlocking(FLEXSPI, &flashXfer);
@@ -509,7 +509,7 @@ status_t flexspi_nor_flash_page_program_ram(uint32_t address, const uint32_t *sr
509509
flashXfer.cmdType = kFLEXSPI_Write;
510510
flashXfer.SeqNumber = 1;
511511
flashXfer.seqIndex = NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM_QUAD;
512-
flashXfer.data = (uint32_t *)(src + offset);
512+
flashXfer.data = (uint32_t *)((uint32_t)src + offset);
513513
flashXfer.dataSize = BOARD_FLASH_PAGE_SIZE;
514514

515515
status = FLEXSPI_TransferBlocking(FLEXSPI, &flashXfer);

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_IMX/spi_api.c

+11-6
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,21 @@ int spi_master_write(spi_t *obj, int value)
124124
int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
125125
char *rx_buffer, int rx_length, char write_fill) {
126126
int total = (tx_length > rx_length) ? tx_length : rx_length;
127+
int ret;
127128

128129
// Default write is done in each and every call, in future can create HAL API instead
129130
LPSPI_SetDummyData(spi_address[obj->instance], write_fill);
130131

131-
LPSPI_MasterTransferBlocking(spi_address[obj->instance], &(lpspi_transfer_t){
132-
.txData = (uint8_t *)tx_buffer,
133-
.rxData = (uint8_t *)rx_buffer,
134-
.dataSize = total,
135-
.configFlags = kLPSPI_MasterPcs0 | kLPSPI_MasterPcsContinuous | kLPSPI_SlaveByteSwap,
136-
});
132+
do
133+
{
134+
ret = LPSPI_MasterTransferBlocking(spi_address[obj->instance], &(lpspi_transfer_t){
135+
.txData = (uint8_t *)tx_buffer,
136+
.rxData = (uint8_t *)rx_buffer,
137+
.dataSize = total,
138+
.configFlags = kLPSPI_MasterPcs0 | kLPSPI_MasterPcsContinuous | kLPSPI_SlaveByteSwap,
139+
});
140+
141+
} while((ret == kStatus_LPSPI_Busy));
137142

138143
return total;
139144
}

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/PeripheralNames.h

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ typedef enum {
132132
SPI_1 = 1,
133133
SPI_2 = 2,
134134
SPI_3 = 3,
135+
SPI_4 = 4,
135136
} SPIName;
136137

137138
#ifdef __cplusplus

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/PeripheralPins.c

+6
Original file line numberDiff line numberDiff line change
@@ -52,36 +52,42 @@ const PinMap PinMap_I2C_SCL[] = {
5252
/************UART***************/
5353
const PinMap PinMap_UART_TX[] = {
5454
{GPIO_AD_B0_12, UART_1, 2},
55+
{GPIO_AD_B1_06, UART_3, 2},
5556
{NC , NC , 0}
5657
};
5758

5859
const PinMap PinMap_UART_RX[] = {
5960
{GPIO_AD_B0_13, UART_1, 2},
61+
{GPIO_AD_B1_07, UART_3, 2},
6062
{NC , NC , 0}
6163
};
6264

6365
/************SPI***************/
6466
const PinMap PinMap_SPI_SCLK[] = {
6567
{GPIO_SD_B0_00, SPI_1, ((1U << DAISY_REG_VALUE_SHIFT) | (0x4F0 << DAISY_REG_SHIFT) | 4)},
6668
{GPIO_AD_B0_00, SPI_3, ((0U << DAISY_REG_VALUE_SHIFT) | (0x510 << DAISY_REG_SHIFT) | 7)},
69+
{GPIO_B0_03, SPI_4, ((0U << DAISY_REG_VALUE_SHIFT) | (0x520 << DAISY_REG_SHIFT) | 3)},
6770
{NC , NC , 0}
6871
};
6972

7073
const PinMap PinMap_SPI_MOSI[] = {
7174
{GPIO_SD_B0_02, SPI_1, ((1U << DAISY_REG_VALUE_SHIFT) | (0x4F8 << DAISY_REG_SHIFT) | 4)},
7275
{GPIO_AD_B0_01, SPI_3, ((0U << DAISY_REG_VALUE_SHIFT) | (0x518 << DAISY_REG_SHIFT) | 7)},
76+
{GPIO_B0_02, SPI_4, ((0U << DAISY_REG_VALUE_SHIFT) | (0x528 << DAISY_REG_SHIFT) | 3)},
7377
{NC , NC , 0}
7478
};
7579

7680
const PinMap PinMap_SPI_MISO[] = {
7781
{GPIO_SD_B0_03, SPI_1, ((1U << DAISY_REG_VALUE_SHIFT) | (0x4F4 << DAISY_REG_SHIFT) | 4)},
7882
{GPIO_AD_B0_02, SPI_3, ((0U << DAISY_REG_VALUE_SHIFT) | (0x514 << DAISY_REG_SHIFT) | 7)},
83+
{GPIO_B0_01, SPI_4, ((0U << DAISY_REG_VALUE_SHIFT) | (0x524 << DAISY_REG_SHIFT) | 3)},
7984
{NC , NC , 0}
8085
};
8186

8287
const PinMap PinMap_SPI_SSEL[] = {
8388
{GPIO_SD_B0_01, SPI_1, ((0U << DAISY_REG_VALUE_SHIFT) | (0x4EC << DAISY_REG_SHIFT) | 4)},
8489
{GPIO_AD_B0_03, SPI_3, ((0U << DAISY_REG_VALUE_SHIFT) | (0x50C << DAISY_REG_SHIFT) | 7)},
90+
{GPIO_B0_00, SPI_4, ((0U << DAISY_REG_VALUE_SHIFT) | (0x51C << DAISY_REG_SHIFT) | 3)},
8591
{NC , NC , 0}
8692
};
8793

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/flash_defines.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ static uint32_t customLUT[CUSTOM_LUT_LENGTH] = {
227227

228228
/* Erase Sector */
229229
[4 * NOR_CMD_LUT_SEQ_IDX_ERASESECTOR] =
230-
FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0xD7, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 0x18),
230+
FLEXSPI_LUT_SEQ(kFLEXSPI_Command_SDR, kFLEXSPI_1PAD, 0x20, kFLEXSPI_Command_RADDR_SDR, kFLEXSPI_1PAD, 0x18),
231231

232232
/* Page Program - single mode */
233233
[4 * NOR_CMD_LUT_SEQ_IDX_PAGEPROGRAM_SINGLE] =

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/fsl_clock_config.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ called_from_default_init: true
139139
* Variables for BOARD_BootClockRUN configuration
140140
******************************************************************************/
141141
const clock_arm_pll_config_t armPllConfig_BOARD_BootClockRUN = {
142-
.loopDivider = 100, /* PLL loop divider, Fout = Fin * 50 */
142+
.loopDivider = 88, /* PLL loop divider, Fout = Fin * 44 */
143143
.src = 0, /* Bypass clock source, 0 - OSC 24M, 1 - CLK1_P and CLK1_N */
144144
};
145145
const clock_sys_pll_config_t sysPllConfig_BOARD_BootClockRUN = {
@@ -467,5 +467,5 @@ void BOARD_BootClockRUN(void)
467467
/* Set GPT2 High frequency reference clock source. */
468468
IOMUXC_GPR->GPR5 &= ~IOMUXC_GPR_GPR5_VREF_1M_CLK_GPT2_MASK;
469469
/* Set SystemCoreClock variable. */
470-
SystemCoreClock = BOARD_BOOTCLOCKRUN_CORE_CLOCK;
470+
SystemCoreClock = CLOCK_GetCpuClkFreq();
471471
}

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/specific.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ void SwitchSystemClocks(lpm_power_mode_t power_mode)
7575
case LPM_PowerModeLowSpeedRun:
7676
case LPM_PowerModeSysIdle:
7777
CLOCK_SET_DIV(kCLOCK_SemcDiv, 3); // SEMC CLK should not exceed 166MHz
78+
#ifdef HYPERFLASH_BOOT
7879
CLOCK_SET_DIV(kCLOCK_FlexspiDiv, 1); // FLEXSPI in DDR mode
80+
#else
81+
CLOCK_SET_DIV(kCLOCK_FlexspiDiv, 3); // FLEXSPI in SDR mode
82+
#endif
7983
CLOCK_SET_MUX(kCLOCK_FlexspiMux, 2); // FLEXSPI mux to PLL2 PFD2
8084
/* CORE CLK to 132MHz and AHB, IPG, PERCLK to 33MHz */
8185
CLOCK_SET_DIV(kCLOCK_PerclkDiv, 0);
@@ -108,6 +112,7 @@ void SwitchSystemClocks(lpm_power_mode_t power_mode)
108112
/* Enable clock gate of flexspi. */
109113
CCM->CCGR6 |= (CCM_CCGR6_CG5_MASK);
110114

115+
#ifdef HYPERFLASH_BOOT
111116
if ((LPM_PowerModeLowPowerRun == power_mode) || (LPM_PowerModeLPIdle == power_mode))
112117
{
113118
FLEXSPI_INST->DLLCR[0] = FLEXSPI_DLLCR_OVRDEN(1) | FLEXSPI_DLLCR_OVRDVAL(19);
@@ -116,7 +121,8 @@ void SwitchSystemClocks(lpm_power_mode_t power_mode)
116121
{
117122
FLEXSPI_INST->DLLCR[0] = FLEXSPI_DLLCR_DLLEN(1) | FLEXSPI_DLLCR_SLVDLYTARGET(15);
118123
}
119-
124+
#endif
125+
120126
FLEXSPI_INST->MCR0 &= ~FLEXSPI_MCR0_MDIS_MASK;
121127
FLEXSPI_INST->MCR0 |= FLEXSPI_MCR0_SWRESET_MASK;
122128
while (FLEXSPI_INST->MCR0 & FLEXSPI_MCR0_SWRESET_MASK)

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/TARGET_EVK/xip/evkbimxrt1050_sdram_ini_dcd.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ const uint8_t dcd_data[] = {
239239
/* #1.95, command: write_value, address: SEMC_MCR, value: 0x10000004, size: 4 */
240240
0x40, 0x2F, 0x00, 0x00, 0x10, 0x00, 0x00, 0x04,
241241
/* #1.96, command: write_value, address: SEMC_BMCR0, value: 0x30524, size: 4 */
242-
0x40, 0x2F, 0x00, 0x08, 0x00, 0x03, 0x05, 0x24,
242+
0x40, 0x2F, 0x00, 0x08, 0x00, 0x00, 0x00, 0x81,
243243
/* #1.97, command: write_value, address: SEMC_BMCR1, value: 0x6030524, size: 4 */
244-
0x40, 0x2F, 0x00, 0x0C, 0x06, 0x03, 0x05, 0x24,
244+
0x40, 0x2F, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x81,
245245
/* #1.98, command: write_value, address: SEMC_BR0, value: 0x8000001B, size: 4 */
246246
0x40, 0x2F, 0x00, 0x10, 0x80, 0x00, 0x00, 0x1B,
247247
/* #1.99, command: write_value, address: SEMC_BR1, value: 0x8200001B, size: 4 */

targets/TARGET_NXP/TARGET_MCUXpresso_MCUS/TARGET_MIMXRT1050/drivers/fsl_lpspi.c

+13-9
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,9 @@ void LPSPI_MasterGetDefaultConfig(lpspi_master_config_t *masterConfig)
258258
masterConfig->cpha = kLPSPI_ClockPhaseFirstEdge;
259259
masterConfig->direction = kLPSPI_MsbFirst;
260260

261-
masterConfig->pcsToSckDelayInNanoSec = 1000000000 / masterConfig->baudRate * 2;
262-
masterConfig->lastSckToPcsDelayInNanoSec = 1000000000 / masterConfig->baudRate * 2;
263-
masterConfig->betweenTransferDelayInNanoSec = 1000000000 / masterConfig->baudRate * 2;
261+
masterConfig->pcsToSckDelayInNanoSec = 80;
262+
masterConfig->lastSckToPcsDelayInNanoSec = 60;
263+
masterConfig->betweenTransferDelayInNanoSec = 160;
264264

265265
masterConfig->whichPcs = kLPSPI_Pcs0;
266266
masterConfig->pcsActiveHighOrLow = kLPSPI_PcsActiveLow;
@@ -871,14 +871,18 @@ status_t LPSPI_MasterTransferBlocking(LPSPI_Type *base, lpspi_transfer_t *transf
871871
{
872872
}
873873

874-
if (txData)
874+
/* To prevent rxfifo overflow, ensure transmitting and receiving are executed in parallel */
875+
if(((NULL == rxData) || (rxRemainingByteCount - txRemainingByteCount)/bytesEachRead < fifoSize))
875876
{
876-
wordToSend = LPSPI_CombineWriteData(txData, bytesEachWrite, isByteSwap);
877-
txData += bytesEachWrite;
878-
}
877+
if (txData)
878+
{
879+
wordToSend = LPSPI_CombineWriteData(txData, bytesEachWrite, isByteSwap);
880+
txData += bytesEachWrite;
881+
}
879882

880-
LPSPI_WriteData(base, wordToSend);
881-
txRemainingByteCount -= bytesEachWrite;
883+
LPSPI_WriteData(base, wordToSend);
884+
txRemainingByteCount -= bytesEachWrite;
885+
}
882886

883887
/*Check whether there is RX data in RX FIFO . Read out the RX data so that the RX FIFO would not overrun.*/
884888
if (rxData)

0 commit comments

Comments
 (0)