First implementation of read write

This commit is contained in:
Hierophect 2019-09-27 17:59:55 -04:00
parent ad33950966
commit d7443fce54
5 changed files with 17 additions and 4 deletions

View File

@ -4,6 +4,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2016 Scott Shawcroft
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -32,6 +33,7 @@
#include "shared-bindings/microcontroller/__init__.h"
#include "boards/board.h"
#include "supervisor/shared/translate.h"
#include "common-hal/microcontroller/Pin.h"
STATIC bool reserved_spi[6];
@ -277,16 +279,21 @@ void common_hal_busio_spi_unlock(busio_spi_obj_t *self) {
bool common_hal_busio_spi_write(busio_spi_obj_t *self,
const uint8_t *data, size_t len) {
return 0;
HAL_StatusTypeDef result = HAL_SPI_Transmit (&self->handle, (uint8_t *)data, (uint16_t)len, 2);
return result == HAL_OK ? 0 : 1;
}
bool common_hal_busio_spi_read(busio_spi_obj_t *self,
uint8_t *data, size_t len, uint8_t write_value) {
return 0;
HAL_StatusTypeDef result = HAL_SPI_Receive (&self->handle, data, (uint16_t)len, 2);
return result == HAL_OK ? 0 : 1;
}
bool common_hal_busio_spi_transfer(busio_spi_obj_t *self, uint8_t *data_out, uint8_t *data_in, size_t len) {
return 0;
bool common_hal_busio_spi_transfer(busio_spi_obj_t *self,
uint8_t *data_out, uint8_t *data_in, size_t len) {
HAL_StatusTypeDef result = HAL_SPI_TransmitReceive (&self->handle,
data_out, data_in, (uint16_t)len,2);
return result == HAL_OK ? 0 : 1;
}
uint32_t common_hal_busio_spi_get_frequency(busio_spi_obj_t* self) {

View File

@ -4,6 +4,7 @@
* The MIT License (MIT)
*
* Copyright (c) 2016 Scott Shawcroft
* Copyright (c) 2019 Lucian Copeland for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@ -23,6 +23,7 @@ CIRCUITPY_BUSIO = 1
CIRCUITPY_TIME = 1
CIRCUITPY_OS = 1
CIRCUITPY_STRUCT = 1
CIRCUITPY_MATH = 1
#ifeq ($(MCU_SUB_VARIANT), stm32f412zx)
#endif

View File

@ -164,7 +164,9 @@ bool supervisor_flash_write_block(const uint8_t *src, uint32_t block) {
if (sector_size == 0x4000) {
sector_copy = sector_copy_16;
} else if (sector_size == 0x10000) {
#ifdef sector_copy_64
sector_copy = sector_copy_64;
#endif
} else {
mp_printf(&mp_plat_print, "Error: flash sector incorrect size");
}

View File

@ -32,6 +32,7 @@
#include "common-hal/microcontroller/Pin.h"
#include "common-hal/busio/I2C.h"
#include "common-hal/busio/SPI.h"
#include "stm32f4/clocks.h"
#include "stm32f4/gpio.h"
@ -55,6 +56,7 @@ safe_mode_t port_init(void) {
void reset_port(void) {
reset_all_pins();
i2c_reset();
spi_reset();
}
void reset_to_bootloader(void) {