Skip to content

Pr/cy mbed os 5.12.0 #9908

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

Merged
merged 8 commits into from
Mar 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion TESTS/mbedmicro-rtos-mbed/mail/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using namespace utest::v1;
#define THREAD_STACK_SIZE 512
#elif defined(__ARM_FM)
#define THREAD_STACK_SIZE 512
#elif defined(TARGET_FUTURE_SEQUANA_PSA)
#elif defined(TARGET_FUTURE_SEQUANA_PSA) || defined(TARGET_CY8CKIT_062_WIFI_BT_PSA)
#define THREAD_STACK_SIZE 512
#else
#define THREAD_STACK_SIZE 320 /* larger stack cause out of heap memory on some 16kB RAM boards in multi thread test*/
Expand Down
2 changes: 1 addition & 1 deletion TESTS/mbedmicro-rtos-mbed/malloc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ volatile bool thread_should_continue = true;
#define THREAD_STACK_SIZE 512
#elif defined(__ARM_FM)
#define THREAD_STACK_SIZE 512
#elif defined(TARGET_FUTURE_SEQUANA_PSA)
#elif defined(TARGET_FUTURE_SEQUANA_PSA) || defined(TARGET_CY8CKIT_062_WIFI_BT_PSA)
#define THREAD_STACK_SIZE 512
#else
#define THREAD_STACK_SIZE 256
Expand Down
2 changes: 1 addition & 1 deletion TESTS/mbedmicro-rtos-mbed/threads/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#define PARALLEL_THREAD_STACK_SIZE 512
#elif defined(__ARM_FM)
#define PARALLEL_THREAD_STACK_SIZE 512
#elif defined(TARGET_FUTURE_SEQUANA_PSA)
#elif defined(TARGET_FUTURE_SEQUANA_PSA) || defined(TARGET_CY8CKIT_062_WIFI_BT_PSA)
#define PARALLEL_THREAD_STACK_SIZE 512
#else
#define PARALLEL_THREAD_STACK_SIZE 384
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,11 +681,11 @@ const char *UBUTest_CopyUtil()
return "CopyFloatToUint32 failed";
}

if(UsefulBufUtil_CopyDoubleToUint64(4e-40F) != 0X37C16C2800000000ULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moranpeker @avolinski
please review the changes in this commit

if(UsefulBufUtil_CopyDoubleToUint64(4e-40L) != 0X37C16C2800000000ULL) {
return "CopyDoubleToUint64 failed";
}

if(UsefulBufUtil_CopyUint64ToDouble(0X37C16C2800000000ULL) != 4e-40F) {
if(UsefulBufUtil_CopyUint64ToDouble(0X37C16C2800000000ULL) != 4e-40L) {
return "CopyUint64ToDouble failed";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ int DoubleAsSmallestTest()
// 70 # text(16)
// 7375626E6F726D616C2073696E676C65 # "subnormal single"
// FB 37C16C2800000000 # primitive(4017611261645684736)
QCBOREncode_AddDoubleAsSmallestToMap(&EC, "subnormal single", 4e-40F);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moranpeker @avolinski
please review the changes in this commit

QCBOREncode_AddDoubleAsSmallestToMap(&EC, "subnormal single", 4e-40L);

// 03 # unsigned(3)
// F9 C000 # primitive(49152)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* mbed Microcontroller Library
* Copyright (c) 2017-2017 ARM Limited
* Copyright (c) 2017-2018 Future Electronics
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* mbed Microcontroller Library
* Copyright (c) 2017-2017 ARM Limited
* Copyright (c) 2017-2018 Future Electronics
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* mbed Microcontroller Library
* Copyright (c) 2017-2017 ARM Limited
* Copyright (c) 2017-2018 Future Electronics
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/* mbed Microcontroller Library
* Copyright (c) 2017-2017 ARM Limited
* SPDX-License-Identifier: Apache-2.0
*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SPDX identifier for new files please

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.
Fixes to PinNamesTypes.h and PortNames.h files from TARGET_Cypress\TARGET_PSOC6 will be merged to the PR on Monday.

* 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.
*/

#if DEVICE_SERIAL && DEVICE_SERIAL_FC

#include "CyH4TransportDriver.h"
#include "cycfg_pins.h"

namespace ble {
namespace vendor {
namespace cypress_ble {

CyH4TransportDriver::CyH4TransportDriver(PinName tx, PinName rx, PinName cts, PinName rts, int baud, PinName bt_host_wake_name, PinName bt_device_wake_name) :
uart(tx, rx, baud), cts(cts), rts(rts),
bt_host_wake_name(bt_host_wake_name),
bt_device_wake_name(bt_device_wake_name),
bt_host_wake(bt_host_wake_name, PIN_INPUT, PullNone, 0),
bt_device_wake(bt_device_wake_name, PIN_OUTPUT, PullDefault, 1)
{
}

void CyH4TransportDriver::bt_host_wake_irq_handler(void)
{
sleep_manager_lock_deep_sleep();
CyH4TransportDriver::on_controller_irq();
sleep_manager_unlock_deep_sleep();
}

void CyH4TransportDriver::initialize()
{
InterruptIn *host_wake_pin;

uart.format(
/* bits */ 8,
/* parity */ SerialBase::None,
/* stop bit */ 1
);

uart.set_flow_control(
/* flow */ SerialBase::RTSCTS,
/* rts */ rts,
/* cts */ cts
);

uart.attach(
callback(this, &CyH4TransportDriver::on_controller_irq),
SerialBase::RxIrq
);

#if (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER)
//Register IRQ for Host WAKE
host_wake_pin = new InterruptIn(bt_host_wake_name);
host_wake_pin->fall(callback(this, &CyH4TransportDriver::bt_host_wake_irq_handler));

#endif
bt_device_wake = 0;
wait_ms(500);
}

void CyH4TransportDriver::terminate() { }

uint16_t CyH4TransportDriver::write(uint8_t type, uint16_t len, uint8_t *pData)
{
uint16_t i = 0;

assert_bt_dev_wake();

while (i < len + 1) {
uint8_t to_write = i == 0 ? type : pData[i - 1];
while (uart.writeable() == 0);
uart.putc(to_write);
++i;
}

deassert_bt_dev_wake();
return len;
}

void CyH4TransportDriver::on_controller_irq()
{
assert_bt_dev_wake();

while (uart.readable()) {
uint8_t char_received = uart.getc();
on_data_received(&char_received, 1);
}

deassert_bt_dev_wake();
}

void CyH4TransportDriver::assert_bt_dev_wake()
{
#if (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER)
bt_device_wake = 0;
#endif
}

void CyH4TransportDriver::deassert_bt_dev_wake()
{
#if (defined(MBED_TICKLESS) && DEVICE_SLEEP && DEVICE_LPTICKER)
//De-assert bt_device_wake
bt_device_wake = 1;
#endif
}

} // namespace cypress_ble
} // namespace vendor
} // namespace ble

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/* mbed Microcontroller Library
* Copyright (c) 2017-2017 ARM Limited
* SPDX-License-Identifier: Apache-2.0
*
* 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 CY_H4TRANSPORT_DRIVER_H_
#define CY_H4TRANSPORT_DRIVER_H_

#if (DEVICE_SERIAL && DEVICE_SERIAL_FC) || defined(DOXYGEN_ONLY)

#include <stdint.h>
#include "mbed.h"
#include "CordioHCITransportDriver.h"
#include "drivers/DigitalInOut.h"


namespace ble {
namespace vendor {
namespace cypress_ble {

using namespace ble::vendor;

/**
* Implementation of the H4 driver over Cypress based chips.
*/
class CyH4TransportDriver : public cordio::CordioHCITransportDriver {
public:
/**
* Initialize the transport driver.
*
*/
CyH4TransportDriver(PinName tx, PinName rx, PinName cts, PinName rts, int baud, PinName bt_host_wake_name, PinName bt_device_wake_name);

/**
* Destructor
*/
virtual ~CyH4TransportDriver() { }

/**
* @see CordioHCITransportDriver::initialize
*/
virtual void initialize();

/**
* @see CordioHCITransportDriver::terminate
*/
virtual void terminate();

/**
* @see CordioHCITransportDriver::write
*/
virtual uint16_t write(uint8_t type, uint16_t len, uint8_t *pData);

void bt_host_wake_irq_handler();

private:
private:
void on_controller_irq();
void assert_bt_dev_wake();
void deassert_bt_dev_wake();

// Use RawSerial as opposed to Serial as we don't require the locking primitives
// provided by the Serial class (access to the UART should be exclusive to this driver)
// Furthermore, we access the peripheral in interrupt context which would clash
// with Serial's locking facilities
RawSerial uart;
PinName cts;
PinName rts;
PinName bt_host_wake_name;
PinName bt_device_wake_name;
DigitalInOut bt_host_wake;
DigitalInOut bt_device_wake;
};

} // namespace cypress
} // namespace vendor
} // namespace ble

