2 * Copyright © 2020 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 #include <ao_micropeak.h>
22 #include <ao_adc_stm32l0.h>
30 uint32_t icscr = stm_rcc.icscr;
32 /* Set MSI clock to desired range */
33 icscr &= ~(STM_RCC_ICSCR_MSIRANGE_MASK << STM_RCC_ICSCR_MSIRANGE);
34 icscr |= (AO_MSI_RANGE << STM_RCC_ICSCR_MSIRANGE);
35 stm_rcc.icscr = icscr;
37 /* Set vcore to 1.2V */
38 uint32_t cr = stm_pwr.cr;
39 cr &= ~(STM_PWR_CR_VOS_MASK << STM_PWR_CR_VOS);
40 cr |= (STM_PWR_CR_VOS_1_2 << STM_PWR_CR_VOS);
47 printf("flight %d start %x end %x\n",
48 1, 0 >> 8, ao_storage_total >> 8);
51 const struct ao_cmds ao_micro_cmds[] = {
52 { list_flights, "l\0List flights" },
59 static struct ao_ms5607_value value;
61 ao_ms5607_sample(&ao_ms5607_current);
62 ao_ms5607_convert(&ao_ms5607_current, &value);
72 ao_led_on(AO_LED_ORANGE);
80 uint16_t vref = ao_adc_read_vref();
82 uint32_t vdda = 3 * stm_vrefint_cal.vrefint_cal * 1000 / vref;
83 ao_led_off(AO_LED_ORANGE);
85 /* Power supply > 3.25V means we're on USB power */
89 ao_cmd_register(ao_micro_cmds);