Skip to content

Commit 46dad5a

Browse files
committed
Confilicting names changed
1 parent a2d763f commit 46dad5a

File tree

6 files changed

+339
-48
lines changed

6 files changed

+339
-48
lines changed

.vscode/c_cpp_properties.json

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Mac",
5+
"includePath": [
6+
"/usr/include",
7+
"/usr/local/include",
8+
"${workspaceRoot}"
9+
],
10+
"defines": [],
11+
"intelliSenseMode": "clang-x64",
12+
"browse": {
13+
"path": [
14+
"/usr/include",
15+
"/usr/local/include",
16+
"${workspaceRoot}"
17+
],
18+
"limitSymbolsToIncludedHeaders": true,
19+
"databaseFilename": ""
20+
},
21+
"macFrameworkPath": [
22+
"/System/Library/Frameworks",
23+
"/Library/Frameworks"
24+
]
25+
},
26+
{
27+
"name": "Linux",
28+
"includePath": [
29+
"/home/LoBo2_Razno/ESP32/esp-idf/components",
30+
"/home/LoBo2_Razno/ESP32/esp-idf/components/driver/include",
31+
"/home/LoBo2_Razno/ESP32/esp-idf/components/newlib/include",
32+
"/home/LoBo2_Razno/ESP32/esp-idf/components/freertos/include",
33+
"/home/LoBo2_Razno/ESP32/esp-idf/components/esp32/include",
34+
"/home/LoBo2_Razno/ESP32/esp-idf/components/log/include",
35+
"/home/LoBo2_Razno/ESP32/esp-idf/components/nvs_flash/include",
36+
"/home/LoBo2_Razno/ESP32/esp-idf/components/heap/include",
37+
"/home/LoBo2_Razno/ESP32/esp-idf/components/tcpip_adapter/include",
38+
"/home/LoBo2_Razno/ESP32/esp-idf/components/soc/include",
39+
"/home/LoBo2_Razno/ESP32/esp-idf/components/lwip/include/lwip",
40+
"/home/LoBo2_Razno/ESP32/esp-idf/components/lwip/include/lwip/port",
41+
"/home/LoBo2_Razno/ESP32/esp-idf/components/soc/esp32/include",
42+
"${workspaceRoot}/build/include",
43+
"${workspaceRoot}/components/tft",
44+
"${workspaceRoot}/components/spiffs",
45+
"${workspaceRoot}/components/spidriver",
46+
"/usr/include/c++/7",
47+
"/usr/include/x86_64-linux-gnu/c++/7",
48+
"/usr/include/c++/7/backward",
49+
"/usr/lib/gcc/x86_64-linux-gnu/7/include",
50+
"/usr/local/include",
51+
"/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed",
52+
"/usr/include/x86_64-linux-gnu",
53+
"/usr/include",
54+
"${workspaceRoot}"
55+
],
56+
"defines": [],
57+
"intelliSenseMode": "clang-x64",
58+
"browse": {
59+
"path": [
60+
"/home/LoBo2_Razno/ESP32/esp-idf/components",
61+
"/usr/include/c++/7",
62+
"/usr/include/x86_64-linux-gnu/c++/7",
63+
"/usr/include/c++/7/backward",
64+
"/usr/lib/gcc/x86_64-linux-gnu/7/include",
65+
"/usr/local/include",
66+
"/usr/lib/gcc/x86_64-linux-gnu/7/include-fixed",
67+
"/usr/include/x86_64-linux-gnu",
68+
"/usr/include",
69+
"${workspaceRoot}"
70+
],
71+
"limitSymbolsToIncludedHeaders": true,
72+
"databaseFilename": ""
73+
}
74+
},
75+
{
76+
"name": "Win32",
77+
"includePath": [
78+
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include",
79+
"${workspaceRoot}"
80+
],
81+
"defines": [
82+
"_DEBUG",
83+
"UNICODE"
84+
],
85+
"intelliSenseMode": "msvc-x64",
86+
"browse": {
87+
"path": [
88+
"C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include/*",
89+
"${workspaceRoot}"
90+
],
91+
"limitSymbolsToIncludedHeaders": true,
92+
"databaseFilename": ""
93+
}
94+
}
95+
],
96+
"version": 3
97+
}

.vscode/tasks.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"version": "0.1.0",
3+
"command": "bash",
4+
"args": ["-c"],
5+
"isShellCommand": true,
6+
"showOutput": "always",
7+
"suppressTaskName": true,
8+
"options": {
9+
"cwd": "${workspaceRoot}"
10+
},
11+
"tasks": [
12+
{
13+
"taskName": "build app",
14+
"args": ["./BUILD all"],
15+
"isBuildCommand": false,
16+
"problemMatcher": {
17+
"owner": "cpp",
18+
"fileLocation": "absolute",
19+
"pattern": {
20+
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
21+
"file": 1,
22+
"line": 2,
23+
"column": 3,
24+
"severity": 4,
25+
"message": 5
26+
}
27+
}
28+
},
29+
{
30+
"taskName": "build app -j8",
31+
"args": ["./BUILD -j8 all"],
32+
"isBuildCommand": true,
33+
"problemMatcher": {
34+
"owner": "cpp",
35+
"fileLocation": "absolute",
36+
"pattern": {
37+
"regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
38+
"file": 1,
39+
"line": 2,
40+
"column": 3,
41+
"severity": 4,
42+
"message": 5
43+
}
44+
}
45+
},
46+
{
47+
"taskName": "clean app",
48+
"args": ["./BUILD clean"]
49+
},
50+
{
51+
"taskName": "flash app",
52+
"args": ["make app-flash"]
53+
},
54+
{
55+
"taskName": "monitor",
56+
"command": "gnome-terminal",
57+
"args": ["-e","make monitor"],
58+
"isShellCommand": false,
59+
"showOutput": "never"
60+
},
61+
{
62+
"taskName": "menuconfig",
63+
"command": "gnome-terminal",
64+
"args": ["-e","make menuconfig"],
65+
"isShellCommand": false,
66+
"showOutput": "never"
67+
}
68+
]
69+
}

