Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of priustroller_current by
main.cpp
- Committer:
- nki
- Date:
- 2015-03-15
- Revision:
- 30:2b6d426f3bfc
- Parent:
- 29:cb03760ba9ea
- Child:
- 31:86b87913d8e1
File content as of revision 30:2b6d426f3bfc:
#include "includes.h"
#include "transforms.h"
#include "filters.h"
#include "context.h"
#include "core.h"
#include "meta.h"
#include "sensors.h"
#include "callbacks.h"
volatile unsigned short global_ib, global_ic;
uint32_t channel_ib, channel_ic;
extern "C" void TIM2_Derpy_Handler()
{
TIM2->SR &= ~1;
ADC1->SQR1 &= ~ADC_SQR1_L;
ADC1->SQR3 = 0;
ADC1->SQR3 |= channel_ib;
ADC1->CR2 |= ADC_CR2_SWSTART;
while ((ADC1->SR & 2) == 0){}
global_ib = ADC1->DR;
ADC1->SQR3 = 0;
ADC1->SQR3 |= channel_ic;
ADC1->CR2 |= ADC_CR2_SWSTART;
while ((ADC1->SR & 2) == 0){}
global_ic = ADC1->DR;
}
int main() {
NVIC_EnableIRQ(TIM2_IRQn);
NVIC_SetVector(TIM2_IRQn, (uint32_t)TIM2_Derpy_Handler);
Context *context = new Context();
context->ConfigureOutputs(D6, D13, D3, D8);
context->ConfigurePositionSensor(A4, A5, 0.249f, 0.497f, 0.231f, 0.499f, 205.0f);
context->ConfigureIdPidController(0.0000f, 0.0f, 0.0f, 5.0f, -5.0f);
context->ConfigureIqPidController(0.0001f, 0.1f, 0.0f, 5.0f, -5.0f);
context->ConfigureThrottle(A0, 0.8f, 3.0f);
context->ConfigureCurrentSensors(A1, A2, 0.01f, 0.7f); // I guess this configures the ADCs or something
context->ConfigureReference(5.0f);
context->ConfigureDebugger(2, 1000);
context->AttachCallBack(&fast, 5000);
context->AttachCallBack(&slow, 10);
context->AttachCallBack(&debug, 10);
context->AttachCallBack(&log, 500);
context->InitData();
context->Start();
}
