-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a49a9d
commit ff5e253
Showing
4 changed files
with
89 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
cmake_minimum_required(VERSION 3.22) | ||
|
||
# Pull in SDK (must be before project) | ||
include(../../lib/pico-sdk/pico_sdk_init.cmake) | ||
|
||
project(fram_clear C CXX ASM) | ||
set(CMAKE_C_STANDARD 11) | ||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
# Initialize the SDK | ||
pico_sdk_init() | ||
|
||
add_compile_options( | ||
-Wall | ||
-Wno-format | ||
-Wno-unused-function | ||
) | ||
|
||
add_executable(${PROJECT_NAME} | ||
${PROJECT_NAME}.cpp | ||
) | ||
|
||
add_subdirectory(${PROJECT_SOURCE_DIR}/../../lib/MB85RS-Pico ${CMAKE_BINARY_DIR}/MB85RS-Pico) | ||
|
||
# Include project and library headers | ||
target_include_directories(${PROJECT_NAME} | ||
PRIVATE | ||
${PROJECT_SOURCE_DIR}/../../lib/MB85RS-Pico | ||
) | ||
|
||
# Pull in common dependencies | ||
target_link_libraries(${PROJECT_NAME} | ||
pico_stdlib | ||
MB85RS-Pico | ||
) | ||
|
||
pico_enable_stdio_usb(${PROJECT_NAME} 1) | ||
pico_enable_stdio_uart(${PROJECT_NAME} 0) | ||
|
||
# Create uf2 file | ||
pico_add_uf2_output(${PROJECT_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* @file fram_clear.cpp | ||
* @author csg83 | ||
* | ||
* @brief Clears the contents of FRAM | ||
*/ | ||
|
||
#include "pico/stdlib.h" | ||
#include "mb85rs.hpp" | ||
#include "../../src/pins.hpp" | ||
#include "tusb.h" | ||
#include <cstdio> | ||
|
||
#define BYTES_TO_CLEAR 20 | ||
|
||
MB85RS fram(SPI_PORT, FRAM_CS); | ||
|
||
int main() { | ||
stdio_init_all(); | ||
|
||
gpio_init(FRAM_CS); | ||
gpio_set_dir(FRAM_CS, GPIO_OUT); | ||
|
||
spi_init(SPI_PORT, 125 * 1000000 / 6); | ||
gpio_set_function(SPI_MISO, GPIO_FUNC_SPI); | ||
gpio_set_function(SPI_MOSI, GPIO_FUNC_SPI); | ||
gpio_set_function(SPI_SCK, GPIO_FUNC_SPI); | ||
gpio_put(FRAM_CS, 1); | ||
|
||
while (!tud_cdc_connected()) { | ||
sleep_ms(500); | ||
} | ||
printf("Connected\n"); | ||
|
||
if (!fram.begin()) { | ||
printf("Error: FRAM begin unsuccessful\n"); | ||
} | ||
|
||
uint8_t clear[BYTES_TO_CLEAR] = {0}; | ||
|
||
if (fram.write_bytes(0, clear, BYTES_TO_CLEAR)) { | ||
printf("FRAM clear successful!\n"); | ||
} else { | ||
printf("Error: FRAM clear unsuccessful\n"); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters