Skip to content

Commit

Permalink
Expose more Mifare util functions (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
abobija authored Oct 1, 2024
1 parent f855abc commit 2d0bfb4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion idf_component.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: "3.2.2"
version: "3.2.3"
description: "Library for communication with RFID / NFC cards using MFRC522 module"
url: "https://github.com/abobija/esp-idf-rc522"
repository: "https://github.com/abobija/esp-idf-rc522.git"
Expand Down
8 changes: 8 additions & 0 deletions include/picc/rc522_mifare.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ esp_err_t rc522_mifare_read_sector_block(const rc522_handle_t rc522, const rc522
const rc522_mifare_sector_desc_t *sector_desc, const rc522_mifare_sector_block_t *trailer, uint8_t block_offset,
rc522_mifare_sector_block_t *out_block);

esp_err_t rc522_mifare_get_number_of_sectors(rc522_picc_type_t type, uint8_t *out_result);

uint8_t rc522_mifare_get_sector_index_by_block_address(uint8_t block_address);

esp_err_t rc522_mifare_get_number_of_blocks_in_sector(uint8_t sector_index, uint8_t *out_result);

esp_err_t rc522_mifare_get_sector_block_0_address(uint8_t sector_index, uint8_t *out_result);

// }}

#ifdef __cplusplus
Expand Down
8 changes: 4 additions & 4 deletions src/picc/rc522_mifare.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ static esp_err_t rc522_mifare_send(const rc522_handle_t rc522, const uint8_t *se
return ESP_OK;
}

static esp_err_t rc522_mifare_get_number_of_sectors(rc522_picc_type_t type, uint8_t *out_result)
esp_err_t rc522_mifare_get_number_of_sectors(rc522_picc_type_t type, uint8_t *out_result)
{
RC522_CHECK(rc522_mifare_type_is_classic_compatible(type) == false);
RC522_CHECK(out_result == NULL);
Expand All @@ -288,7 +288,7 @@ static esp_err_t rc522_mifare_get_number_of_sectors(rc522_picc_type_t type, uint
}
}

inline static uint8_t rc522_mifare_get_sector_index_by_block_address(uint8_t block_address)
inline uint8_t rc522_mifare_get_sector_index_by_block_address(uint8_t block_address)
{
if (block_address < 128) {
return block_address / 4;
Expand All @@ -298,7 +298,7 @@ inline static uint8_t rc522_mifare_get_sector_index_by_block_address(uint8_t blo
}
}

inline static esp_err_t rc522_mifare_get_number_of_blocks_in_sector(uint8_t sector_index, uint8_t *out_result)
inline esp_err_t rc522_mifare_get_number_of_blocks_in_sector(uint8_t sector_index, uint8_t *out_result)
{
RC522_CHECK(sector_index > RC522_MIFARE_SECTOR_INDEX_MAX);
RC522_CHECK(out_result == NULL);
Expand All @@ -313,7 +313,7 @@ inline static esp_err_t rc522_mifare_get_number_of_blocks_in_sector(uint8_t sect
return ESP_OK;
}

inline static esp_err_t rc522_mifare_get_sector_block_0_address(uint8_t sector_index, uint8_t *out_result)
inline esp_err_t rc522_mifare_get_sector_block_0_address(uint8_t sector_index, uint8_t *out_result)
{
RC522_CHECK(sector_index > RC522_MIFARE_SECTOR_INDEX_MAX);
RC522_CHECK(out_result == NULL);
Expand Down

0 comments on commit 2d0bfb4

Please sign in to comment.