1 /*********************************************************************************************************//**
2  * @file    CAN/Send_DATA/ht32_can_config.h
3  * @version $Rev:: 8164         $
4  * @date    $Date:: 2024-09-20 #$
5  * @brief   The header file of CAN baudrate configuration.
6  *************************************************************************************************************
7  * @attention
8  *
9  * Firmware Disclaimer Information
10  *
11  * 1. The customer hereby acknowledges and agrees that the program technical documentation, including the
12  *    code, which is supplied by Holtek Semiconductor Inc., (hereinafter referred to as "HOLTEK") is the
13  *    proprietary and confidential intellectual property of HOLTEK, and is protected by copyright law and
14  *    other intellectual property laws.
15  *
16  * 2. The customer hereby acknowledges and agrees that the program technical documentation, including the
17  *    code, is confidential information belonging to HOLTEK, and must not be disclosed to any third parties
18  *    other than HOLTEK and the customer.
19  *
20  * 3. The program technical documentation, including the code, is provided "as is" and for customer reference
21  *    only. After delivery by HOLTEK, the customer shall use the program technical documentation, including
22  *    the code, at their own risk. HOLTEK disclaims any expressed, implied or statutory warranties, including
23  *    the warranties of merchantability, satisfactory quality and fitness for a particular purpose.
24  *
25  * <h2><center>Copyright (C) Holtek Semiconductor Inc. All rights reserved</center></h2>
26  ************************************************************************************************************/
27 //-------- <<< Use Configuration Wizard in Context Menu >>> -----------------
28 /* Define to prevent recursive inclusion -------------------------------------------------------------------*/
29 #ifndef __HT32_CAN_CONFIG_H
30 #define __HT32_CAN_CONFIG_H
31 
32 #ifdef __cplusplus
33  extern "C" {
34 #endif
35 
36 
37 //  <q0> Enable CAN Config Check
38 //     <i> Display related setting by printf().
39 #define HTCFG_CAN_CONF_CHECK_ENABLE               (0)
40 
41 //  <h> Core Clock Setting
42 //  </h>
43 //  <o0> -- Core Clock Calculation Setting
44 //     <i> HTCFG_CAN_CORECLKSEL
45 //     <i> Define the Core Clock by default maximum clock setting or manual input.
46 //     <i> 0 = Default Maximum (LIBCFG_MAX_SPEED)
47 //     <i> 1 = Manual Input (HTCFG_CAN_CORECLK_MANUAL)
48 //       <0=> Default Maximum (LIBCFG_MAX_SPEED)
49 //       <1=> Manual Input (HTCFG_CAN_CORECLK_MANUAL)
50 //     <i> Note: CK_CAN = (Core Clock) / (CAN Peripheral Clock Prescaler)
51 //  <o1> -- Core Clock Manual Input (Hz)
52 //     <i> HTCFG_CAN_CORECLK_MANUAL
53 //     <i> Only meaningful when HTCFG_CAN_CLKSEL = 1 (Manual Input)
54 #define HTCFG_CAN_CORECLKSEL                      (0)         // 0 = Default Maximum (LIBCFG_MAX_SPEED), 1 = Manual Input (HTCFG_CAN_CORECLK_MANUAL)
55 #define HTCFG_CAN_CORECLK_MANUAL                  (8000000)  // Only meaningful when HTCFG_CAN_CORECLKSEL = 1 (Manual Input)
56 
57 //  <h> ------------------------------------------
58 //  </h>
59 
60 //  <h> CAN Config 0 Setting
61 //  </h>
62 //  <o0> CAN Peripheral Clock Selection (CANnPCLK)
63 //     <i> HTCFG_CAN_CLK_PRESCALER
64 //       <0=> Div 1
65 //       <1=> Div 2
66 //       <2=> Div 4
67 //       <3=> Div 8
68 #define HTCFG_CAN_CF0_CLK_DIV                     (0)         // 0 = /1, 1 = /2, 2 = /4, 3 = /8
69 
70 /*
71 //  <o> CAN Baudrate
72 //    <i> HTCFG_CAN_BAUDRATE
73 //      <1000000=> 1000 kbps
74 //      <800000=>   800 kbps
75 //      <500000=>   500 kbps
76 //      <250000=>   250 kbps
77 //      <125000=>   125 kbps
78 //      <100000=>   100 kbps
79 //      <50000=>     50 kbps
80 //      <20000=>     20 kbps
81 //      <10000=>     10 kbps
82 //      <5000=>       5 kbps
83 //    <i> The CAN baudrate specifies the frequency of transitions occurring per second.
84 */
85 #define HTCFG_CAN_CF0_BAUDRATE                    (500000)
86 
87 /*
88 //  <o> CAN Sample Point Target (%) <50-90:1>
89 //    <i> HTCFG_CAN_SAMPLE_POINT
90 //    <i> The Sample Point is the specific location within each bit period where the CAN_Core samples the CAN bus's state (dominant or recessive).
91 //    <i> Notice: The real calculation result may small than the HTCFG_CAN_SAMPLE_POINT setting.
92 */
93 #define HTCFG_CAN_CF0_SAMPLE_POINT                (70)
94 
95 //  <o> CAN SJW (Synchronisation Jump Width)
96 //    <i> HTCFG_CAN_BIT_TIME_SJW
97 //    <i> The (Re-)Synchronisation Jump Width.
98 //      <1=> 1
99 //      <2=> 2
100 //      <3=> 3
101 //      <4=> 4
102 #define HTCFG_CAN_CF0_BIT_TIME_SJW                (1)       // 1 ~ 4
103 
104 #include "ht32_can_config0_calc.h"
105 
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 #endif
112