-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Pr/cy mbed os 5.12.0 #9908
Changes from all commits
aedec74
69c5404
0cce5d5
6d3ec4c
20c2734
ac6a6b8
084a837
4c1ff13
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -379,7 +379,7 @@ int DoubleAsSmallestTest() | |
// 70 # text(16) | ||
// 7375626E6F726D616C2073696E676C65 # "subnormal single" | ||
// FB 37C16C2800000000 # primitive(4017611261645684736) | ||
QCBOREncode_AddDoubleAsSmallestToMap(&EC, "subnormal single", 4e-40F); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @moranpeker @avolinski |
||
QCBOREncode_AddDoubleAsSmallestToMap(&EC, "subnormal single", 4e-40L); | ||
|
||
// 03 # unsigned(3) | ||
// F9 C000 # primitive(49152) | ||
|
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 | ||
* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SPDX identifier for new files please There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
* 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_ */ |
There was a problem hiding this comment.
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