#endif
#endif /* CY_H4TRANSPORT_DRIVER_H_ */
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018 ARM Limited
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,7 +24,7 @@
#include "bstream.h"
#include <stdbool.h>
#include "hci_mbed_os_adaptation.h"
#include "H4TransportDriver.h"
#include "CyH4TransportDriver.h"
#include "cycfg_pins.h"

extern const int brcm_patch_ram_length;
Expand Down Expand Up @@ -56,15 +57,9 @@ class HCIDriver : public cordio::CordioHCIDriver {
public:
HCIDriver(
cordio::CordioHCITransportDriver& transport_driver,
PinName bt_host_wake_name,
PinName bt_device_wake_name,
PinName bt_power_name
) : cordio::CordioHCIDriver(transport_driver),
bt_host_wake_name(bt_host_wake_name),
bt_device_wake_name(bt_device_wake_name),
bt_power_name(bt_power_name),
bt_host_wake(bt_host_wake_name, PIN_INPUT, PullNone, 0),
bt_device_wake(bt_device_wake_name, PIN_OUTPUT, PullDefault, 1),
bt_power(bt_power_name, PIN_OUTPUT, PullUp, 0),
service_pack_index(0),
service_pack_ptr(0),
Expand All @@ -81,9 +76,6 @@ class HCIDriver : public cordio::CordioHCIDriver {

virtual void do_initialize()
{
bt_device_wake = 0;
wait_ms(500);

bt_power = 1;
wait_ms(500);
}
Expand Down Expand Up @@ -351,7 +343,7 @@ class HCIDriver : public cordio::CordioHCIDriver {
uint8_t *pBuf;
if ((pBuf = hciCmdAlloc(HCI_VS_CMD_SET_SLEEP_MODE, 12)) != NULL)
{
pBuf[HCI_CMD_HDR_LEN] = 0x00; // no sleep moode
pBuf[HCI_CMD_HDR_LEN] = 0x00; // no sleep
pBuf[HCI_CMD_HDR_LEN + 1] = 0x00; // no idle threshold host (N/A)
pBuf[HCI_CMD_HDR_LEN + 2] = 0x00; // no idle threshold HC (N/A)
pBuf[HCI_CMD_HDR_LEN + 3] = 0x00; // BT WAKE
Expand Down Expand Up @@ -414,11 +406,7 @@ class HCIDriver : public cordio::CordioHCIDriver {
}
}

PinName bt_host_wake_name;
PinName bt_device_wake_name;
PinName bt_power_name;
DigitalInOut bt_host_wake;
DigitalInOut bt_device_wake;
DigitalInOut bt_power;
size_t service_pack_index;
const uint8_t* service_pack_ptr;
Expand All @@ -433,13 +421,14 @@ class HCIDriver : public cordio::CordioHCIDriver {
} // namespace ble

ble::vendor::cordio::CordioHCIDriver& ble_cordio_get_hci_driver() {
static ble::vendor::cordio::H4TransportDriver transport_driver(
static ble::vendor::cypress_ble::CyH4TransportDriver transport_driver(
/* TX */ CY_BT_UART_TX, /* RX */ CY_BT_UART_RX,
/* cts */ CY_BT_UART_CTS, /* rts */ CY_BT_UART_RTS, 115200
/* cts */ CY_BT_UART_CTS, /* rts */ CY_BT_UART_RTS, 115200,
CY_BT_PIN_HOST_WAKE, CY_BT_PIN_DEVICE_WAKE
);
static ble::vendor::cypress::HCIDriver hci_driver(
transport_driver, /* host wake */ CY_BT_PIN_HOST_WAKE,
/* device wake */ CY_BT_PIN_DEVICE_WAKE, /* bt_power */ CY_BT_PIN_POWER
transport_driver,
/* bt_power */ CY_BT_PIN_POWER
);
return hci_driver;
}
3 changes: 3 additions & 0 deletions features/storage/kvstore/conf/global/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"FUTURE_SEQUANA_M0_PSA": {
"storage_type": "TDB_INTERNAL"
},
"CY8CKIT_062_WIFI_BT_M0_PSA": {
"storage_type": "TDB_INTERNAL"
},
"K66F": {
"storage_type": "TDB_INTERNAL"
},
Expand Down
4 changes: 4 additions & 0 deletions features/storage/kvstore/conf/tdb_internal/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
"FUTURE_SEQUANA_M0_PSA": {
"internal_size": "0x8000",
"internal_base_address": "0x10078000"
},
"CY8CKIT_062_WIFI_BT_M0_PSA": {
"internal_size": "0x8000",
"internal_base_address": "0x10078000"
}
}
}
Loading