-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
72 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#define ADC_CELL 0 | ||
#define ADC_SYS 3 | ||
|
||
/** | ||
** Return ADC value in Volt | ||
** | ||
** \return a float containing the ADC value. | ||
*/ | ||
float adc_read_V(int ch) | ||
{ | ||
const float conversion_factor = 3.3f / (1 << 12) * 2.0; | ||
adc_select_input(ch); | ||
uint16_t result = adc_read(); | ||
return result * conversion_factor; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#define LED0_PIN 19 | ||
#define LED1_PIN 20 | ||
#define LED2_PIN 21 | ||
#define LED3_PIN 22 | ||
|
||
|
||
void led_set(uint led) | ||
{ | ||
gpio_put(led, 1); | ||
} | ||
|
||
void led_reset(uint led) | ||
{ | ||
gpio_put(led, 0); | ||
} | ||
|
||
void led_init(uint led) | ||
{ | ||
gpio_init(led); | ||
gpio_set_dir(led, GPIO_OUT); | ||
} | ||
|
||
|
||
uint led_toggle(uint led) | ||
{ | ||
uint val = gpio_get(led); | ||
val = (~val & 0x1); | ||
gpio_put(led, val); | ||
return val; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#pragma once | ||
#include <hardware/uart.h> | ||
|
||
|
||
template< int ID > uart_inst_t* uart_id(); | ||
template<> uart_inst_t* uart_id<0> () {return uart0;} | ||
template<> uart_inst_t* uart_id<1> () {return uart1;} | ||
|
||
template< int ID > unsigned int uart_irq(); | ||
template<> unsigned int uart_irq<0> () {return UART0_IRQ;} | ||
template<> unsigned int uart_irq<1> () {return UART1_IRQ;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters