random changes..

new_hw
phail 4 years ago
parent 1c4c038bd6
commit 5ba749f30f
  1. 2
      inc/config.h
  2. 9
      src/control.c
  3. 1
      src/main.c

@ -1,5 +1,7 @@
#pragma once
#include "stm32f1xx_hal.h"
#include <stdint.h>
#include "stm32f1xx_hal_rcc.h"
// ############################### DO-NOT-TOUCH SETTINGS ###############################

@ -8,10 +8,11 @@
TIM_HandleTypeDef TimHandle;
uint8_t ppm_count = 0;
uint32_t timeout = 100;
volatile uint32_t timeout = 100;
uint8_t nunchuck_data[6] = {0};
uint8_t i2cBuffer[2];
uint32_t nunchuckInits = 0;
extern I2C_HandleTypeDef hi2c2;
DMA_HandleTypeDef hdma_i2c2_rx;
@ -97,12 +98,18 @@ void Nunchuck_Init() {
HAL_I2C_Master_Transmit(&hi2c2,0xA4,(uint8_t*)i2cBuffer, 2, 100);
HAL_Delay(10);
setScopeChannel(1, nunchuckInits++);
}
void Nunchuck_Read() {
i2cBuffer[0] = 0x00;
HAL_I2C_Master_Transmit(&hi2c2,0xA4,(uint8_t*)i2cBuffer, 1, 100);
HAL_Delay(5);
// reset control to neutral position
for(int i = 0; i<2;++i)
{
nunchuck_data[i] = 128;
}
if (HAL_I2C_Master_Receive(&hi2c2,0xA4,(uint8_t*)nunchuck_data, 6, 100) == HAL_OK) {
timeout = 0;
} else {

@ -142,6 +142,7 @@ int main(void) {
HAL_ADC_Start(&hadc1);
HAL_ADC_Start(&hadc2);
//boot melody
for (int i = 8; i >= 0; i--) {
buzzerFreq = i;
HAL_Delay(100);

Loading…
Cancel
Save