mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
CC-6 Flash chip working to read ID. Also tweaked how the semaphore for the SPI
bus is used to be a bit safer. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2591 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
2868547e75
commit
c759253b77
@ -236,8 +236,8 @@ TIM4 | RC In 1 | Servo 3 | Servo 2 | Servo 1
|
||||
#define PIOS_GPIO_CLKS { PIOS_GPIO_1_GPIO_CLK }
|
||||
#define PIOS_GPIO_NUM 1
|
||||
|
||||
#define PIOS_FLASH_ENABLE PIOS_GPIO_Off(0)
|
||||
#define PIOS_FLASH_DISABLE PIOS_GPIO_On(0)
|
||||
#define PIOS_FLASH_ENABLE PIOS_GPIO_On(0)
|
||||
#define PIOS_FLASH_DISABLE PIOS_GPIO_Off(0)
|
||||
#define PIOS_ADXL_ENABLE PIOS_SPI_RC_PinSet(PIOS_SPI_ACCEL,0)
|
||||
#define PIOS_ADXL_DISABLE PIOS_SPI_RC_PinSet(PIOS_SPI_ACCEL,1)
|
||||
|
||||
|
@ -23,8 +23,8 @@ void PIOS_ADXL345_ClaimBus()
|
||||
*/
|
||||
void PIOS_ADXL345_ReleaseBus()
|
||||
{
|
||||
PIOS_SPI_ReleaseBus(PIOS_SPI_ACCEL);
|
||||
PIOS_ADXL_DISABLE;
|
||||
PIOS_SPI_ReleaseBus(PIOS_SPI_ACCEL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,17 +9,21 @@
|
||||
|
||||
#include "pios.h"
|
||||
#include "pios_flash_w25x.h"
|
||||
#include "pios_adxl345.h"
|
||||
|
||||
void PIOS_FLASH_W25X_ClaimBus()
|
||||
{
|
||||
PIOS_SPI_ClaimBus(PIOS_SPI_FLASH);
|
||||
PIOS_ADXL_DISABLE;
|
||||
PIOS_FLASH_ENABLE;
|
||||
PIOS_DELAY_WaituS(1);
|
||||
}
|
||||
|
||||
void PIOS_FLASH_W25X_ReleaseBus()
|
||||
{
|
||||
PIOS_SPI_ReleaseBus(PIOS_SPI_FLASH);
|
||||
PIOS_ADXL_DISABLE;
|
||||
PIOS_FLASH_DISABLE;
|
||||
PIOS_SPI_ReleaseBus(PIOS_SPI_FLASH);
|
||||
}
|
||||
|
||||
void PIOS_FLASH_W25X_Init()
|
||||
@ -41,6 +45,19 @@ uint8_t PIOS_FLASH_ReadStatus()
|
||||
return in[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Read the status register from flash chip and return it
|
||||
*/
|
||||
uint8_t PIOS_FLASH_ReadID()
|
||||
{
|
||||
PIOS_FLASH_W25X_ClaimBus();
|
||||
uint8_t out[] = {W25X_DEVICE_ID, 0, 0, 0, 0, 0};
|
||||
uint8_t in[6];
|
||||
PIOS_SPI_TransferBlock(PIOS_SPI_FLASH,out,in,sizeof(out),NULL);
|
||||
PIOS_FLASH_W25X_ReleaseBus();
|
||||
return in[5];
|
||||
}
|
||||
|
||||
void PIOS_FLASH_W25X_WriteData(uint32_t addr, uint8_t * data, uint16_t len)
|
||||
{
|
||||
}
|
||||
|
@ -13,9 +13,10 @@
|
||||
#define W25X_WRITE_STATUS 0x01
|
||||
#define W25X_READ_DATA 0x03
|
||||
#define W25X_FAST_READ 0x0b
|
||||
#define W25X_DEVICE_ID 0x92
|
||||
#define W25X_DEVICE_ID 0x90
|
||||
|
||||
void PIOS_FLASH_W25X_Init();
|
||||
uint8_t PIOS_FLASH_ReadStatus();
|
||||
uint8_t PIOS_FLASH_ReadID();
|
||||
void PIOS_FLASH_W25X_WriteData(uint32_t addr, uint8_t * data, uint16_t len);
|
||||
void PIOS_FLASH_W25X_ReadData(uint32_t addr, uint8_t * data, uint16_t len);
|
||||
void PIOS_FLASH_W25X_ReadData(uint32_t addr, uint8_t * data, uint16_t len);
|
||||
|
Loading…
x
Reference in New Issue
Block a user