Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ブレーキ統合ユニットからボタンやブレーキハンドル角度を読み出すやつ
#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
You can’t perform that action at this time.