Implemented Command-Level Interaction with CAN Interface
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
#include "driver/spi_master.h"
|
||||
|
||||
#include "mcp2521.hpp"
|
||||
#include "reg.hpp"
|
||||
|
||||
#define SPI_PIN_CS0 GPIO_NUM_5
|
||||
#define SPI_PIN_SCLK GPIO_NUM_18
|
||||
@@ -32,11 +31,7 @@
|
||||
|
||||
#define EXTERNAL_TRIGGER GPIO_NUM_26
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void app_main() {
|
||||
extern "C" void app_main() {
|
||||
printf("Hello world!\n");
|
||||
|
||||
const gpio_num_t LED_PIN = GPIO_NUM_2;
|
||||
@@ -46,11 +41,11 @@ void app_main() {
|
||||
gpio_set_level(EXTERNAL_TRIGGER, true);
|
||||
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
gpio_set_level(EXTERNAL_TRIGGER, false);
|
||||
|
||||
|
||||
spi_bus_config_t spi_bus;
|
||||
|
||||
MCP2521_SPI_Interface mcp2521_spi(
|
||||
MCP2521_Hardware_Handle_ESP hardware_mcp2521(
|
||||
VSPI_HOST,
|
||||
&spi_bus,
|
||||
SPI_PIN_MOSI,
|
||||
@@ -60,11 +55,16 @@ void app_main() {
|
||||
CAN_INT_PIN
|
||||
);
|
||||
|
||||
mcp2521_spi.reset();
|
||||
printf("%x\n", mcp2521_spi.read_reg(MCP2521_CANCTRL));
|
||||
MCP2521_Command_Interface mcp2521(&hardware_mcp2521);
|
||||
|
||||
|
||||
gpio_set_level(EXTERNAL_TRIGGER, false);
|
||||
printf("CANCTRL: %x\n", mcp2521.read_reg(MCP2521_CANCTRL));
|
||||
printf("RX_STATUS: %x\n", mcp2521.read_rx_status());
|
||||
printf("STATUS: %x\n", mcp2521.read_status());
|
||||
|
||||
uint8_t data[16];
|
||||
mcp2521_spi.read_reg(MCP2521_CANSTAT, data, 16);
|
||||
hardware_mcp2521.read(MCP2521_OP_READ, data, 16, MCP2521_RXB0CTRL);
|
||||
|
||||
for(int i=0; i<0x10; i++) {
|
||||
printf("%x ", i);
|
||||
@@ -79,12 +79,8 @@ void app_main() {
|
||||
bool flag = true;
|
||||
while (true) {
|
||||
gpio_set_level(LED_PIN, flag);
|
||||
flag = dummy_function(flag);
|
||||
flag = !flag;
|
||||
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user