Skip to content

Commit

Permalink
DualTachyon-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr022 committed Aug 1, 2023
1 parent 74da1c2 commit bce9c42
Show file tree
Hide file tree
Showing 14 changed files with 784 additions and 272 deletions.
18 changes: 18 additions & 0 deletions libs/k5_uv_system/hardware/adc.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once
#include "registers.hpp"
#include "system.hpp"

namespace Adc
{
inline unsigned short ReadSingleChannelSync(unsigned char u8Channel)
{
ADC->ADC_START |= 1;

while(!(ADC->CHANNEL[u8Channel].STAT & 1))
{
}

ADC->ADC_IF = 1 << u8Channel;
return ADC->CHANNEL[u8Channel].DATA & 0xFFF;
}
};
21 changes: 21 additions & 0 deletions libs/k5_uv_system/registers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,24 @@ struct TSysCon
unsigned int PLL_ST;
};

struct TAdc
{
unsigned int ADC_CFG;
unsigned int ADC_START;
unsigned int ADC_IE;
unsigned int ADC_IF;
struct
{
unsigned int STAT;
unsigned int DATA;
}CHANNEL[16];
unsigned int ADC_FIFO_STAT;
unsigned int ADC_FIFO_DATA;
unsigned int EXTTRIG_SEL;
unsigned int ADC_CALIB_OFFSET;
unsigned int ADC_CALIB_KD;
};

#define GPIO_BASE 0x400B0000
#define GPIO ((TPort*)GPIO_BASE)
#define __BKPT(value) __asm volatile ("bkpt "#value)
Expand Down Expand Up @@ -94,4 +112,7 @@ struct TSysCon
#define SYSCON_BASE 0x40000000
#define SYSCON ((TSysCon*)SYSCON_BASE)

#define ADC_BASE 0x400BA000
#define ADC ((TAdc*)ADC_BASE)


Loading

0 comments on commit bce9c42

Please sign in to comment.