Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup part 2 for 5.14 #11366

Merged
merged 19 commits into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c0032c9
ATHandler::read_int: allow returning 0 successfully
Aug 13, 2019
726eace
Do not fail on trailing data in read_int
Aug 16, 2019
7647b39
TARGET_STM: I2C sequential communication revert PR #3324 to original …
ABOSTM Aug 20, 2019
7dddf64
Add QSPIF test flash config for TARGET_DISCO_L4R9I
LMESTM Aug 22, 2019
ac08592
QSPI test: Add condition to multiple IO read support
LMESTM Aug 22, 2019
4f22a10
Add MX25LM51245G Serial Flash test config file
LMESTM Aug 22, 2019
06dd330
Fix missing offset in TBStore read from flash
Aug 21, 2019
1c29136
MX25LM51245G test config: explicitely remove unsupported commands
LMESTM Aug 23, 2019
8cd00b3
STM32L4: Add OSPI IP support in fallback QSPI mode
jeromecoutant Jul 19, 2019
7910de2
TARGET_STM: Fix I2C sequential communication
ABOSTM Aug 21, 2019
de121a3
Fix I2C issue with test mbed_hal_fpga_ci_test_shield
ABOSTM Aug 26, 2019
b5826fc
Mutex: _count incrementation brought back
Aug 27, 2019
db0d3d2
Updating SDP-K1 PinNames.h file.
malavikasajikumar Aug 27, 2019
cb6efc0
Merge branch 'Mutex_trylock_adding_missing_count_parameter' of git://…
0xc0170 Aug 28, 2019
31b65ad
Merge branch 'master' of git://github.com/malavikasajikumar/mbed-os i…
0xc0170 Aug 28, 2019
104f928
Merge branch 'I2C_SEQUENTIAL_COMMUNICATION_REWORK' of git://github.co…
0xc0170 Aug 28, 2019
206e52c
Merge branch 'pr/tdbstore-missing-offset' of git://github.com/kyle-cy…
0xc0170 Aug 28, 2019
96d9a8f
Merge branch 'MX25LM51245G_QSPI_test_config' of git://github.com/LMES…
0xc0170 Aug 28, 2019
de627da
Merge branch 'read-int-zero' of git://github.com/dextero/mbed-os into…
0xc0170 Aug 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 101 additions & 0 deletions TESTS/mbed_hal/qspi/flash_configs/MX25LM51245G_config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/* mbed Microcontroller Library
* Copyright (c) 2018-2018 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MBED_QSPI_FLASH_MX25LM51245G_H
#define MBED_QSPI_FLASH_MX25LM51245G_H


#define QSPI_FLASH_CHIP_STRING "macronix MX25LM51245G"

// Command for reading status register
#define QSPI_CMD_RDSR 0x05
// Command for reading configuration register
#define QSPI_CMD_RDCR0 0x15
#define QSPI_CMD_RDCR1 0x71
// Command for writing status/configuration register
#define QSPI_CMD_WRSR 0x01
// Command for reading security register
#define QSPI_CMD_RDSCUR 0x2B

// Command for setting Reset Enable
#define QSPI_CMD_RSTEN 0x66
// Command for setting Reset
#define QSPI_CMD_RST 0x99

// Command for setting write enable
#define QSPI_CMD_WREN 0x06
// Command for setting write disable
#define QSPI_CMD_WRDI 0x04

// WRSR operations max time [us] (datasheet max time + 15%)
#define QSPI_WRSR_MAX_TIME 34500 // 30ms
// general wait max time [us]
#define QSPI_WAIT_MAX_TIME 100000 // 100ms


// Commands for writing (page programming)
// Only single/octal mode supported with this memory
// So only single 1-1-1 mode in this QSPI config
#define QSPI_CMD_WRITE_1IO 0x02 // 1-1-1 mode
// write operations max time [us] (datasheet max time + 15%)
#define QSPI_PAGE_PROG_MAX_TIME 11500 // 10ms

#define QSPI_PAGE_SIZE 256 // 256B
#define QSPI_SECTOR_SIZE 4096 // 4kB
#define QSPI_SECTOR_COUNT 2048

// Commands for reading
// Only single/octal mode supported with this memory
// So only single 1-1-1 mode in this QSPI config
#define QSPI_CMD_READ_1IO_FAST 0x0B // 1-1-1 mode
#define QSPI_CMD_READ_1IO 0x03 // 1-1-1 mode

#define QSPI_READ_1IO_DUMMY_CYCLE 0
#define QSPI_READ_FAST_DUMMY_CYCLE 8

// Commands for erasing
#define QSPI_CMD_ERASE_SECTOR 0x20 // 4kB
//#define QSPI_CMD_ERASE_BLOCK_32 // not supported, only ersae block 64
#define QSPI_CMD_ERASE_BLOCK_64 0xD8 // 64kB
#define QSPI_CMD_ERASE_CHIP 0x60 // or 0xC7

// erase operations max time [us] (datasheet max time + 15%)
#define QSPI_ERASE_SECTOR_MAX_TIME 480000 // 400 ms
#define QSPI_ERASE_BLOCK_64_MAX_TIME 2400000 // 2s

// max frequency for basic rw operation (for fast mode)
#define QSPI_COMMON_MAX_FREQUENCY 1000000

#define QSPI_STATUS_REG_SIZE 1 //2 ??
#define QSPI_CONFIG_REG_0_SIZE 1
#define QSPI_CONFIG_REG_1_SIZE 1
#define QSPI_SECURITY_REG_SIZE 1
#define QSPI_MAX_REG_SIZE 2

// status register
#define STATUS_BIT_WIP (1 << 0) // write in progress bit
#define STATUS_BIT_WEL (1 << 1) // write enable latch
#define STATUS_BIT_BP0 (1 << 2) //
#define STATUS_BIT_BP1 (1 << 3) //
#define STATUS_BIT_BP2 (1 << 4) //
#define STATUS_BIT_BP3 (1 << 5) //
//#define STATUS_BIT_QE (1 << 6) // Not supported
//#define STATUS_BIT_SRWD (1 << 7) // Not supported

// configuration register 0
// bit 0, 1, 2, 4, 5, 7 reserved
#define CONFIG0_BIT_TB (1 << 3) // Top/Bottom area protect

#endif // MBED_QSPI_FLASH_MX25LM51245G_H
3 changes: 3 additions & 0 deletions TESTS/mbed_hal/qspi/flash_configs/flash_configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#elif defined(TARGET_DISCO_F769NI)
#include "MX25L51245G_config.h" // MX25L51245G

#elif defined(TARGET_DISCO_L4R9I)
#include "MX25LM51245G_config.h" // MX25LM51245G

#elif defined(TARGET_DISCO_L476VG)
#include "N25Q128A_config.h" // N25Q128A13EF840E
/* See STM32L476 Errata Sheet, it is not possible to use Dual-/Quad-mode for the command phase */
Expand Down
18 changes: 18 additions & 0 deletions TESTS/mbed_hal/qspi/main.cpp

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions TESTS/mbed_hal/qspi/qspi_test_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,19 @@ struct Qspi {


#define READ_1_1_1 MODE_1_1_1, QSPI_CMD_READ_1IO, QSPI_READ_1IO_DUMMY_CYCLE
#ifdef QSPI_CMD_READ_1I2O
#define READ_1_1_2 MODE_1_1_2, QSPI_CMD_READ_1I2O, QSPI_READ_1I2O_DUMMY_CYCLE
#endif
#ifdef QSPI_CMD_READ_2IO
#define READ_1_2_2 MODE_1_2_2, QSPI_CMD_READ_2IO, QSPI_READ_2IO_DUMMY_CYCLE
#endif
#ifdef QSPI_CMD_READ_1I4O
#define READ_1_1_4 MODE_1_1_4, QSPI_CMD_READ_1I4O, QSPI_READ_1I4O_DUMMY_CYCLE
#endif
#ifdef QSPI_CMD_READ_4IO
#define READ_1_4_4 MODE_1_4_4, QSPI_CMD_READ_4IO, QSPI_READ_4IO_DUMMY_CYCLE
#endif

#ifdef QSPI_CMD_READ_DPI
#define READ_2_2_2 MODE_2_2_2, QSPI_CMD_READ_DPI, QSPI_READ_2IO_DUMMY_CYCLE
#endif
Expand Down
14 changes: 13 additions & 1 deletion features/cellular/framework/AT/ATHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,19 @@ int32_t ATHandler::read_int()
return -1;
}

return std::strtol(buff, NULL, 10);
errno = 0;
char *endptr;
long result = std::strtol(buff, &endptr, 10);
if ((result == LONG_MIN || result == LONG_MAX) && errno == ERANGE) {
return -1; // overflow/underflow
}
if (result < 0) {
return -1; // negative values are unsupported
}
if (*buff == '\0') {
return -1; // empty string
}
return (int32_t) result;
}

void ATHandler::set_delimiter(char delimiter)
Expand Down
4 changes: 2 additions & 2 deletions features/cellular/framework/AT/ATHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -416,9 +416,9 @@ class ATHandler {
*/
ssize_t read_hex_string(char *str, size_t size);

/** Reads as string and converts result to integer. Supports only positive integers.
/** Reads as string and converts result to integer. Supports only non-negative integers.
*
* @return the positive integer or -1 in case of error.
* @return the non-negative integer or -1 in case of error.
*/
int32_t read_int();

Expand Down
2 changes: 1 addition & 1 deletion features/storage/kvstore/tdbstore/TDBStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ int TDBStore::do_reserved_data_get(void *reserved_data, size_t reserved_data_buf

while (actual_size) {
uint32_t chunk = std::min(work_buf_size, (uint32_t) actual_size);
ret = read_area(_active_area, offset, chunk, buf);
ret = read_area(_active_area, offset, chunk, buf + offset);
if (ret) {
return ret;
}
Expand Down
1 change: 1 addition & 0 deletions rtos/source/Mutex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ bool Mutex::trylock_for(uint32_t millisec)
{
osStatus status = osMutexAcquire(_id, millisec);
if (status == osOK) {
_count++;
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions targets/TARGET_STM/TARGET_STM32F0/device/stm32f0xx_hal_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -2592,7 +2592,7 @@ HAL_StatusTypeDef HAL_I2C_Master_Sequential_Transmit_IT(I2C_HandleTypeDef *hi2c,
/* Prepare transfer parameters */
hi2c->pBuffPtr = pData;
hi2c->XferCount = Size;
hi2c->XferOptions = (XferOptions & (~I2C_RELOAD_MODE));
hi2c->XferOptions = XferOptions;
hi2c->XferISR = I2C_Master_ISR_IT;

/* If size > MAX_NBYTE_SIZE, use reload mode */
Expand Down Expand Up @@ -2658,7 +2658,7 @@ HAL_StatusTypeDef HAL_I2C_Master_Sequential_Receive_IT(I2C_HandleTypeDef *hi2c,
/* Prepare transfer parameters */
hi2c->pBuffPtr = pData;
hi2c->XferCount = Size;
hi2c->XferOptions = (XferOptions & (~I2C_RELOAD_MODE));
hi2c->XferOptions = XferOptions;
hi2c->XferISR = I2C_Master_ISR_IT;

/* If hi2c->XferCount > MAX_NBYTE_SIZE, use reload mode */
Expand Down
4 changes: 2 additions & 2 deletions targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_hal_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -2592,7 +2592,7 @@ HAL_StatusTypeDef HAL_I2C_Master_Sequential_Transmit_IT(I2C_HandleTypeDef *hi2c,
/* Prepare transfer parameters */
hi2c->pBuffPtr = pData;
hi2c->XferCount = Size;
hi2c->XferOptions = (XferOptions & (~I2C_RELOAD_MODE)); // MBED patch
hi2c->XferOptions = XferOptions;
hi2c->XferISR = I2C_Master_ISR_IT;

/* If size > MAX_NBYTE_SIZE, use reload mode */
Expand Down Expand Up @@ -2666,7 +2666,7 @@ HAL_StatusTypeDef HAL_I2C_Master_Sequential_Receive_IT(I2C_HandleTypeDef *hi2c,
/* Prepare transfer parameters */
hi2c->pBuffPtr = pData;
hi2c->XferCount = Size;
hi2c->XferOptions = (XferOptions & (~I2C_RELOAD_MODE)); // MBED patch
hi2c->XferOptions = XferOptions;
hi2c->XferISR = I2C_Master_ISR_IT;

/* If hi2c->XferCount > MAX_NBYTE_SIZE, use reload mode */
Expand Down
10 changes: 0 additions & 10 deletions targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F413xH/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,6 @@ struct trng_s {
RNG_HandleTypeDef handle;
};

struct qspi_s {
QSPI_HandleTypeDef handle;
PinName io0;
PinName io1;
PinName io2;
PinName io3;
PinName sclk;
PinName ssel;
};

#include "common_objects.h"

#ifdef __cplusplus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,12 @@ typedef enum {
D7 = PG_10,
D8 = PG_11,
D9 = PB_15,
D10 = PA_15,
D11 = PA_7,
D12 = PB_4,
D13 = PB_3,
D14 = PB_7,
D15 = PB_8,
D10 = PA_15, // SPI CS
D11 = PA_7, // SPI MOSI
D12 = PB_4, // SPI MISO
D13 = PB_3, // SPI SCK
D14 = PB_7, // I2C SDA
D15 = PB_8, // I2C SCL

// STDIO for console print
#ifdef MBED_CONF_TARGET_STDIO_UART_TX
Expand All @@ -310,43 +310,35 @@ typedef enum {
LED2 = PK_6, // Orange LED
LED3 = PK_5, // Green LED
LED4 = PK_4,
LED_RED = LED1,
LED_ORANGE = LED2,
LED_GREEN = LED3,
SERIAL_TX = STDIO_UART_TX,
SERIAL_RX = STDIO_UART_RX,
USBTX = STDIO_UART_TX,
USBRX = STDIO_UART_RX,


// Adding these signals for the SDP connector
SDP_SPI_MOSI = PF_9, // SDP Connector for SPI lines
SDP_SPI_MISO = PF_8,
SDP_SPI_MOSI = PF_9, // SDP Connector for SPI lines
SDP_SPI_MISO = PF_8,
SDP_SPI_SCK = PH_6,
SDP_SPI_CS_A = PB_9,
SDP_SPI_CS_B = PC_6,
SDP_SPI_CS_C = PC_7,
SDP_I2C_SDA = PC_9, // SDP Connector I2C lines
SDP_I2C_SDA = PC_9, // SDP Connector I2C lines
SDP_I2C_SCL = PH_7,
SDP_GPIO_0 = PJ_0, // SDP connector GPIO 0-7
SDP_GPIO_0 = PJ_0, // SDP connector GPIO 0-7
SDP_GPIO_1 = PJ_1,
SDP_GPIO_2 = PJ_3,
SDP_GPIO_3 = PJ_4,
SDP_GPIO_4 = PJ_5,
SDP_GPIO_5 = PJ_12,
SDP_GPIO_6 = PJ_13,
SDP_GPIO_7 = PJ_14,
SDP_UART_TX = PD_5, // SDP connector UART
SDP_GPIO_7 = PJ_14,
SDP_UART_TX = PD_5, // SDP connector UART
SDP_UART_RX = PD_6,
SDP_TMR_A = PB_14, // SDP connector TMR A, B & D
SDP_TMR_A = PB_14, // SDP connector TMR A, B & D
SDP_TMR_B = PE_6,
SDP_TMR_D = PC_8,

/**** USB pins ****/
USB_OTG_HS_DM = PB_14,
USB_OTG_HS_DP = PB_15,
USB_OTG_HS_ID = PB_12,
USB_OTG_HS_SOF = PA_4,
/**** USB pins ****/
USB_OTG_HS_ULPI_CK = PA_5,
USB_OTG_HS_ULPI_D0 = PA_3,
USB_OTG_HS_ULPI_D1 = PB_0,
Expand All @@ -356,12 +348,9 @@ typedef enum {
USB_OTG_HS_ULPI_D5 = PB_12,
USB_OTG_HS_ULPI_D6 = PB_13,
USB_OTG_HS_ULPI_D7 = PB_5,
USB_OTG_HS_ULPI_DIR = PI_11,
USB_OTG_HS_ULPI_DIR_ALT0 = PC_2,
USB_OTG_HS_ULPI_NXT = PH_4,
USB_OTG_HS_ULPI_NXT_ALT0 = PC_3,
USB_OTG_HS_ULPI_DIR = PC_2,
USB_OTG_HS_ULPI_NXT = PC_3,
USB_OTG_HS_ULPI_STP = PC_0,
USB_OTG_HS_VBUS = PB_13,

/**** OSCILLATOR pins ****/
RCC_OSC32_IN = PC_14,
Expand Down
10 changes: 0 additions & 10 deletions targets/TARGET_STM/TARGET_STM32F4/TARGET_STM32F469xI/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ struct trng_s {
RNG_HandleTypeDef handle;
};

struct qspi_s {
QSPI_HandleTypeDef handle;
PinName io0;
PinName io1;
PinName io2;
PinName io3;
PinName sclk;
PinName ssel;
};

#include "common_objects.h"

#ifdef __cplusplus
Expand Down
17 changes: 17 additions & 0 deletions targets/TARGET_STM/TARGET_STM32F4/common_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,23 @@ struct can_s {
};
#endif

#if DEVICE_QSPI
struct qspi_s {
#if defined(OCTOSPI1)
OSPI_HandleTypeDef handle;
#else
QSPI_HandleTypeDef handle;
#endif
QSPIName qspi;
PinName io0;
PinName io1;
PinName io2;
PinName io3;
PinName sclk;
PinName ssel;
};
#endif

#ifdef __cplusplus
}
#endif
Expand Down
10 changes: 0 additions & 10 deletions targets/TARGET_STM/TARGET_STM32F7/TARGET_STM32F746xG/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ struct trng_s {
RNG_HandleTypeDef handle;
};

struct qspi_s {
QSPI_HandleTypeDef handle;
PinName io0;
PinName io1;
PinName io2;
PinName io3;
PinName sclk;
PinName ssel;
};

#include "common_objects.h"

#ifdef __cplusplus
Expand Down
10 changes: 0 additions & 10 deletions targets/TARGET_STM/TARGET_STM32F7/TARGET_STM32F756xG/objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ struct trng_s {
RNG_HandleTypeDef handle;
};

struct qspi_s {
QSPI_HandleTypeDef handle;
PinName io0;
PinName io1;
PinName io2;
PinName io3;
PinName sclk;
PinName ssel;
};

#include "common_objects.h"

#ifdef __cplusplus
Expand Down
Loading