Add ifdef to bit definitions to avoid conflicts with other libraries. Refactor BITx to use BIT macro. (#45)

This commit is contained in:
Steve Karg
2020-02-18 08:21:54 -06:00
committed by GitHub
parent cf963a63ca
commit 9c41180145
19 changed files with 89 additions and 104 deletions
+3 -3
View File
@@ -70,10 +70,10 @@ uint16_t apdu_decode_confirmed_service_request(uint8_t * apdu, /* APDU data */
{
uint16_t len = 0; /* counts where we are in PDU */
service_data->segmented_message = (apdu[0] & BIT3) ? true : false;
service_data->more_follows = (apdu[0] & BIT2) ? true : false;
service_data->segmented_message = (apdu[0] & BIT(3)) ? true : false;
service_data->more_follows = (apdu[0] & BIT(2)) ? true : false;
service_data->segmented_response_accepted =
(apdu[0] & BIT1) ? true : false;
(apdu[0] & BIT(1)) ? true : false;
service_data->max_segs = decode_max_segs(apdu[1]);
service_data->max_resp = decode_max_apdu(apdu[1]);
service_data->invoke_id = apdu[2];
+2 -2
View File
@@ -274,7 +274,7 @@ static bool dlmstp_compare_data_expecting_reply(
}
request.invoke_id = request_pdu[offset + 2];
/* segmented message? */
if (request_pdu[offset] & BIT3)
if (request_pdu[offset] & BIT(3))
request.service_choice = request_pdu[offset + 5];
else
request.service_choice = request_pdu[offset + 3];
@@ -297,7 +297,7 @@ static bool dlmstp_compare_data_expecting_reply(
case PDU_TYPE_COMPLEX_ACK:
reply.invoke_id = reply_pdu[offset + 1];
/* segmented message? */
if (reply_pdu[offset] & BIT3)
if (reply_pdu[offset] & BIT(3))
reply.service_choice = reply_pdu[offset + 4];
else
reply.service_choice = reply_pdu[offset + 2];
+3 -3
View File
@@ -71,10 +71,10 @@ uint16_t apdu_decode_confirmed_service_request(
{
uint16_t len = 0; /* counts where we are in PDU */
service_data->segmented_message = (apdu[0] & BIT3) ? true : false;
service_data->more_follows = (apdu[0] & BIT2) ? true : false;
service_data->segmented_message = (apdu[0] & BIT(3)) ? true : false;
service_data->more_follows = (apdu[0] & BIT(2)) ? true : false;
service_data->segmented_response_accepted =
(apdu[0] & BIT1) ? true : false;
(apdu[0] & BIT(1)) ? true : false;
service_data->max_segs = decode_max_segs(apdu[1]);
service_data->max_resp = decode_max_apdu(apdu[1]);
service_data->invoke_id = apdu[2];
+2 -2
View File
@@ -273,7 +273,7 @@ static bool dlmstp_compare_data_expecting_reply(
}
request.invoke_id = request_pdu[offset + 2];
/* segmented message? */
if (request_pdu[offset] & BIT3)
if (request_pdu[offset] & BIT(3))
request.service_choice = request_pdu[offset + 5];
else
request.service_choice = request_pdu[offset + 3];
@@ -296,7 +296,7 @@ static bool dlmstp_compare_data_expecting_reply(
case PDU_TYPE_COMPLEX_ACK:
reply.invoke_id = reply_pdu[offset + 1];
/* segmented message? */
if (reply_pdu[offset] & BIT3)
if (reply_pdu[offset] & BIT(3))
reply.service_choice = reply_pdu[offset + 4];
else
reply.service_choice = reply_pdu[offset + 2];
+7 -7
View File
@@ -165,13 +165,13 @@ void test_task(
mstimer_reset(&Test_Timer);
sprintf(Send_Buffer, "BACnet: 0000000\r\n");
MSTP_MAC_Address = input_address();
Send_Buffer[8] = (MSTP_MAC_Address & BIT0) ? '1' : '0';
Send_Buffer[9] = (MSTP_MAC_Address & BIT1) ? '1' : '0';
Send_Buffer[10] = (MSTP_MAC_Address & BIT2) ? '1' : '0';
Send_Buffer[11] = (MSTP_MAC_Address & BIT3) ? '1' : '0';
Send_Buffer[12] = (MSTP_MAC_Address & BIT4) ? '1' : '0';
Send_Buffer[13] = (MSTP_MAC_Address & BIT5) ? '1' : '0';
Send_Buffer[14] = (MSTP_MAC_Address & BIT6) ? '1' : '0';
Send_Buffer[8] = (MSTP_MAC_Address & BIT(0)) ? '1' : '0';
Send_Buffer[9] = (MSTP_MAC_Address & BIT(1)) ? '1' : '0';
Send_Buffer[10] = (MSTP_MAC_Address & BIT(2)) ? '1' : '0';
Send_Buffer[11] = (MSTP_MAC_Address & BIT(3)) ? '1' : '0';
Send_Buffer[12] = (MSTP_MAC_Address & BIT(4)) ? '1' : '0';
Send_Buffer[13] = (MSTP_MAC_Address & BIT(5)) ? '1' : '0';
Send_Buffer[14] = (MSTP_MAC_Address & BIT(6)) ? '1' : '0';
serial_bytes_send((uint8_t *) Send_Buffer, 17);
}
if (serial_byte_get(&data_register)) {
+2 -2
View File
@@ -447,7 +447,7 @@ static bool dlmstp_compare_data_expecting_reply(
}
request.invoke_id = request_pdu[offset + 2];
/* segmented message? */
if (request_pdu[offset] & BIT3) {
if (request_pdu[offset] & BIT(3)) {
request.service_choice = request_pdu[offset + 5];
} else {
request.service_choice = request_pdu[offset + 3];
@@ -475,7 +475,7 @@ static bool dlmstp_compare_data_expecting_reply(
case PDU_TYPE_COMPLEX_ACK:
reply.invoke_id = reply_pdu[offset + 1];
/* segmented message? */
if (reply_pdu[offset] & BIT3) {
if (reply_pdu[offset] & BIT(3)) {
reply.service_choice = reply_pdu[offset + 4];
} else {
reply.service_choice = reply_pdu[offset + 2];
+2 -2
View File
@@ -444,7 +444,7 @@ bool dlmstp_compare_data_expecting_reply(
}
request.invoke_id = request_pdu[offset + 2];
/* segmented message? */
if (request_pdu[offset] & BIT3) {
if (request_pdu[offset] & BIT(3)) {
request.service_choice = request_pdu[offset + 5];
} else {
request.service_choice = request_pdu[offset + 3];
@@ -472,7 +472,7 @@ bool dlmstp_compare_data_expecting_reply(
case PDU_TYPE_COMPLEX_ACK:
reply.invoke_id = reply_pdu[offset + 1];
/* segmented message? */
if (reply_pdu[offset] & BIT3) {
if (reply_pdu[offset] & BIT(3)) {
reply.service_choice = reply_pdu[offset + 4];
} else {
reply.service_choice = reply_pdu[offset + 2];
+3 -3
View File
@@ -85,10 +85,10 @@ uint16_t apdu_decode_confirmed_service_request(
{
uint16_t len = 0; /* counts where we are in PDU */
service_data->segmented_message = (apdu[0] & BIT3) ? true : false;
service_data->more_follows = (apdu[0] & BIT2) ? true : false;
service_data->segmented_message = (apdu[0] & BIT(3)) ? true : false;
service_data->more_follows = (apdu[0] & BIT(2)) ? true : false;
service_data->segmented_response_accepted =
(apdu[0] & BIT1) ? true : false;
(apdu[0] & BIT(1)) ? true : false;
service_data->max_segs = decode_max_segs(apdu[1]);
service_data->max_resp = decode_max_apdu(apdu[1]);
service_data->invoke_id = apdu[2];
+2 -2
View File
@@ -590,7 +590,7 @@ static bool mstp_compare_data_expecting_reply(
}
request.invoke_id = request_pdu[offset + 2];
/* segmented message? */
if (request_pdu[offset] & BIT3)
if (request_pdu[offset] & BIT(3))
request.service_choice = request_pdu[offset + 5];
else
request.service_choice = request_pdu[offset + 3];
@@ -613,7 +613,7 @@ static bool mstp_compare_data_expecting_reply(
case PDU_TYPE_COMPLEX_ACK:
reply.invoke_id = reply_pdu[offset + 1];
/* segmented message? */
if (reply_pdu[offset] & BIT3)
if (reply_pdu[offset] & BIT(3))
reply.service_choice = reply_pdu[offset + 4];
else
reply.service_choice = reply_pdu[offset + 2];
+3 -3
View File
@@ -85,10 +85,10 @@ uint16_t apdu_decode_confirmed_service_request(
{
uint16_t len = 0; /* counts where we are in PDU */
service_data->segmented_message = (apdu[0] & BIT3) ? true : false;
service_data->more_follows = (apdu[0] & BIT2) ? true : false;
service_data->segmented_message = (apdu[0] & BIT(3)) ? true : false;
service_data->more_follows = (apdu[0] & BIT(2)) ? true : false;
service_data->segmented_response_accepted =
(apdu[0] & BIT1) ? true : false;
(apdu[0] & BIT(1)) ? true : false;
service_data->max_segs = decode_max_segs(apdu[1]);
service_data->max_resp = decode_max_apdu(apdu[1]);
service_data->invoke_id = apdu[2];
+3 -3
View File
@@ -590,7 +590,7 @@ static bool mstp_compare_data_expecting_reply(
}
request.invoke_id = request_pdu[offset + 2];
/* segmented message? */
if (request_pdu[offset] & BIT3)
if (request_pdu[offset] & BIT(3))
request.service_choice = request_pdu[offset + 5];
else
request.service_choice = request_pdu[offset + 3];
@@ -609,7 +609,7 @@ static bool mstp_compare_data_expecting_reply(
case PDU_TYPE_CONFIRMED_SERVICE_REQUEST:
reply.invoke_id = reply_pdu[offset + 2];
/* segmented message? */
if (reply_pdu[offset] & BIT3)
if (reply_pdu[offset] & BIT(3))
reply.service_choice = reply_pdu[offset + 5];
else
reply.service_choice = reply_pdu[offset + 3];
@@ -621,7 +621,7 @@ static bool mstp_compare_data_expecting_reply(
case PDU_TYPE_COMPLEX_ACK:
reply.invoke_id = reply_pdu[offset + 1];
/* segmented message? */
if (reply_pdu[offset] & BIT3)
if (reply_pdu[offset] & BIT(3))
reply.service_choice = reply_pdu[offset + 4];
else
reply.service_choice = reply_pdu[offset + 2];
+2 -2
View File
@@ -277,7 +277,7 @@ static bool dlmstp_compare_data_expecting_reply(
}
request.invoke_id = request_pdu[offset + 2];
/* segmented message? */
if (request_pdu[offset] & BIT3)
if (request_pdu[offset] & BIT(3))
request.service_choice = request_pdu[offset + 5];
else
request.service_choice = request_pdu[offset + 3];
@@ -300,7 +300,7 @@ static bool dlmstp_compare_data_expecting_reply(
case PDU_TYPE_COMPLEX_ACK:
reply.invoke_id = reply_pdu[offset + 1];
/* segmented message? */
if (reply_pdu[offset] & BIT3)
if (reply_pdu[offset] & BIT(3))
reply.service_choice = reply_pdu[offset + 4];
else
reply.service_choice = reply_pdu[offset + 2];
+2 -2
View File
@@ -350,7 +350,7 @@ bool dlmstp_compare_data_expecting_reply(
}
request.invoke_id = request_pdu[offset + 2];
/* segmented message? */
if (request_pdu[offset] & BIT3)
if (request_pdu[offset] & BIT(3))
request.service_choice = request_pdu[offset + 5];
else
request.service_choice = request_pdu[offset + 3];
@@ -372,7 +372,7 @@ bool dlmstp_compare_data_expecting_reply(
case PDU_TYPE_COMPLEX_ACK:
reply.invoke_id = reply_pdu[offset + 1];
/* segmented message? */
if (reply_pdu[offset] & BIT3)
if (reply_pdu[offset] & BIT(3))
reply.service_choice = reply_pdu[offset + 4];
else
reply.service_choice = reply_pdu[offset + 2];
+2 -2
View File
@@ -334,7 +334,7 @@ static bool dlmstp_compare_data_expecting_reply(
}
request.invoke_id = request_pdu[offset + 2];
/* segmented message? */
if (request_pdu[offset] & BIT3)
if (request_pdu[offset] & BIT(3))
request.service_choice = request_pdu[offset + 5];
else
request.service_choice = request_pdu[offset + 3];
@@ -357,7 +357,7 @@ static bool dlmstp_compare_data_expecting_reply(
case PDU_TYPE_COMPLEX_ACK:
reply.invoke_id = reply_pdu[offset + 1];
/* segmented message? */
if (reply_pdu[offset] & BIT3)
if (reply_pdu[offset] & BIT(3))
reply.service_choice = reply_pdu[offset + 4];
else
reply.service_choice = reply_pdu[offset + 2];
+1 -1
View File
@@ -253,7 +253,7 @@ static bool dlmstp_compare_data_expecting_reply(uint8_t * request_pdu,
}
request.invoke_id = request_pdu[offset + 2];
/* segmented message? */
if (request_pdu[offset] & BIT3)
if (request_pdu[offset] & BIT(3))
request.service_choice = request_pdu[offset + 5];
else
request.service_choice = request_pdu[offset + 3];