Skip to content

First System Integration Merge#14

Open
spressomartini wants to merge 7 commits intomasterfrom
eng/filter_merge
Open

First System Integration Merge#14
spressomartini wants to merge 7 commits intomasterfrom
eng/filter_merge

Conversation

@spressomartini
Copy link
Copy Markdown
Contributor

This is one ain't pretty.
Merges:

  • Multiprocessing
  • Sensor Read
  • Sensor Fusion
  • An entry point of flight control algorithms

Work to be done:

  • Servo code needs a refactor.

Copy link
Copy Markdown
Contributor

@PyroAVR PyroAVR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really should be a demo merge. We should discuss whether this is really "quality enough" for a merge into master, or if this is really a demo commit that needs cleanup before getting merged into master.

.rx_pcr = &(PORTB->PCR[16]),
.tx_pcr = &(PORTB->PCR[17]),
.rx_pcr = &(PORTA->PCR[1]),
.tx_pcr = &(PORTA->PCR[2]),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we should have left these hunks out, and include them only on a demo branch, since during normal debugging we're going to want the multiplexed OpenSDA + UART streams.

.ct_pcr = 0,
.rx_alt = 3,
.tx_alt = 3,
.rx_alt = 2,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

.port_clock_gate_base = &(SIM->SCGC5),
.uart_clock_gate_mask = SIM_SCGC4_UART0_MASK,
.port_clock_gate_mask = SIM_SCGC5_PORTB_MASK,
.port_clock_gate_mask = SIM_SCGC5_PORTA_MASK,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

*/
void servo_init_io() {
// Enable clock on PORT C
SIM -> SCGC5 |= SIM_SCGC5_PORTC_MASK;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

engage s p a c e t e x t

// Timer Overflow Interrupt Enable
FTM3->SC = FTM_SC_PS(5) | FTM_SC_CLKS(1) | FTM_SC_TOIE_MASK;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this definitely needs a refactor.

  • the code here should have Sabrina's name on it, so we need to figure out how to fix that without merging this.
  • it should be re-named as an FTM driver - the question is whether it is worthwhile for the time being, or will this be "good enough" and we can just fix it later if we ever get to it?
  • It would be nice to at least make this able to use any FTM module, not just the ones specifically connected to the board.

q3 += (qa * gz + qb * gy - qc * gx);

// Normalise quaternion
recipNorm = invSqrt(q0 * q0 + q1 * q1 + q2 * q2 + q3 * q3);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we still using this?

schedule_process(&process_table, &flight_ctrl_app);

return 0;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to rename this file, because there may be multiple "mains" that we want - configurations of many processes.

pcb_t sensor_fusion_app;
uint32_t sensor_fusion_stack[SENSOR_FUSION_STACK_SIZE];

int sensor_fusion_main(void) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs - I know what this does, but it would be nice to have it written down.

bool i2c_free;

/* initialize the sensor offsets */
goffx = GYRO_OFFSET_X;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should document where these are obtained

mz = (mz * MAG_SCALE) - moffz;

/* signal that data is ready */
sensor_data_ready = true;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sensor data ends up being ready after the loop, but then is never set to not ready again. If this process is preempted before finishing a frame, it is erroneously signalling valid data.
Additionally, to ensure that another process uses this data frame before updating it again, a yield() should be placed at the end of this loop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants