Appiko
main.c
1 /*
2  * main.c : Application for board level testing of SensePi devices
3  * Copyright (C) 2019 Appiko
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
30 #include <stdint.h>
31 #include "nrf.h"
32 #include "boards.h"
33 
34 #include "hal_clocks.h"
35 #include "hal_gpio.h"
36 #include "hal_nop_delay.h"
37 
38 #include "mcp4012_x.h"
39 #include "log.h"
40 
41 #include "hw_testing_app.h"
42 #include "product_id.h"
43 
44 #define NO_OF_TESTS 7
45 
46 static uint32_t flag_rev_pol_pro = 0;
47 static uint32_t flag_led = 0;
48 static uint32_t flag_dc_dc = 0;
49 static uint32_t flag_pot = 0;
50 static uint32_t flag_rc_output = 0;
51 static uint32_t flag_crystal = 0;
52 static uint32_t flag_freq_filter = 0;
58 int main(void)
59 {
60  hal_gpio_cfg_output(LED_GREEN, !(LEDS_ACTIVE_STATE));
61  hal_gpio_cfg_output(LED_RED, !(LEDS_ACTIVE_STATE));
63  log_init();
64  log_printf("\nHARDWARE TEST\n");
65  log_printf("START\n");
67  hal_nop_delay_ms(250);
68  flag_rev_pol_pro = power_test();
69  flag_dc_dc = dc_dc_test();
70  flag_led = led_test();
71  flag_crystal = crystal_test();
72  flag_rc_output = rc_test();
73  flag_freq_filter = freq_filter_test();
74  flag_pot = pot_test();
75  if( flag_rev_pol_pro && flag_dc_dc && flag_led && flag_pot && flag_rc_output
76  && flag_crystal && flag_freq_filter )
77  {
78  hal_gpio_pin_clear(LED_RED);
79  hal_gpio_pin_set(LED_GREEN);
80  log_printf("Status : 1\n");
81  log_printf("END\n");
82  }
83  else
84  {
85  hal_gpio_pin_clear(LED_GREEN);
86  hal_gpio_pin_set(LED_RED);
87  log_printf("Status : 0\n");
88  log_printf("END\n");
89  }
90  while(1)
91  {
92  }
93 }
uint32_t freq_filter_test(void)
This fucntion is used to check output filter designed for f(max)=10Hz This test will detect if any ot...
#define SPI_SCK_PIN
Definition: sensepi_rev4.h:96
#define LEDS_ACTIVE_STATE
Definition: bluey_1v1.h:44
uint32_t power_test(void)
This function is used to check power on the board If program execution starts properly,...
uint32_t dc_dc_test(void)
This fucntion is used to check DC/DC converter. If DC/DC circuit is present at input supply,...
uint32_t rc_test(void)
This fucntion is used to check output RC very low frequency filter. This function will actully check ...
void mcp4012_init(uint32_t CS_bar_pin_no, uint32_t UD_bar_pin_no, uint32_t SCK_pin_no)
This function is used to initialize MCP4012 in our program. This will set wiper value of MCP4012 to z...
Definition: mcp4012_x.c:69
#define MCP4012T_UD_PIN
Definition: sensepi_rev4.h:94
uint32_t led_test(void)
This fucntion is used to check on board LEDs. Operator has to be there to check if LEDs are blinking ...
uint32_t pot_test(void)
This fucntion is used to check MCP4012 pot. In this function we will check an ratio between two signa...
#define MCP4012T_CS_PIN
Definition: sensepi_rev4.h:92
void hfclk_xtal_init_blocking(void)
Function to start the crystal oscillator to be used for HF clock. This function blocks until the crys...
Definition: hal_clocks.c:71
int main(void)
Function for application main entry.
Definition: main.c:90
uint32_t crystal_test()
This fucntion is used to check on low frequency crystal. Without LF-XTAL we cannot use RTC....