1 /*
2 * Copyright (c) 2022 HPMicro
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8 #include "hpm_tsns_drv.h"
9
tsns_configure_low_limit_event(TSNS_Type * ptr,int32_t low,tsns_event_t e)10 void tsns_configure_low_limit_event(TSNS_Type *ptr, int32_t low, tsns_event_t e)
11 {
12 switch (e) {
13 case tsns_event_irq:
14 tsns_set_irq_threshold_low(ptr, low);
15 ptr->CONFIG |= TSNS_CONFIG_IRQ_EN_MASK | TSNS_CONFIG_COMPARE_MIN_EN_MASK;
16 break;
17 case tsns_event_reset:
18 tsns_set_reset_threshold_low(ptr, low);
19 ptr->CONFIG |= TSNS_CONFIG_RST_EN_MASK | TSNS_CONFIG_COMPARE_MIN_EN_MASK;
20 break;
21 default:
22 assert(NULL);
23 }
24 }
25
tsns_configure_high_limit_event(TSNS_Type * ptr,int32_t high,tsns_event_t e)26 void tsns_configure_high_limit_event(TSNS_Type *ptr, int32_t high, tsns_event_t e)
27 {
28 switch (e) {
29 case tsns_event_irq:
30 tsns_set_irq_threshold_high(ptr, high);
31 ptr->CONFIG |= TSNS_CONFIG_IRQ_EN_MASK | TSNS_CONFIG_COMPARE_MAX_EN_MASK;
32 break;
33 case tsns_event_reset:
34 tsns_set_reset_threshold_high(ptr, high);
35 ptr->CONFIG |= TSNS_CONFIG_RST_EN_MASK | TSNS_CONFIG_COMPARE_MAX_EN_MASK;
36 break;
37 default:
38 assert(NULL);
39 }
40 }
41
tsns_configure_limit_event(TSNS_Type * ptr,int32_t high,int32_t low,tsns_event_t e)42 void tsns_configure_limit_event(TSNS_Type *ptr, int32_t high, int32_t low, tsns_event_t e)
43 {
44 assert(high > low);
45 switch (e) {
46 case tsns_event_irq:
47 tsns_config_irq_threshold(ptr, high, low);
48 ptr->CONFIG |= TSNS_CONFIG_IRQ_EN_MASK | TSNS_CONFIG_COMPARE_MAX_EN_MASK | TSNS_CONFIG_COMPARE_MIN_EN_MASK;
49 break;
50 case tsns_event_reset:
51 tsns_config_reset_threshold(ptr, high, low);
52 ptr->CONFIG |= TSNS_CONFIG_RST_EN_MASK | TSNS_CONFIG_COMPARE_MAX_EN_MASK | TSNS_CONFIG_COMPARE_MIN_EN_MASK;
53 break;
54 default:
55 assert(NULL);
56 }
57 }
58
59