Fixed spacing and comment annotations around namespace and extern declarations (#587)

This commit is contained in:
Tyler Veness
2017-08-23 22:07:46 -07:00
committed by Peter Johnson
parent f151892db5
commit a4e781a231
34 changed files with 94 additions and 26 deletions

View File

@@ -13,6 +13,7 @@
using namespace hal;
extern "C" {
/**
* Is the channel attached to an accumulator.
*
@@ -193,4 +194,5 @@ void HAL_GetAccumulatorOutput(HAL_AnalogInputHandle analogPortHandle,
*value = output.Value;
*count = output.Count;
}
}
} // extern "C"

View File

@@ -15,13 +15,15 @@
#include "HAL/handles/IndexedHandleResource.h"
namespace {
struct AnalogGyro {
HAL_AnalogInputHandle handle;
double voltsPerDegreePerSecond;
double offset;
int32_t center;
};
}
} // namespace
static constexpr uint32_t kOversampleBits = 10;
static constexpr uint32_t kAverageBits = 0;
@@ -41,6 +43,7 @@ static void Wait(double seconds) {
}
extern "C" {
HAL_GyroHandle HAL_InitializeAnalogGyro(HAL_AnalogInputHandle analogHandle,
int32_t* status) {
if (!HAL_IsAccumulatorChannel(analogHandle, status)) {
@@ -238,4 +241,5 @@ int32_t HAL_GetAnalogGyroCenter(HAL_GyroHandle handle, int32_t* status) {
}
return gyro->center;
}
}
} // extern "C"

View File

@@ -20,6 +20,7 @@
using namespace hal;
extern "C" {
/**
* Initialize the analog input port using the given port object.
*
@@ -382,4 +383,5 @@ int32_t HAL_GetAnalogOffset(HAL_AnalogInputHandle analogPortHandle,
0, port->channel, status); // XXX: aiSystemIndex == 0?
return offset;
}
}
} // extern "C"

View File

@@ -15,6 +15,7 @@
#include "PortsInternal.h"
namespace hal {
priority_recursive_mutex analogRegisterWindowMutex;
std::unique_ptr<tAI> analogInputSystem;
std::unique_ptr<tAO> analogOutputSystem;
@@ -118,4 +119,5 @@ void setAnalogSampleRate(double samplesPerSecond, int32_t* status) {
void setAnalogNumChannelsToActivate(int32_t channels) {
analogNumChannelsToActivate = channels;
}
} // namespace hal

View File

@@ -18,6 +18,7 @@
#include "PortsInternal.h"
namespace hal {
constexpr int32_t kTimebase = 40000000; ///< 40 MHz clock
constexpr int32_t kDefaultOversampleBits = 0;
constexpr int32_t kDefaultAverageBits = 7;
@@ -43,4 +44,5 @@ int32_t getAnalogNumChannelsToActivate(int32_t* status);
void setAnalogNumChannelsToActivate(int32_t channels);
void setAnalogSampleRate(double samplesPerSecond, int32_t* status);
void initializeAnalog(int32_t* status);
} // namespace hal

View File

@@ -16,10 +16,12 @@
using namespace hal;
namespace {
struct AnalogOutput {
uint8_t channel;
};
}
} // namespace
static IndexedHandleResource<HAL_AnalogOutputHandle, AnalogOutput,
kNumAnalogOutputs, HAL_HandleEnum::AnalogOutput>
@@ -103,4 +105,5 @@ double HAL_GetAnalogOutput(HAL_AnalogOutputHandle analogOutputHandle,
return rawValue * 5.0 / 0x1000;
}
}
} // extern "C"

View File

@@ -17,12 +17,14 @@
using namespace hal;
namespace {
struct AnalogTrigger {
std::unique_ptr<tAnalogTrigger> trigger;
HAL_AnalogInputHandle analogHandle;
uint8_t index;
};
}
} // namespace
static LimitedHandleResource<HAL_AnalogTriggerHandle, AnalogTrigger,
kNumAnalogTriggers, HAL_HandleEnum::AnalogTrigger>
@@ -203,4 +205,5 @@ HAL_Bool HAL_GetAnalogTriggerOutput(HAL_AnalogTriggerHandle analogTriggerHandle,
}
return result;
}
}
} // extern "C"

View File

@@ -190,4 +190,5 @@ HAL_Bool HAL_GetCompressorNotConnectedFault(
return value;
}
} // extern "C"

View File

@@ -12,7 +12,9 @@
using namespace hal;
extern "C" {
int32_t HAL_GetSystemClockTicksPerMicrosecond(void) {
return kSystemClockTicksPerMicrosecond;
}
}
} // extern "C"

View File

@@ -10,5 +10,7 @@
#include <stdint.h>
namespace hal {
constexpr int32_t kSystemClockTicksPerMicrosecond = 40;
}
} // namespace hal

View File

@@ -16,17 +16,20 @@
using namespace hal;
namespace {
struct Counter {
std::unique_ptr<tCounter> counter;
uint8_t index;
};
}
} // namespace
static LimitedHandleResource<HAL_CounterHandle, Counter, kNumCounters,
HAL_HandleEnum::Counter>
counterHandles;
extern "C" {
HAL_CounterHandle HAL_InitializeCounter(HAL_Counter_Mode mode, int32_t* index,
int32_t* status) {
auto handle = counterHandles.Allocate();
@@ -463,4 +466,5 @@ void HAL_SetCounterReverseDirection(HAL_CounterHandle counterHandle,
HAL_SetCounterDownSourceEdge(counterHandle, false, true, status);
}
}
}
} // extern "C"

View File

@@ -529,4 +529,5 @@ int64_t HAL_GetFilterPeriod(int32_t filterIndex, int32_t* status) {
}
return hdrPeriod;
}
}
} // extern "C"

View File

@@ -21,6 +21,7 @@
#include "PortsInternal.h"
namespace hal {
// Create a mutex to protect changes to the DO PWM config
priority_recursive_mutex digitalPwmMutex;
@@ -157,4 +158,5 @@ bool remapDigitalSource(HAL_Handle digitalSourceHandle,
return false;
}
}
} // namespace hal

View File

@@ -20,6 +20,7 @@
#include "PortsInternal.h"
namespace hal {
/**
* MXP channels when used as digital output PWM are offset from actual value
*/
@@ -86,4 +87,5 @@ bool remapDigitalSource(HAL_Handle digitalSourceHandle,
int32_t remapSPIChannel(int32_t channel);
int32_t remapMXPPWMChannel(int32_t channel);
int32_t remapMXPChannel(int32_t channel);
} // namespace hal

View File

@@ -445,4 +445,5 @@ int32_t HAL_GetEncoderFPGAIndex(HAL_EncoderHandle encoderHandle,
}
return encoder->GetFPGAIndex();
}
}
} // extern "C"

