![ARTERY AT32F435 Series Скачать руководство пользователя страница 552](http://html1.mh-extra.com/html/artery/at32f435-series/at32f435-series_reference-manual_2977592552.webp)
AT32F435/437
Series Reference Manual
2022.11.11
Page 552
Rev 2.03
bit in the CSD, part of the data can be protected, and the write protection can be changed by the
application. The SET_WRITE_PROT commands set the write protection of the addressed group. The
CLR_WRITE_PROT commands clear the write protection of the addressed group. The
SEND_WRITE_PROT command is similar to a single block read command. The card sends a data block
containing 32 write protection bits (representing 32 write protect groups starting at the specified address)
followed by 16 CRC bits. The address filed in the write protect commands is a group address in byte
units.
Password protect
The password protection function enables the SDIO card host to lock and unlock a card with a password.
The password is stored in the 128-bit PWD register and its size is set in the 8-bit PWD_LEN register.
These registers are nonvolatile so that the content is not erased after power-off.
Locked cards can support certain commands, indicating that the host is allowed to reset, initialize and
query for status, but not allowed to access data on the card. When the password is set (PWD_LEN is
nonzero value), the card is locked automatically after power-up.
Like the CSD and CID register write commands, the lock/unlock commands are valid only in a transfer
state. The command does not include an address parameter and thus the card must be selected before
using it.
The card lock/unlock commands have the structure and bus transaction types of a regular single-block
write command. The transferred data block include all the information required for the command (the
password setting mode, PWD content and card lock/unlock indication). The command data block size is
defined by the SDIO card host module before it sends the card lock/unlock command. The lock/unlock
command structure is shown below:
Table 25-1
Lock/unlock command structure
Byte
Bit7 Bit6 Bit5 Bit4
Bit3
Bit2
Bit1
Bit0
0
Reserved(set to 0)
ERASE
LOCK_UNLOCK
CLR_PWD
SET_PWD
1
PWDS_LEN
2
password data
…
P1
ERASE: Setting it will force an erase operation. All other bits must be zero, and only the
command byte is sent.
LOCK_UNLOCK: Setting it will lock the card. Clearing it will unlock the card. LOCK_UNLOCK
can be set simultaneously with SET_PWD, but not with the CLR_PWD.
CLR_PWD: Setting it will clear the password data.
SET_PWD: Setting this bit will save the password data to memory.
PWD_LEN: This bit defines the length of the password in bytes. When the password is changed,
the length is the combination of the old and new passwords.
PWD: password (new or currently used, depending on the command)
The data block size should be defined by the host before it sends the card lock/unlock command. The
block length should be equal to or greater than the data structure required for the lock/unlock command.
The following sections list the command sequence to set/clear a password, lock/unlock a card, and force
an erase operation.
Setting the password
1.
Select a card using CMD7 (SELECT/DESELECT_CARD), if none is selected previously
2.
Define the block length with CMD16(SET_BLOCKLEN) to send in the 8-bit card lock/unlock
mode, 8-bit PWD_LEN, and the number of bytes of the new password. When a password is
replaced, the block size must take into account the length of both the old and the new
passwords sent with the command.
3.
Send CMD42(LOCK/UNLOCK) with the appropriate data block size on the data line including
the 16-bit CRC. The data block indicates the operation mode (SET_PWD=1), the length
(PWD_LEN) and the password (PWD). When a password replacement is done, the length
value includes the length of the both passwords, the old and the new one, and the PWD field
includes the old password (currently used) followed by the new password.