Mistake on this page?
Report an issue in GitHub or email us
EMW3080B_SPI.h
1 /*
2  * Copyright (c) STMicroelectronics 2021
3  * SPDX-License-Identifier: Apache-2.0
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 
19 /* Includes ------------------------------------------------------------------*/
20 #include <inttypes.h>
21 
22 /* Private includes ----------------------------------------------------------*/
23 #include "mbed.h"
24 #include "mbed_debug.h"
25 #include "mbed_error.h"
26 #include "mx_wifi.h"
27 #include "core/mx_wifi_hci.h"
28 
29 
30 
31 class EMW3080B_SPI : public SPI {
32 public:
33  EMW3080B_SPI(bool debug = MBED_CONF_EMW3080B_WIFI_DEBUG,
34  PinName mosi = MBED_CONF_EMW3080B_WIFI_MOSI,
35  PinName miso = MBED_CONF_EMW3080B_WIFI_MISO,
36  PinName sclk = MBED_CONF_EMW3080B_WIFI_SCLK,
37  PinName nss = MBED_CONF_EMW3080B_WIFI_NSS,
38  PinName notify = MBED_CONF_EMW3080B_WIFI_NOTIFY,
39  PinName flow = MBED_CONF_EMW3080B_WIFI_FLOW,
40  PinName reset = MBED_CONF_EMW3080B_WIFI_RESET
41  );
42 
43 private:
44  DigitalOut _resetpin;
45  DigitalOut _nsspin;
46 
47  DigitalIn _notifypin;
48  DigitalIn _flowpin;
49 
50  InterruptIn *_notify_irq;
51  InterruptIn *_flow_irq;
52 
53  void flow_rise(void);
54  void notify_rise(void);
55  int8_t wait_flow_high(uint32_t timeout);
56 
57  SEM_DECLARE(spi_txrx_sem);
58  SEM_DECLARE(spi_flow_rise_sem);
59  SEM_DECLARE(spi_transfer_done_sem);
60 
61  uint8_t *spi_tx_data = NULL;
62  uint16_t spi_tx_len = 0;
63 
64  int32_t TransmitReceive(uint8_t *txdata, uint8_t *rxdata, uint32_t datalen, uint32_t timeout);
65  int32_t Transmit(uint8_t *txdata, uint32_t datalen, uint32_t timeout);
66  int32_t Receive(uint8_t *rxdata, uint32_t datalen, uint32_t timeout);
67  void spi_handler(int event);
68 
69  int8_t mx_wifi_spi_txrx_start(void);
70  int8_t mx_wifi_spi_txrx_stop(void);
71 
72  THREAD_DECLARE(MX_WIFI_TxRxThreadId);
73 
74 
75 public:
76 
77  int8_t IO_Init(uint16_t mode);
78  int8_t IO_DeInit(void);
79  void IO_Delay(uint32_t delayms);
80  uint16_t IO_Send(uint8_t *data, uint16_t len);
81  uint16_t IO_Receive(uint8_t *buffer, uint16_t buff_size);
82  void process_txrx_poll(uint32_t timeout);
83 
84  uint8_t _debug_level;
85 };
Header for mx_wifi.c module.
Header for mx_wifi_hci.c module.
A digital interrupt input, used to call a function on a rising or falling edge.
Definition: InterruptIn.h:65
A digital output, used for setting the state of a pin.
Definition: DigitalOut.h:51
A SPI Master, used for communicating with SPI slave devices.
Definition: SPI.h:98
static void debug(const char *format,...) MBED_PRINTF(1
Output a debug message.
Definition: mbed_debug.h:44
A digital input, used for reading the state of a pin.
Definition: DigitalIn.h:56
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.