View File

@@ -12,6 +12,7 @@
#include "HAL/Encoder.h"
namespace hal {
class Encoder {
public:
Encoder(HAL_Handle digitalSourceHandleA,
@@ -73,4 +74,5 @@ class Encoder {
int32_t m_encodingScale;
};
} // namespace hal

View File

@@ -16,11 +16,13 @@
using namespace hal;
namespace {
struct Encoder {
std::unique_ptr<tEncoder> encoder;
uint8_t index;
};
}
} // namespace
static const double DECODING_SCALING_FACTOR = 0.25;
@@ -29,6 +31,7 @@ static LimitedHandleResource<HAL_FPGAEncoderHandle, Encoder, kNumEncoders,
fpgaEncoderHandles;
extern "C" {
HAL_FPGAEncoderHandle HAL_InitializeFPGAEncoder(
HAL_Handle digitalSourceHandleA, HAL_AnalogTriggerType analogTriggerTypeA,
HAL_Handle digitalSourceHandleB, HAL_AnalogTriggerType analogTriggerTypeB,
@@ -293,4 +296,5 @@ void HAL_SetFPGAEncoderIndexSource(HAL_FPGAEncoderHandle fpgaEncoderHandle,
encoder->encoder->writeConfig_IndexActiveHigh(activeHigh, status);
encoder->encoder->writeConfig_IndexEdgeSensitive(edgeSensitive, status);
}
}
} // extern "C"

View File

@@ -13,6 +13,7 @@
#include "HAL/Types.h"
extern "C" {
HAL_FPGAEncoderHandle HAL_InitializeFPGAEncoder(
HAL_Handle digitalSourceHandleA, HAL_AnalogTriggerType analogTriggerTypeA,
HAL_Handle digitalSourceHandleB, HAL_AnalogTriggerType analogTriggerTypeB,
@@ -44,4 +45,5 @@ void HAL_SetFPGAEncoderIndexSource(HAL_FPGAEncoderHandle fpgaEncoderHandle,
HAL_AnalogTriggerType analogTriggerType,
HAL_Bool activeHigh, HAL_Bool edgeSensitive,
int32_t* status);
}
} // extern "C"

View File

@@ -31,6 +31,7 @@ static hal::priority_mutex newDSDataAvailableMutex;
static int newDSDataAvailableCounter{0};
extern "C" {
int32_t HAL_SetErrorData(const char* errors, int32_t errorsLength,
int32_t waitMs) {
return setErrorData(errors, errorsLength, waitMs);

View File

@@ -26,6 +26,7 @@ static HAL_DigitalHandle i2CMXPDigitalHandle1 = HAL_kInvalidHandle;
static HAL_DigitalHandle i2CMXPDigitalHandle2 = HAL_kInvalidHandle;
extern "C" {
/*
* Initialize the I2C port. Opens the port if necessary and saves the handle.
* If opening the MXP port, also sets up the channel functions appropriately
@@ -180,4 +181,5 @@ void HAL_CloseI2C(HAL_I2CPort port) {
}
return;
}
}
} // extern "C"

View File

@@ -21,6 +21,7 @@
using namespace hal;
namespace {
struct Interrupt {
std::unique_ptr<tInterrupt> anInterrupt;
std::unique_ptr<tInterruptManager> manager;

View File

@@ -34,6 +34,7 @@ static std::unique_ptr<tInterruptManager> notifierManager;
static uint64_t closestTrigger = UINT64_MAX;
namespace {
struct Notifier {
std::shared_ptr<Notifier> prev, next;
void* param;
@@ -87,6 +88,7 @@ class NotifierThreadOwner : public wpi::SafeThreadOwner<NotifierThread> {
void* m_param;
};
} // namespace
static std::shared_ptr<Notifier> notifiers;

View File

@@ -229,4 +229,5 @@ void HAL_ClearOSSerial(HAL_SerialPort port, int32_t* status) {
void HAL_CloseOSSerial(HAL_SerialPort port, int32_t* status) {
close(portHandles[port]);
}
}
} // extern "C"

View File

@@ -13,6 +13,7 @@
#include "PortsInternal.h"
namespace hal {
std::unique_ptr<PCM> PCM_modules[kNumPCMModules];
void initializePCM(int32_t module, int32_t* status) {
@@ -24,4 +25,5 @@ void initializePCM(int32_t module, int32_t* status) {
PCM_modules[module] = std::make_unique<PCM>(module);
}
}
} // namespace hal

View File

@@ -18,6 +18,7 @@
#include "ctre/PCM.h"
namespace hal {
extern std::unique_ptr<PCM> PCM_modules[kNumPCMModules];
static inline bool checkPCMInit(int32_t module, int32_t* status) {
@@ -33,4 +34,5 @@ static inline bool checkPCMInit(int32_t module, int32_t* status) {
}
void initializePCM(int32_t module, int32_t* status);
} // namespace hal

View File

@@ -449,4 +449,5 @@ int32_t HAL_GetLoopTiming(int32_t* status) {
if (*status != 0) return 0;
return pwmSystem->readLoopTiming(status);
}
}
} // extern "C"

View File

@@ -12,6 +12,7 @@
using namespace hal;
extern "C" {
int32_t HAL_GetNumAccumulators(void) { return kNumAccumulators; }
int32_t HAL_GetNumAnalogTriggers(void) { return kNumAnalogTriggers; }
int32_t HAL_GetNumAnalogInputs(void) { return kNumAnalogInputs; }
@@ -30,4 +31,5 @@ int32_t HAL_GetNumPCMModules(void) { return kNumPCMModules; }
int32_t HAL_GetNumSolenoidChannels(void) { return kNumSolenoidChannels; }
int32_t HAL_GetNumPDPModules(void) { return kNumPDPModules; }
int32_t HAL_GetNumPDPChannels(void) { return kNumPDPChannels; }
}
} // extern "C"

View File

@@ -12,6 +12,7 @@
#include "HAL/ChipObject.h"
namespace hal {
constexpr int32_t kNumAccumulators = tAccumulator::kNumSystems;
constexpr int32_t kNumAnalogTriggers = tAnalogTrigger::kNumSystems;
constexpr int32_t kNumAnalogInputs = 8;
@@ -34,4 +35,5 @@ constexpr int32_t kNumPCMModules = 63;
constexpr int32_t kNumSolenoidChannels = 8;
constexpr int32_t kNumPDPModules = 63;
constexpr int32_t kNumPDPChannels = 16;
} // namespace hal

View File

@@ -14,11 +14,13 @@
using namespace hal;
namespace {
struct Relay {
uint8_t channel;
bool fwd;
};
}
} // namespace
static IndexedHandleResource<HAL_RelayHandle, Relay, kNumRelayChannels,
HAL_HandleEnum::Relay>
@@ -28,6 +30,7 @@ static IndexedHandleResource<HAL_RelayHandle, Relay, kNumRelayChannels,
static priority_recursive_mutex digitalRelayMutex;
extern "C" {
HAL_RelayHandle HAL_InitializeRelayPort(HAL_PortHandle portHandle, HAL_Bool fwd,
int32_t* status) {
initializeDigital(status);
@@ -131,4 +134,5 @@ HAL_Bool HAL_GetRelay(HAL_RelayHandle relayPortHandle, int32_t* status) {
return (relays & (1 << port->channel)) != 0;
}
}
} // extern "C"

View File

@@ -670,4 +670,5 @@ void HAL_GetSPIAccumulatorOutput(HAL_SPIPort port, int64_t* value,
*value = accum->value;
*count = accum->count;
}
}
} // extern "C"

View File

@@ -18,11 +18,13 @@
#include "ctre/PCM.h"
namespace {
struct Solenoid {
uint8_t module;
uint8_t channel;
};
}
} // namespace
using namespace hal;

View File

@@ -13,6 +13,7 @@
#include "HAL/Errors.h"
extern "C" {
/**
* Get the thread priority for the specified thread.
*
@@ -119,4 +120,5 @@ HAL_Bool HAL_SetCurrentThreadPriority(HAL_Bool realTime, int32_t priority,
auto thread = pthread_self();
return HAL_SetThreadPriority(&thread, realTime, priority, status);
}
}
} // extern "C"

View File

@@ -22,6 +22,7 @@ constexpr const char* OnboardResourceOS = "/dev/ttyS0";
constexpr const char* MxpResourceOS = "/dev/ttyS1";
namespace hal {
std::string SerialHelper::m_usbNames[2]{"", ""};
priority_mutex SerialHelper::m_nameMutex;

View File

@@ -15,4 +15,5 @@ int GetThreadPriority(std::thread& thread, bool* isRealTime);
int GetCurrentThreadPriority(bool* isRealTime);
bool SetThreadPriority(std::thread& thread, bool realTime, int priority);
bool SetCurrentThreadPriority(bool realTime, int priority);
} // namespace frc