From 35c885898abb866256bfcc5e62f13913f89e4e25 Mon Sep 17 00:00:00 2001 From: Florent Duchon Date: Tue, 23 Apr 2013 16:45:01 +0200 Subject: digital/zigbit/common: rework of UID definition --- digital/zigbit/common/uid.c | 38 ++++++++++++++++++++++++++++++-------- digital/zigbit/common/uid.h | 23 ++++++++++++++++++++++- 2 files changed, 52 insertions(+), 9 deletions(-) diff --git a/digital/zigbit/common/uid.c b/digital/zigbit/common/uid.c index 6ecc8ce9..9f8bff42 100644 --- a/digital/zigbit/common/uid.c +++ b/digital/zigbit/common/uid.c @@ -26,13 +26,27 @@ /* This function returns the UID of the device according to the mapping of F5 F6 F7 F8*/ #include "uid.h" +#include /* APBTeam static zigbit device list */ -static DeviceType_t apbeam_zigbit_table[APBTEAM_MAX_ZIGBIT_DEVICES] = +static zigbit_definition_s apbeam_zigbit_table[APBTEAM_MAX_ZIGBIT_DEVICES] = { - DEVICE_TYPE_COORDINATOR, - DEVICE_TYPE_END_DEVICE, - DEVICE_TYPE_END_DEVICE + {0 ,DEVICE_TYPE_COORDINATOR ,ZIGBIT_BEACON}, + {1 ,DEVICE_TYPE_ROUTER ,ZIGBIT_BEACON}, + {2 ,DEVICE_TYPE_ROUTER ,ZIGBIT_BEACON}, + {3 ,DEVICE_TYPE_ROUTER ,ZIGBIT_BEACON}, + {4 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED}, + {5 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED}, + {6 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED}, + {7 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED}, + {8 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED}, + {9 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED}, + {10 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED}, + {11 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED}, + {12 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED}, + {13 ,DEVICE_TYPE_ROUTER ,ZIGBIT_NOT_DEFINED}, + {14 ,DEVICE_TYPE_ROUTER ,ZIGBIT_DONGLE}, + {15 ,DEVICE_TYPE_ROUTER ,ZIGBIT_DONGLE}, }; /* This function returns the UID of the device according to the mapping of F5 F6 F7 F8*/ @@ -46,6 +60,8 @@ uint16_t get_uid(void) /* F4 -> F7 configured as input */ DDRF = 0x00; + _delay_ms(10); + if(PINF&0x20) //PINF5 value &= 0xF7; @@ -59,14 +75,20 @@ uint16_t get_uid(void) value &= 0xFE; /* Nothing connected */ - if(PINF&0xFF) - value &=0xF0; - +// if(PINF&0xFF) +// value &=0xF0; + return value; } /* This function returns the device type */ DeviceType_t get_device_type(uint16_t uid) { - return apbeam_zigbit_table[uid]; + return apbeam_zigbit_table[uid].type; +} + +/* This function returns the device functionnaly */ +TFunctionnality get_device_functionnality(uint16_t uid) +{ + return apbeam_zigbit_table[uid].func; } diff --git a/digital/zigbit/common/uid.h b/digital/zigbit/common/uid.h index c5a5c8f4..f3969b2e 100644 --- a/digital/zigbit/common/uid.h +++ b/digital/zigbit/common/uid.h @@ -23,11 +23,32 @@ * * }}} */ -#define APBTEAM_MAX_ZIGBIT_DEVICES 3 +#ifndef _UID_H +#define _UID_H +#define APBTEAM_MAX_ZIGBIT_DEVICES 16 + +typedef enum +{ + ZIGBIT_NOT_DEFINED, + ZIGBIT_BEACON, + ZIGBIT_DONGLE, +} TFunctionnality; + +typedef struct +{ + uint16_t uid; + DeviceType_t type; + TFunctionnality func; +} zigbit_definition_s; /* This function returns the UID of the device according to the mapping of F5 F6 F7 F8*/ uint16_t get_uid(void); /* This function returns the device type */ DeviceType_t get_device_type(uint16_t uid); + +/* This function returns the device functionnaly */ +TFunctionnality get_device_functionnality(uint16_t uid); + +#endif -- cgit v1.2.3