Skip to content

Commit

Permalink
Adding Lpc17xx Pulse Capture Config Structures
Browse files Browse the repository at this point in the history
  • Loading branch information
HuangDave authored and kammce committed Nov 18, 2019
1 parent 6259b7c commit 9769186
Showing 1 changed file with 107 additions and 0 deletions.
107 changes: 107 additions & 0 deletions library/L1_Peripheral/lpc17xx/pulse_capture.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#pragma once

#include "L1_Peripheral/interrupt.hpp"
#include "L1_Peripheral/lpc17xx/pin.hpp"
#include "L1_Peripheral/lpc17xx/system_controller.hpp"
#include "L1_Peripheral/lpc17xx/timer.hpp"
#include "L1_Peripheral/lpc40xx/pulse_capture.hpp"

namespace sjsu::lpc17xx
{
// The LPC40xx driver is compatible with the lpc17xx peripheral
using ::sjsu::lpc40xx::PulseCapture;

struct PulseCaptureChannel
{
private:
inline static lpc40xx::PulseCapture::CaptureIsr timer0_isr = nullptr;
inline static lpc40xx::PulseCapture::CaptureChannelNumber
timer0_channel_number =
lpc40xx::PulseCapture::CaptureChannelNumber::kChannel1;
inline static const Pin kCapture0Channel0Pin = Pin(1, 26);
inline static const Pin kCapture0Channel1Pin = Pin(1, 27);
inline static const lpc40xx::PulseCapture::CaptureChannelPartial_t
kTimerPartial0 = { .timer_register =
reinterpret_cast<lpc40xx::LPC_TIM_TypeDef *>(
LPC_TIM0),
.power_id = SystemController::Peripherals::kTimer0,
.irq = static_cast<lpc40xx::IRQn>(IRQn::TIMER0_IRQn),
.user_callback = &timer0_isr,
.capture_pin0 = kCapture0Channel0Pin,
.capture_pin1 = kCapture0Channel1Pin,
.channel_number = &timer0_channel_number };

inline static lpc40xx::PulseCapture::CaptureIsr timer1_isr = nullptr;
inline static lpc40xx::PulseCapture::CaptureChannelNumber
timer1_channel_number =
lpc40xx::PulseCapture::CaptureChannelNumber::kChannel1;
inline static const Pin kCapture1Channel0Pin = Pin(1, 18);
inline static const Pin kCapture1Channel1Pin = Pin(1, 19);
inline static const lpc40xx::PulseCapture::CaptureChannelPartial_t
kTimerPartial1 = { .timer_register =
reinterpret_cast<lpc40xx::LPC_TIM_TypeDef *>(
LPC_TIM1),
.power_id = SystemController::Peripherals::kTimer1,
.irq = static_cast<lpc40xx::IRQn>(IRQn::TIMER1_IRQn),
.user_callback = &timer1_isr,
.capture_pin0 = kCapture1Channel0Pin,
.capture_pin1 = kCapture1Channel1Pin,
.channel_number = &timer1_channel_number };

inline static lpc40xx::PulseCapture::CaptureIsr timer2_isr = nullptr;
inline static lpc40xx::PulseCapture::CaptureChannelNumber
timer2_channel_number =
lpc40xx::PulseCapture::CaptureChannelNumber::kChannel1;
inline static const Pin kCapture2Channel0Pin = Pin(0, 4);
inline static const Pin kCapture2Channel1Pin = Pin(0, 5);
inline static const lpc40xx::PulseCapture::CaptureChannelPartial_t
kTimerPartial2 = { .timer_register =
reinterpret_cast<lpc40xx::LPC_TIM_TypeDef *>(
LPC_TIM2),
.power_id = SystemController::Peripherals::kTimer2,
.irq = static_cast<lpc40xx::IRQn>(IRQn::TIMER2_IRQn),
.user_callback = &timer2_isr,
.capture_pin0 = kCapture2Channel0Pin,
.capture_pin1 = kCapture2Channel1Pin,
.channel_number = &timer2_channel_number };

inline static lpc40xx::PulseCapture::CaptureIsr timer3_isr = nullptr;
inline static lpc40xx::PulseCapture::CaptureChannelNumber
timer3_channel_number =
lpc40xx::PulseCapture::CaptureChannelNumber::kChannel1;
inline static const Pin kCapture3Channel0Pin = Pin(0, 23);
inline static const Pin kCapture3Channel1Pin = Pin(0, 24);
inline static const lpc40xx::PulseCapture::CaptureChannelPartial_t
kTimerPartial3 = { .timer_register =
reinterpret_cast<lpc40xx::LPC_TIM_TypeDef *>(
LPC_TIM3),
.power_id = SystemController::Peripherals::kTimer3,
.irq = static_cast<lpc40xx::IRQn>(IRQn::TIMER3_IRQn),
.user_callback = &timer3_isr,
.capture_pin0 = kCapture3Channel0Pin,
.capture_pin1 = kCapture3Channel1Pin,
.channel_number = &timer3_channel_number };

public:
/// Structure that defines the capture channels associated with timer 0
inline static const lpc40xx::PulseCapture::CaptureChannel_t kCaptureTimer0 = {
.channel = kTimerPartial0,
.isr = lpc40xx::PulseCapture::TimerHandler<kTimerPartial0>
};
/// Structure that defines the capture channels associated with timer 1
inline static const lpc40xx::PulseCapture::CaptureChannel_t kCaptureTimer1 = {
.channel = kTimerPartial1,
.isr = lpc40xx::PulseCapture::TimerHandler<kTimerPartial1>
};
/// Structure that defines the capture channels associated with timer 2
inline static const lpc40xx::PulseCapture::CaptureChannel_t kCaptureTimer2 = {
.channel = kTimerPartial2,
.isr = lpc40xx::PulseCapture::TimerHandler<kTimerPartial2>
};
/// Structure that defines the capture channels associated with timer 3
inline static const lpc40xx::PulseCapture::CaptureChannel_t kCaptureTimer3 = {
.channel = kTimerPartial3,
.isr = lpc40xx::PulseCapture::TimerHandler<kTimerPartial3>
};
};
}; // namespace sjsu::lpc17xx

0 comments on commit 9769186

Please sign in to comment.