Skip to content

Commit 0e6eac5

Browse files
author
Cruz Monrreal
authored
Merge pull request #8491 from lrusinowicz/new-target-future_sequana
New target future sequana
2 parents 5a8a598 + 5347784 commit 0e6eac5

File tree

190 files changed

+101882
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

190 files changed

+101882
-11
lines changed
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/*
2+
* mbed Microcontroller Library
3+
* Copyright (c) 2017-2017 ARM Limited
4+
* Copyright (c) 2017-2018 Future Electronics
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include "hci_api.h"
20+
#include "bstream.h"
21+
#include "driver/CordioHCIDriver.h"
22+
#include "drivers/IPCPipeTransportDriver.h"
23+
#include "psoc6_utils.h"
24+
25+
using namespace ble::vendor::cordio;
26+
using namespace ble::vendor::cypress;
27+
28+
const uint16_t HCI_VEND_SET_BD_ADDR = 0xfda0;
29+
const uint8_t HCI_VEND_SET_BD_ADDR_LEN = 7; /* MAC address + address type */
30+
31+
class Psoc6HCIDriver : public CordioHCIDriver
32+
{
33+
public:
34+
Psoc6HCIDriver(IPCPipeTransportDriver& transport_driver) :
35+
CordioHCIDriver(transport_driver)
36+
{
37+
}
38+
39+
40+
private:
41+
42+
struct BdAddress {
43+
uint8_t mac_address[6];
44+
uint8_t addr_type;
45+
46+
BdAddress() : addr_type(0) {}
47+
};
48+
49+
/**
50+
* Initialize the chip.
51+
* The transport is up at that time.
52+
*/
53+
virtual void do_initialize();
54+
55+
/**
56+
* Terminate the driver
57+
*/
58+
virtual void do_terminate() {}
59+
60+
virtual void handle_reset_sequence(uint8_t *pMsg);
61+
62+
private:
63+
BdAddress bd_address;
64+
};
65+
66+
67+
void Psoc6HCIDriver::do_initialize()
68+
{
69+
cy_get_bd_mac_address(bd_address.mac_address);
70+
}
71+
72+
73+
void Psoc6HCIDriver::handle_reset_sequence(uint8_t *pMsg) {
74+
75+
uint16_t opcode;
76+
77+
/* if event is a command complete event */
78+
if (*pMsg == HCI_CMD_CMPL_EVT) {
79+
/* parse parameters */
80+
uint8_t *pMsg2 = pMsg + HCI_EVT_HDR_LEN;
81+
pMsg2++; /* skip num packets */
82+
BSTREAM_TO_UINT16(opcode, pMsg2);
83+
pMsg2 -= 2;
84+
/* decode opcode */
85+
switch (opcode) {
86+
case HCI_OPCODE_RESET:
87+
/* send next command in sequence */
88+
HciVendorSpecificCmd(HCI_VEND_SET_BD_ADDR,
89+
HCI_VEND_SET_BD_ADDR_LEN,
90+
reinterpret_cast<uint8_t*>(&bd_address));
91+
break;
92+
93+
case HCI_VEND_SET_BD_ADDR:
94+
/* pretend we have just completed reset */
95+
UINT16_TO_BSTREAM(pMsg2, HCI_OPCODE_RESET);
96+
CordioHCIDriver::handle_reset_sequence(pMsg);
97+
break;
98+
99+
default:
100+
/* pass to parent */
101+
CordioHCIDriver::handle_reset_sequence(pMsg);
102+
}
103+
}
104+
}
105+
106+
107+
CordioHCIDriver& ble_cordio_get_hci_driver() {
108+
static IPCPipeTransportDriver transport_driver;
109+
110+
static Psoc6HCIDriver hci_driver(
111+
transport_driver /* other hci driver parameters */
112+
);
113+
114+
return hci_driver;
115+
}
116+
117+
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* mbed Microcontroller Library
3+
* Copyright (c) 2017-2017 ARM Limited
4+
* Copyright (c) 2017-2018 Future Electronics
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include "IPCPipeTransportDriver.h"
20+
#include "ipcpipe_transport.h"
21+
#include "mbed_assert.h"
22+
#include "mbed_error.h"
23+
24+
namespace ble {
25+
namespace vendor {
26+
namespace cypress {
27+
28+
29+
void dump_buffer(uint8_t *buffer, uint32_t len)
30+
{
31+
32+
while (len > 0) {
33+
printf(" %02x", *buffer++);
34+
--len;
35+
}
36+
printf("\n");
37+
}
38+
39+
void ipc_h4_receive(uint32_t *ptr)
40+
{
41+
IpcPipeMessage *message = (IpcPipeMessage *)ptr;
42+
43+
// We don't expect header to be received from M0+ core.
44+
MBED_ASSERT(message->header_length == 0);
45+
46+
// printf("BLE received: ");
47+
// h4_dump_buffer(buffer->message.data, buffer->message.length);
48+
cordio::CordioHCITransportDriver::on_data_received(message->data, message->data_length);
49+
}
50+
51+
IPCPipeTransportDriver::IPCPipeTransportDriver()
52+
{ }
53+
54+
void IPCPipeTransportDriver::initialize()
55+
{
56+
// printf("H4 Transport driver initialization.\n");
57+
ipcpipe_transport_start(IPCPIPE_CLIENT_H4, ipc_h4_receive, NULL);
58+
}
59+
60+
void IPCPipeTransportDriver::terminate()
61+
{
62+
ipcpipe_transport_stop(IPCPIPE_CLIENT_H4);
63+
}
64+
65+
uint16_t IPCPipeTransportDriver::write(uint8_t type, uint16_t len, uint8_t *pData)
66+
{
67+
// printf("BLE sending T<%02x>:", type);
68+
// dump_buffer(pData, len);
69+
ipcpipe_write_data(IPCPIPE_CLIENT_H4, &type, 1, pData, len);
70+
return len;
71+
}
72+
73+
} // namespace cypress
74+
} // namespace vendor
75+
} // namespace ble
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* mbed Microcontroller Library
3+
* Copyright (c) 2017-2017 ARM Limited
4+
* Copyright (c) 2017-2018 Future Electronics
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#ifndef PSOC6_IPCPIPE_TRANSPORT_DRIVER_H_
20+
#define PSOC6_IPCPIPE_TRANSPORT_DRIVER_H_
21+
22+
#include <stdint.h>
23+
#include "mbed.h"
24+
#include "CordioHCITransportDriver.h"
25+
26+
27+
namespace ble {
28+
namespace vendor {
29+
namespace cypress {
30+
31+
using namespace ble::vendor;
32+
33+
/**
34+
* Implementation of the H4 driver over PSoC6 IPC pipe.
35+
*/
36+
class IPCPipeTransportDriver : public cordio::CordioHCITransportDriver {
37+
public:
38+
/**
39+
* Initialize the transport driver.
40+
*
41+
*/
42+
IPCPipeTransportDriver();
43+
44+
/**
45+
* Destructor
46+
*/
47+
virtual ~IPCPipeTransportDriver() { }
48+
49+
/**
50+
* @see CordioHCITransportDriver::initialize
51+
*/
52+
virtual void initialize();
53+
54+
/**
55+
* @see CordioHCITransportDriver::terminate
56+
*/
57+
virtual void terminate();
58+
59+
/**
60+
* @see CordioHCITransportDriver::write
61+
*/
62+
virtual uint16_t write(uint8_t type, uint16_t len, uint8_t *pData);
63+
64+
private:
65+
66+
};
67+
68+
} // namespace cypress
69+
} // namespace vendor
70+
} // namespace ble
71+
72+
#endif /* PSOC6_IPCPIPE_TRANSPORT_DRIVER_H_ */

features/storage/nvstore/mbed_lib.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,19 @@
2727
"macro_name": "NVSTORE_AREA_2_SIZE",
2828
"help": "Area 2 size"
2929
}
30+
},
31+
"target_overrides": {
32+
"FUTURE_SEQUANA": {
33+
"area_1_address": "0x100F8000",
34+
"area_1_size": 16384,
35+
"area_2_address": "0x100FC000",
36+
"area_2_size": 16384
37+
},
38+
"FUTURE_SEQUANA_M0": {
39+
"area_1_address": "0x10078000",
40+
"area_1_size": 16384,
41+
"area_2_address": "0x1007C000",
42+
"area_2_size": 16384
43+
}
3044
}
3145
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
* mbed Microcontroller Library
3+
* Copyright (c) 2017-2018 Future Electronics
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#ifndef MBED_PERIPHERALNAMES_H
19+
#define MBED_PERIPHERALNAMES_H
20+
21+
#include "cmsis.h"
22+
#include "PinNames.h"
23+
24+
#ifdef __cplusplus
25+
extern "C" {
26+
#endif
27+
28+
typedef enum {
29+
UART_0 = (int)SCB0_BASE,
30+
UART_1 = (int)SCB1_BASE,
31+
UART_2 = (int)SCB2_BASE,
32+
UART_3 = (int)SCB3_BASE,
33+
UART_4 = (int)SCB4_BASE,
34+
UART_5 = (int)SCB5_BASE,
35+
UART_6 = (int)SCB6_BASE,
36+
UART_7 = (int)SCB7_BASE,
37+
} UARTName;
38+
39+
40+
typedef enum {
41+
SPI_0 = (int)SCB0_BASE,
42+
SPI_1 = (int)SCB1_BASE,
43+
SPI_2 = (int)SCB2_BASE,
44+
SPI_3 = (int)SCB3_BASE,
45+
SPI_4 = (int)SCB4_BASE,
46+
SPI_5 = (int)SCB5_BASE,
47+
SPI_6 = (int)SCB6_BASE,
48+
SPI_7 = (int)SCB7_BASE,
49+
} SPIName;
50+
51+
typedef enum {
52+
I2C_0 = (int)SCB0_BASE,
53+
I2C_1 = (int)SCB1_BASE,
54+
I2C_2 = (int)SCB2_BASE,
55+
I2C_3 = (int)SCB3_BASE,
56+
I2C_4 = (int)SCB4_BASE,
57+
I2C_5 = (int)SCB5_BASE,
58+
I2C_6 = (int)SCB6_BASE,
59+
I2C_7 = (int)SCB7_BASE,
60+
} I2CName;
61+
62+
typedef enum {
63+
PWM_32b_0 = TCPWM0_BASE,
64+
PWM_32b_1,
65+
PWM_32b_2,
66+
PWM_32b_3,
67+
PWM_32b_4,
68+
PWM_32b_5,
69+
PWM_32b_6,
70+
PWM_32b_7,
71+
PWM_16b_0 = TCPWM1_BASE,
72+
PWM_16b_1,
73+
PWM_16b_2,
74+
PWM_16b_3,
75+
PWM_16b_4,
76+
PWM_16b_5,
77+
PWM_16b_6,
78+
PWM_16b_7,
79+
PWM_16b_8,
80+
PWM_16b_9,
81+
PWM_16b_10,
82+
PWM_16b_11,
83+
PWM_16b_12,
84+
PWM_16b_13,
85+
PWM_16b_14,
86+
PWM_16b_15,
87+
PWM_16b_16,
88+
PWM_16b_17,
89+
PWM_16b_18,
90+
PWM_16b_19,
91+
PWM_16b_20,
92+
PWM_16b_21,
93+
PWM_16b_22,
94+
PWM_16b_23,
95+
} PWMName;
96+
97+
typedef enum {
98+
ADC_0 = (int)SAR_BASE,
99+
} ADCName;
100+
101+
typedef enum {
102+
DAC_0 = (int)CTDAC0_BASE,
103+
} DACName;
104+
105+
#ifdef __cplusplus
106+
}
107+
#endif
108+
109+
#endif

0 commit comments

Comments
 (0)