bDodson
February 25, 2023, 3:24am
1
I have managed to take pictures, but I want to temporarily save the image file to the PICO before transmitting the image. How can I write a JPG file from my SPI camera to PICO on-board flash memory? I am using Ardurino IDE, so I prefer C to python code.
Dion
February 27, 2023, 3:15am
2
Hi,
You can use the Pico SDK to write a JPG file. Please refer to the link below.
/**
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <stdio.h>
#include <stdlib.h>
#include "pico/stdlib.h"
#include "hardware/flash.h"
// We're going to erase and reprogram a region 256k from the start of flash.
// Once done, we can access this at XIP_BASE + 256k.
#define FLASH_TARGET_OFFSET (256 * 1024)
const uint8_t *flash_target_contents = (const uint8_t *) (XIP_BASE + FLASH_TARGET_OFFSET);
void print_buf(const uint8_t *buf, size_t len) {
for (size_t i = 0; i < len; ++i) {
This file has been truncated. show original
In addition, if you have to write in the arduino IDE, refer to the class mbed::MBRBlockDevice to write data to flash.
Perfect! Thank you very much.