problem regarding pointers

function specification:
Name:void MilCAN_Init(----);
The call backs should be set. That is, they all shall be assigned according to their name, but only if they pass a not-zero value. If they are zero or 0xffff the callbacks shall still point to the empty functions.

milCAN.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef MILCAN_
#define MILCAN_

typedef enum MILCAN_MODES_t
{
	MILCAN_MODE_PREOPERATIONAL = 0X01,
	MILCAN_MODE_OPERATIONAL = 0X02,
	MILCAN_MODE_CONFIGURATION = 0X03
} MILCAN_MODES_t;

typedef enum MILCAN_CHARACTER_t
{
	MilCAN_ENTER_CHAR_NBR_1 = 0X43,
	MilCAN_ENTER_CHAR_NBR_2 = 0X46,
	MilCAN_ENTER_CHAR_NBR_3 = 0X47,
	MilCAN_EXIT_CHAR_NBR_1 = 0X4F,
	MilCAN_EXIT_CHAR_NBR_2 = 0X50,
	MilCAN_EXIT_CHAR_NBR_3 = 0X52
} MILCAN_CHARACTER_t;

typedef struct MILCAN_DATA_t
{
	MILCAN_MODES_t mode_milcan;
} MILCAN_DATA_t;

typedef union MILCAN_DATA_t
{
	MILCAN__MODES_t mode_milcan;
	MILCAN__CHARACTER_t config_mode_next;
	uint16_t counter_525ms;
	uint16_t counter_1100ms;
	uint16_t counter_8ptu;
} MILCAN_DATA_t;

typedef void(*MilCAN_ConfigMode_Status_CB_t) (uint16_t);
typedef void(*MilCAN_ConfigMode_CB_t) ();
typedef void(*MilCAN_OperationalMode_CB_t) ();
typedef void(*MilCAN_PreoperationalMode_CB_t) ();
typedef void(*MilCAN_Dosynchronize_CB_t) (uint16_t);

void MilCAN_Init(MilCAN_ConfigMode_Status_CB_t ConfigMode_status,
		MilCAN_ConfigMode_CB_t ConfigMode,
		MilCAN_OperationalMode_CB_t OperationalMode,
		MilCAN_PreoperationalMode_CB_t PreoperationalMode,
		MilCAN_Dosynchronize_CB_t Dosynchroniza);


milCAN.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include "milCAN.h"

static MILCAN_DATA_t milcan_data;
uint16_t MILCAn_PTU_TIME = 2u;
const uint16_t TIME_525ms= 1050u;
const uint16_t TIME_1100ms=2200u;
const uint16_t TIME_8PTUs=MilCAN_PTU_TIME*16u;

static MilCAN_ConfigMode_Status_CB_t MilCAN_ConfigMode_Status	=&MILCAN_StubUint16;   		
static MilCAN_ConfigMode_CB_t MilCAN_ConfigMode			=&MILCAN_StubVoid;		
static MilCAN_OperationalMode_CB_t MilCAN_OperationalMode	=&MILCAN_StubVoid;		
static MilCAN_PreoperationalMode_CB_t MilCAN_PreOperationalMode	=&MILCAN_StubVoid;   		
static MilCAN_Dosynchronize_CB_t MilCAN_DoSynchronize		=&MILCAN_StubUint16;	

void MilCAN_Init(const   MilCAN_ConfigMode_Status_CB_t ConfigMode_Status,
		const MilCAN_ConfigMode_CB_t ConfigMode,
		const MilCAN_OperationalMode_CB_t OperationalMode,
		const MilCAN_PreoperationalMode_CB_t PreOperationalMode,
		const MilCAN_Dosynchronize_CB_t DoSynchronize)
{
	milcan_data.mode_milcan = MILCAN_MODE_PREOPERATIONAL;
	milcan_data.config_mode_next = MilCAN_ENTER_CHAR_NBR_1;

	milcan_data.counter_1100ms = TIME_1100ms;
	milcan_data.counter_525ms = TIME_525ms;
	milcan_data.counter_8ptu = TIME_8PTUs;
        
        //CallBacks are set here
	
}


MILCAN_StubUint16 (); these are empty functions.
MILCAN_StubVoid ();
MILCAN_StubVoid ();
MILCAN_StubVoid ();
MILCAN_StubUint16 ();

How do i set the callbacks in Initialization function?

please help!!!
Kind Regards.
1
2
3
if (ConfigMode_Status != nullptr && (int)ConfigMode_Status != 0xffff) {
    MilCAN_ConfigMode_Status = ConfigMode_Status;
}

// etc.
Topic archived. No new replies allowed.