mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-12 02:48:28 -04:00
DataFlash_APM2: private AP_Semaphore* rather than use extern AP_Semaphore_spi3
The AP_Semaphore* argument to the constructor can be null (and is by default for compatibility). Semaphore is only used when non-null.
This commit is contained in:
parent
39be6be363
commit
00243e3c6c
@ -95,9 +95,12 @@ unsigned char DataFlash_APM2::SPI_transfer(unsigned char data)
|
|||||||
{
|
{
|
||||||
unsigned char retval;
|
unsigned char retval;
|
||||||
|
|
||||||
// get spi3 semaphore if required. if failed to get semaphore then just quietly fail
|
// get spi3 semaphore if required. if failed to get semaphore then
|
||||||
if( !AP_Semaphore_spi3.get(this) ) {
|
// just quietly fail
|
||||||
return 0;
|
if ( _semaphore != NULL) {
|
||||||
|
if( !_semaphore->get(this) ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for empty transmit buffer */
|
/* Wait for empty transmit buffer */
|
||||||
@ -110,7 +113,9 @@ unsigned char DataFlash_APM2::SPI_transfer(unsigned char data)
|
|||||||
retval = UDR3;
|
retval = UDR3;
|
||||||
|
|
||||||
// release spi3 semaphore
|
// release spi3 semaphore
|
||||||
AP_Semaphore_spi3.release(this);
|
if ( _semaphore != NULL) {
|
||||||
|
_semaphore->release(this);
|
||||||
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@ -127,11 +132,6 @@ void DataFlash_APM2::CS_active()
|
|||||||
digitalWrite(DF_SLAVESELECT,LOW);
|
digitalWrite(DF_SLAVESELECT,LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constructors ////////////////////////////////////////////////////////////////
|
|
||||||
DataFlash_APM2::DataFlash_APM2()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Public Methods //////////////////////////////////////////////////////////////
|
// Public Methods //////////////////////////////////////////////////////////////
|
||||||
void DataFlash_APM2::Init(void)
|
void DataFlash_APM2::Init(void)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#ifndef __DATAFLASH_APM2_H__
|
#ifndef __DATAFLASH_APM2_H__
|
||||||
#define __DATAFLASH_APM2_H__
|
#define __DATAFLASH_APM2_H__
|
||||||
|
|
||||||
#include <AP_Semaphore.h> // for removing conflict with dataflash on SPI3 bus
|
#include <AP_Semaphore.h>
|
||||||
#include "DataFlash.h"
|
#include "DataFlash.h"
|
||||||
|
|
||||||
class DataFlash_APM2 : public DataFlash_Class
|
class DataFlash_APM2 : public DataFlash_Class
|
||||||
@ -27,8 +27,10 @@ private:
|
|||||||
void BlockErase (uint16_t BlockAdr);
|
void BlockErase (uint16_t BlockAdr);
|
||||||
void ChipErase(void (*delay_cb)(unsigned long));
|
void ChipErase(void (*delay_cb)(unsigned long));
|
||||||
|
|
||||||
|
AP_Semaphore* _semaphore;
|
||||||
public:
|
public:
|
||||||
DataFlash_APM2(); // Constructor
|
DataFlash_APM2(AP_Semaphore* semaphore = NULL) : _semaphore(semaphore) {}
|
||||||
|
|
||||||
void Init();
|
void Init();
|
||||||
void ReadManufacturerID();
|
void ReadManufacturerID();
|
||||||
bool CardInserted();
|
bool CardInserted();
|
||||||
|
Loading…
Reference in New Issue
Block a user