components/spidriver/spi_master_lobo.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Main driver's function is 'spi_lobo_transfer_data()'
4444
* Lengths must be 8-bit multiples!
4545
* If trans->rx_buffer is NULL or trans->rx_length is 0, only transmits data
4646
* If trans->tx_buffer is NULL or trans->length is 0, only receives data
47-
* If the device is in duplex mode (SPI_DEVICE_HALFDUPLEX flag NOT set), data are transmitted and received simultaneously.
48-
* If the device is in half duplex mode (SPI_DEVICE_HALFDUPLEX flag IS set), data are received after transmission
47+
* If the device is in duplex mode (LB_SPI_DEVICE_HALFDUPLEX flag NOT set), data are transmitted and received simultaneously.
48+
* If the device is in half duplex mode (LB_SPI_DEVICE_HALFDUPLEX flag IS set), data are received after transmission
4949
* 'address', 'command' and 'dummy bits' are transmitted before data phase IF set in device's configuration
5050
* and IF 'trans->length' and 'trans->rx_length' are NOT both 0
5151
* If configured, devices 'pre_cb' callback is called before and 'post_cb' after the transmission
@@ -567,10 +567,10 @@ esp_err_t spi_lobo_bus_add_device(spi_lobo_host_device_t host, spi_lobo_bus_conf
567567

568568
// The hardware looks like it would support this, but actually setting cs_ena_pretrans when transferring in full
569569
// duplex mode does absolutely nothing on the ESP32.
570-
if ((dev_config->cs_ena_pretrans != 0) && (dev_config->flags & SPI_DEVICE_HALFDUPLEX)) return ESP_ERR_INVALID_ARG;
570+
if ((dev_config->cs_ena_pretrans != 0) && (dev_config->flags & LB_SPI_DEVICE_HALFDUPLEX)) return ESP_ERR_INVALID_ARG;
571571

572572
// Speeds >=40MHz over GPIO matrix needs a dummy cycle, but these don't work for full-duplex connections.
573-
if (((dev_config->flags & SPI_DEVICE_HALFDUPLEX)==0) && (dev_config->clock_speed_hz > ((apbclk*2)/5)) && (!spihost[host]->no_gpio_matrix)) return ESP_ERR_INVALID_ARG;
573+
if (((dev_config->flags & LB_SPI_DEVICE_HALFDUPLEX)==0) && (dev_config->clock_speed_hz > ((apbclk*2)/5)) && (!spihost[host]->no_gpio_matrix)) return ESP_ERR_INVALID_ARG;
574574

575575
//Allocate memory for device
576576
spi_lobo_device_t *dev=malloc(sizeof(spi_lobo_device_t));
@@ -604,12 +604,12 @@ esp_err_t spi_lobo_bus_add_device(spi_lobo_host_device_t host, spi_lobo_bus_conf
604604
gpio_set_direction(dev_config->spics_ext_io_num, GPIO_MODE_OUTPUT);
605605
gpio_set_level(dev_config->spics_ext_io_num, 1);
606606
}
607-
if (dev_config->flags & SPI_DEVICE_CLK_AS_CS) {
607+
if (dev_config->flags & LB_SPI_DEVICE_CLK_AS_CS) {
608608
spihost[host]->hw->pin.master_ck_sel |= (1<<freecs);
609609
} else {
610610
spihost[host]->hw->pin.master_ck_sel &= (1<<freecs);
611611
}
612-
if (dev_config->flags & SPI_DEVICE_POSITIVE_CS) {
612+
if (dev_config->flags & LB_SPI_DEVICE_POSITIVE_CS) {
613613
spihost[host]->hw->pin.master_cs_pol |= (1<<freecs);
614614
} else {
615615
spihost[host]->hw->pin.master_cs_pol &= (1<<freecs);
@@ -746,15 +746,15 @@ esp_err_t IRAM_ATTR spi_lobo_device_select(spi_lobo_device_handle_t handle, int
746746
int apbclk=APB_CLK_FREQ;
747747

748748
//Speeds >=40MHz over GPIO matrix needs a dummy cycle, but these don't work for full-duplex connections.
749-
if (((handle->cfg.flags & SPI_DEVICE_HALFDUPLEX) == 0) && (handle->cfg.clock_speed_hz > ((apbclk*2)/5)) && (!host->no_gpio_matrix)) {
749+
if (((handle->cfg.flags & LB_SPI_DEVICE_HALFDUPLEX) == 0) && (handle->cfg.clock_speed_hz > ((apbclk*2)/5)) && (!host->no_gpio_matrix)) {
750750
// set speed to 32 MHz
751751
handle->cfg.clock_speed_hz = (apbclk*2)/5;
752752
}
753753

754754
int effclk=spi_set_clock(host->hw, apbclk, handle->cfg.clock_speed_hz, handle->cfg.duty_cycle_pos);
755755
//Configure bit order
756-
host->hw->ctrl.rd_bit_order=(handle->cfg.flags & SPI_DEVICE_RXBIT_LSBFIRST)?1:0;
757-
host->hw->ctrl.wr_bit_order=(handle->cfg.flags & SPI_DEVICE_TXBIT_LSBFIRST)?1:0;
756+
host->hw->ctrl.rd_bit_order=(handle->cfg.flags & LB_SPI_DEVICE_RXBIT_LSBFIRST)?1:0;
757+
host->hw->ctrl.wr_bit_order=(handle->cfg.flags & LB_SPI_DEVICE_TXBIT_LSBFIRST)?1:0;
758758

759759
//Configure polarity
760760
//SPI iface needs to be configured for a delay in some cases.
@@ -798,8 +798,8 @@ esp_err_t IRAM_ATTR spi_lobo_device_select(spi_lobo_device_handle_t handle, int
798798
host->hw->user1.usr_dummy_cyclelen=handle->cfg.dummy_bits+extra_dummy-1;
799799
host->hw->user2.usr_command_bitlen=handle->cfg.command_bits-1;
800800
//Configure misc stuff
801-
host->hw->user.doutdin=(handle->cfg.flags & SPI_DEVICE_HALFDUPLEX)?0:1;
802-
host->hw->user.sio=(handle->cfg.flags & SPI_DEVICE_3WIRE)?1:0;
801+
host->hw->user.doutdin=(handle->cfg.flags & LB_SPI_DEVICE_HALFDUPLEX)?0:1;
802+
host->hw->user.sio=(handle->cfg.flags & LB_SPI_DEVICE_3WIRE)?1:0;
803803

804804
host->hw->ctrl2.setup_time=handle->cfg.cs_ena_pretrans-1;
805805
host->hw->user.cs_setup=handle->cfg.cs_ena_pretrans?1:0;
@@ -930,14 +930,14 @@ esp_err_t IRAM_ATTR spi_lobo_transfer_data(spi_lobo_device_handle_t handle, spi_
930930
const uint8_t *txbuffer = NULL;
931931
uint8_t *rxbuffer = NULL;
932932

933-
if (trans->flags & SPI_TRANS_USE_TXDATA) {
933+
if (trans->flags & LB_SPI_TRANS_USE_TXDATA) {
934934
// Send data from 'trans->tx_data'
935935
txbuffer=(uint8_t*)&trans->tx_data[0];
936936
} else {
937937
// Send data from 'trans->tx_buffer'
938938
txbuffer=(uint8_t*)trans->tx_buffer;
939939
}
940-
if (trans->flags & SPI_TRANS_USE_RXDATA) {
940+
if (trans->flags & LB_SPI_TRANS_USE_RXDATA) {
941941
// Receive data to 'trans->rx_data'
942942
rxbuffer=(uint8_t*)&trans->rx_data[0];
943943
} else {
@@ -975,7 +975,7 @@ esp_err_t IRAM_ATTR spi_lobo_transfer_data(spi_lobo_device_handle_t handle, spi_
975975

976976
// Test if operating in full duplex mode
977977
uint8_t duplex = 1;
978-
if (handle->cfg.flags & SPI_DEVICE_HALFDUPLEX) duplex = 0; // Half duplex mode !
978+
if (handle->cfg.flags & LB_SPI_DEVICE_HALFDUPLEX) duplex = 0; // Half duplex mode !
979979

980980
uint32_t bits, rdbits;
981981
uint32_t wd;

components/spidriver/spi_master_lobo.h

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,51 +62,51 @@ typedef struct {
6262
} spi_lobo_bus_config_t;
6363

6464

65-
#define SPI_DEVICE_TXBIT_LSBFIRST (1<<0) ///< Transmit command/address/data LSB first instead of the default MSB first
66-
#define SPI_DEVICE_RXBIT_LSBFIRST (1<<1) ///< Receive data LSB first instead of the default MSB first
67-
#define SPI_DEVICE_BIT_LSBFIRST (SPI_TXBIT_LSBFIRST|SPI_RXBIT_LSBFIRST); ///< Transmit and receive LSB first
68-
#define SPI_DEVICE_3WIRE (1<<2) ///< Use spiq for both sending and receiving data
69-
#define SPI_DEVICE_POSITIVE_CS (1<<3) ///< Make CS positive during a transaction instead of negative
70-
#define SPI_DEVICE_HALFDUPLEX (1<<4) ///< Transmit data before receiving it, instead of simultaneously
71-
#define SPI_DEVICE_CLK_AS_CS (1<<5) ///< Output clock on CS line if CS is active
65+
#define LB_SPI_DEVICE_TXBIT_LSBFIRST (1<<0) ///< Transmit command/address/data LSB first instead of the default MSB first
66+
#define LB_SPI_DEVICE_RXBIT_LSBFIRST (1<<1) ///< Receive data LSB first instead of the default MSB first
67+
#define LB_SPI_DEVICE_BIT_LSBFIRST (SPI_TXBIT_LSBFIRST|SPI_RXBIT_LSBFIRST); ///< Transmit and receive LSB first
68+
#define LB_SPI_DEVICE_3WIRE (1<<2) ///< Use spiq for both sending and receiving data
69+
#define LB_SPI_DEVICE_POSITIVE_CS (1<<3) ///< Make CS positive during a transaction instead of negative
70+
#define LB_SPI_DEVICE_HALFDUPLEX (1<<4) ///< Transmit data before receiving it, instead of simultaneously
71+
#define LB_SPI_DEVICE_CLK_AS_CS (1<<5) ///< Output clock on CS line if CS is active
7272

7373
#define SPI_ERR_OTHER_CONFIG 7001
7474

7575
typedef struct spi_lobo_transaction_t spi_lobo_transaction_t;
76-
typedef void(*transaction_cb_t)(spi_lobo_transaction_t *trans);
76+
typedef void(*spi_lobo_transaction_cb_t)(spi_lobo_transaction_t *trans);
7777

7878
/**
7979
* @brief This is a configuration for a SPI slave device that is connected to one of the SPI buses.
8080
*/
8181
typedef struct {
82-
uint8_t command_bits; ///< Amount of bits in command phase (0-16)
83-
uint8_t address_bits; ///< Amount of bits in address phase (0-64)
84-
uint8_t dummy_bits; ///< Amount of dummy bits to insert between address and data phase
85-
uint8_t mode; ///< SPI mode (0-3)
86-
uint8_t duty_cycle_pos; ///< Duty cycle of positive clock, in 1/256th increments (128 = 50%/50% duty). Setting this to 0 (=not setting it) is equivalent to setting this to 128.
87-
uint8_t cs_ena_pretrans; ///< Amount of SPI bit-cycles the cs should be activated before the transmission (0-16). This only works on half-duplex transactions.
88-
uint8_t cs_ena_posttrans; ///< Amount of SPI bit-cycles the cs should stay active after the transmission (0-16)
89-
int clock_speed_hz; ///< Clock speed, in Hz
90-
int spics_io_num; ///< CS GPIO pin for this device, handled by hardware; set to -1 if not used
91-
int spics_ext_io_num; ///< CS GPIO pin for this device, handled by software (spi_lobo_device_select/spi_lobo_device_deselect); only used if spics_io_num=-1
92-
uint32_t flags; ///< Bitwise OR of SPI_DEVICE_* flags
93-
transaction_cb_t pre_cb; ///< Callback to be called before a transmission is started. This callback from 'spi_lobo_transfer_data' function.
94-
transaction_cb_t post_cb; ///< Callback to be called after a transmission has completed. This callback from 'spi_lobo_transfer_data' function.
95-
uint8_t selected; ///< **INTERNAL** 1 if the device's CS pin is active
82+
uint8_t command_bits; ///< Amount of bits in command phase (0-16)
83+
uint8_t address_bits; ///< Amount of bits in address phase (0-64)
84+
uint8_t dummy_bits; ///< Amount of dummy bits to insert between address and data phase
85+
uint8_t mode; ///< SPI mode (0-3)
86+
uint8_t duty_cycle_pos; ///< Duty cycle of positive clock, in 1/256th increments (128 = 50%/50% duty). Setting this to 0 (=not setting it) is equivalent to setting this to 128.
87+
uint8_t cs_ena_pretrans; ///< Amount of SPI bit-cycles the cs should be activated before the transmission (0-16). This only works on half-duplex transactions.
88+
uint8_t cs_ena_posttrans; ///< Amount of SPI bit-cycles the cs should stay active after the transmission (0-16)
89+
int clock_speed_hz; ///< Clock speed, in Hz
90+
int spics_io_num; ///< CS GPIO pin for this device, handled by hardware; set to -1 if not used
91+
int spics_ext_io_num; ///< CS GPIO pin for this device, handled by software (spi_lobo_device_select/spi_lobo_device_deselect); only used if spics_io_num=-1
92+
uint32_t flags; ///< Bitwise OR of LB_SPI_DEVICE_* flags
93+
spi_lobo_transaction_cb_t pre_cb; ///< Callback to be called before a transmission is started. This callback from 'spi_lobo_transfer_data' function.
94+
spi_lobo_transaction_cb_t post_cb; ///< Callback to be called after a transmission has completed. This callback from 'spi_lobo_transfer_data' function.
95+
uint8_t selected; ///< **INTERNAL** 1 if the device's CS pin is active
9696
} spi_lobo_device_interface_config_t;
9797

9898

99-
#define SPI_TRANS_MODE_DIO (1<<0) ///< Transmit/receive data in 2-bit mode
100-
#define SPI_TRANS_MODE_QIO (1<<1) ///< Transmit/receive data in 4-bit mode
101-
#define SPI_TRANS_MODE_DIOQIO_ADDR (1<<2) ///< Also transmit address in mode selected by SPI_MODE_DIO/SPI_MODE_QIO
102-
#define SPI_TRANS_USE_RXDATA (1<<3) ///< Receive into rx_data member of spi_lobo_transaction_t instead into memory at rx_buffer.
103-
#define SPI_TRANS_USE_TXDATA (1<<4) ///< Transmit tx_data member of spi_lobo_transaction_t instead of data at tx_buffer. Do not set tx_buffer when using this.
99+
#define LB_SPI_TRANS_MODE_DIO (1<<0) ///< Transmit/receive data in 2-bit mode
100+
#define LB_SPI_TRANS_MODE_QIO (1<<1) ///< Transmit/receive data in 4-bit mode
101+
#define LB_SPI_TRANS_MODE_DIOQIO_ADDR (1<<2) ///< Also transmit address in mode selected by SPI_MODE_DIO/SPI_MODE_QIO
102+
#define LB_SPI_TRANS_USE_RXDATA (1<<3) ///< Receive into rx_data member of spi_lobo_transaction_t instead into memory at rx_buffer.
103+
#define LB_SPI_TRANS_USE_TXDATA (1<<4) ///< Transmit tx_data member of spi_lobo_transaction_t instead of data at tx_buffer. Do not set tx_buffer when using this.
104104

105105
/**
106106
* This structure describes one SPI transmission
107107
*/
108108
struct spi_lobo_transaction_t {
109-
uint32_t flags; ///< Bitwise OR of SPI_TRANS_* flags
109+
uint32_t flags; ///< Bitwise OR of LB_SPI_TRANS_* flags
110110
uint16_t command; ///< Command data. Specific length was given when device was added to the bus.
111111
uint64_t address; ///< Address. Specific length was given when device was added to the bus.
112112
size_t length; ///< Total data length to be transmitted to the device, in bits; if 0, no data is transmitted
@@ -281,8 +281,8 @@ void spi_lobo_get_native_pins(int host, int *sdi, int *sdo, int *sck);
281281
* Lengths must be 8-bit multiples!
282282
* If trans->rx_buffer is NULL or trans->rx_length is 0, only transmits data
283283
* If trans->tx_buffer is NULL or trans->length is 0, only receives data
284-
* If the device is in duplex mode (SPI_DEVICE_HALFDUPLEX flag NOT set), data are transmitted and received simultaneously.
285-
* If the device is in half duplex mode (SPI_DEVICE_HALFDUPLEX flag IS set), data are received after transmission
284+
* If the device is in duplex mode (LB_SPI_DEVICE_HALFDUPLEX flag NOT set), data are transmitted and received simultaneously.
285+
* If the device is in half duplex mode (LB_SPI_DEVICE_HALFDUPLEX flag IS set), data are received after transmission
286286
* 'address', 'command' and 'dummy bits' are transmitted before data phase IF set in device's configuration
287287
* and IF 'trans->length' and 'trans->rx_length' are NOT both 0
288288
* If device was not previously selected, it will be selected before transmission and deselected after transmission.

0 commit comments

Comments
 (0)