Created
December 2, 2018 04:10
-
-
Save mipsparc/cbd9612dbfdb188b62839eda3b7fd38a to your computer and use it in GitHub Desktop.
ブレーキ統合ユニットからボタンやブレーキハンドル角度を読み出すやつ
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
#include "mcc_generated_files/mcc.h" | |
void main(void) | |
{ | |
// initialize the device | |
SYSTEM_Initialize(); | |
// Enable the Global Interrupts | |
INTERRUPT_GlobalInterruptEnable(); | |
// Enable the Peripheral Interrupts | |
INTERRUPT_PeripheralInterruptEnable(); | |
int dinputs = 0; | |
int level = 0; | |
while (1) | |
{ | |
if (EUSART_is_rx_ready()) { | |
level = EUSART_Read(); | |
PWM1_DutyCycleSet(level * 15); | |
PWM1_LoadBufferSet(); | |
} | |
adc_result_t result = ADC1_GetConversion(Brake_ADC); | |
dinputs = IO_RA0_GetValue() << 7 | |
| IO_RA1_GetValue() << 6 | |
| IO_RA2_GetValue() << 5 | |
| IO_RC0_GetValue() << 4 | |
| IO_RC1_GetValue() << 3 | |
| IO_RC2_GetValue() << 2 | |
| IO_RB4_GetValue() << 1 | |
| IO_RB6_GetValue(); | |
printf("%lu,%u,\r\n", (long)result, dinputs); | |
__delay_ms(100); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment